Bug 1658856 - Fix overdraw and unused tile pixel computation in the profiler markers. r=mattwoodrow

Differential Revision: https://phabricator.services.mozilla.com/D86888
This commit is contained in:
Markus Stange 2020-08-21 22:47:38 +00:00
Родитель 66928a1e5b
Коммит 418d5452f5
2 изменённых файлов: 18 добавлений и 12 удалений

Просмотреть файл

@ -165,7 +165,7 @@ uint32_t RenderCompositorNative::GetMaxUpdateRects() {
void RenderCompositorNative::CompositorBeginFrame() { void RenderCompositorNative::CompositorBeginFrame() {
mAddedLayers.Clear(); mAddedLayers.Clear();
mAddedPixelCount = 0; mAddedTilePixelCount = 0;
mAddedClippedPixelCount = 0; mAddedClippedPixelCount = 0;
mBeginFrameTimeStamp = TimeStamp::NowUnfuzzed(); mBeginFrameTimeStamp = TimeStamp::NowUnfuzzed();
mSurfacePoolHandle->OnBeginFrame(); mSurfacePoolHandle->OnBeginFrame();
@ -187,10 +187,10 @@ void RenderCompositorNative::CompositorEndFrame() {
int(mDrawnPixelCount * 100 / windowPixelCount), int(mDrawnPixelCount * 100 / windowPixelCount),
int(mAddedClippedPixelCount * 100 / windowPixelCount), int(mAddedClippedPixelCount * 100 / windowPixelCount),
int(mAddedLayers.Length()), int(mAddedLayers.Length()),
int(mAddedPixelCount * 100 / windowPixelCount), int(mAddedTilePixelCount * 100 / windowPixelCount),
int(nativeLayerCount - mAddedLayers.Length()), int(nativeLayerCount - mAddedLayers.Length()),
int((mTotalPixelCount - mAddedPixelCount) * 100 / int((mTotalTilePixelCount - mAddedTilePixelCount) *
windowPixelCount)), 100 / windowPixelCount)),
JS::ProfilingCategoryPair::GRAPHICS, mBeginFrameTimeStamp, JS::ProfilingCategoryPair::GRAPHICS, mBeginFrameTimeStamp,
TimeStamp::NowUnfuzzed()); TimeStamp::NowUnfuzzed());
} }
@ -270,8 +270,10 @@ void RenderCompositorNative::DestroySurface(NativeSurfaceId aId) {
MOZ_RELEASE_ASSERT(surfaceCursor != mSurfaces.end()); MOZ_RELEASE_ASSERT(surfaceCursor != mSurfaces.end());
Surface& surface = surfaceCursor->second; Surface& surface = surfaceCursor->second;
for (const auto& iter : surface.mNativeLayers) { if (!surface.mIsExternal) {
mTotalPixelCount -= gfx::IntRect({}, iter.second->GetSize()).Area(); for (const auto& iter : surface.mNativeLayers) {
mTotalTilePixelCount -= gfx::IntRect({}, iter.second->GetSize()).Area();
}
} }
mSurfaces.erase(surfaceCursor); mSurfaces.erase(surfaceCursor);
@ -287,7 +289,7 @@ void RenderCompositorNative::CreateTile(wr::NativeSurfaceId aId, int aX,
RefPtr<layers::NativeLayer> layer = mNativeLayerRoot->CreateLayer( RefPtr<layers::NativeLayer> layer = mNativeLayerRoot->CreateLayer(
surface.TileSize(), surface.mIsOpaque, mSurfacePoolHandle); surface.TileSize(), surface.mIsOpaque, mSurfacePoolHandle);
surface.mNativeLayers.insert({TileKey(aX, aY), layer}); surface.mNativeLayers.insert({TileKey(aX, aY), layer});
mTotalPixelCount += gfx::IntRect({}, layer->GetSize()).Area(); mTotalTilePixelCount += gfx::IntRect({}, layer->GetSize()).Area();
} }
void RenderCompositorNative::DestroyTile(wr::NativeSurfaceId aId, int aX, void RenderCompositorNative::DestroyTile(wr::NativeSurfaceId aId, int aX,
@ -301,7 +303,7 @@ void RenderCompositorNative::DestroyTile(wr::NativeSurfaceId aId, int aX,
MOZ_RELEASE_ASSERT(layerCursor != surface.mNativeLayers.end()); MOZ_RELEASE_ASSERT(layerCursor != surface.mNativeLayers.end());
RefPtr<layers::NativeLayer> layer = std::move(layerCursor->second); RefPtr<layers::NativeLayer> layer = std::move(layerCursor->second);
surface.mNativeLayers.erase(layerCursor); surface.mNativeLayers.erase(layerCursor);
mTotalPixelCount -= gfx::IntRect({}, layer->GetSize()).Area(); mTotalTilePixelCount -= gfx::IntRect({}, layer->GetSize()).Area();
// If the layer is currently present in mNativeLayerRoot, it will be destroyed // If the layer is currently present in mNativeLayerRoot, it will be destroyed
// once CompositorEndFrame() replaces mNativeLayerRoot's layers and drops that // once CompositorEndFrame() replaces mNativeLayerRoot's layers and drops that
@ -350,9 +352,13 @@ void RenderCompositorNative::AddSurface(
layer->SetSamplingFilter(ToSamplingFilter(aImageRendering)); layer->SetSamplingFilter(ToSamplingFilter(aImageRendering));
mAddedLayers.AppendElement(layer); mAddedLayers.AppendElement(layer);
mAddedPixelCount += layerSize.width * layerSize.height; if (!surface.mIsExternal) {
mAddedTilePixelCount += layerSize.width * layerSize.height;
}
gfx::Rect r = transform.TransformBounds(
gfx::Rect(layer->CurrentSurfaceDisplayRect()));
gfx::IntRect visibleRect = gfx::IntRect visibleRect =
clipRect.Intersect(layer->CurrentSurfaceDisplayRect() + layerPosition); clipRect.Intersect(RoundedToInt(r) + layerPosition);
mAddedClippedPixelCount += visibleRect.Area(); mAddedClippedPixelCount += visibleRect.Area();
} }
} }

Просмотреть файл

@ -123,8 +123,8 @@ class RenderCompositorNative : public RenderCompositor {
// Used in native compositor mode: // Used in native compositor mode:
RefPtr<layers::NativeLayer> mCurrentlyBoundNativeLayer; RefPtr<layers::NativeLayer> mCurrentlyBoundNativeLayer;
nsTArray<RefPtr<layers::NativeLayer>> mAddedLayers; nsTArray<RefPtr<layers::NativeLayer>> mAddedLayers;
uint64_t mTotalPixelCount = 0; uint64_t mTotalTilePixelCount = 0;
uint64_t mAddedPixelCount = 0; uint64_t mAddedTilePixelCount = 0;
uint64_t mAddedClippedPixelCount = 0; uint64_t mAddedClippedPixelCount = 0;
uint64_t mDrawnPixelCount = 0; uint64_t mDrawnPixelCount = 0;
gfx::IntRect mVisibleBounds; gfx::IntRect mVisibleBounds;