diff options
67 files changed, 241 insertions, 191 deletions
diff --git a/cc/bitmap_content_layer_updater.cc b/cc/bitmap_content_layer_updater.cc index 222ab21..2dd4d29 100644 --- a/cc/bitmap_content_layer_updater.cc +++ b/cc/bitmap_content_layer_updater.cc @@ -23,7 +23,7 @@ BitmapContentLayerUpdater::Resource::~Resource() { } -void BitmapContentLayerUpdater::Resource::update(ResourceUpdateQueue& queue, const gfx::Rect& sourceRect, const gfx::Vector2d& destOffset, bool partialUpdate, RenderingStats&) +void BitmapContentLayerUpdater::Resource::update(ResourceUpdateQueue& queue, const gfx::Rect& sourceRect, const gfx::Vector2d& destOffset, bool partialUpdate, RenderingStats*) { updater()->updateTexture(queue, texture(), sourceRect, destOffset, partialUpdate); } @@ -48,14 +48,15 @@ scoped_ptr<LayerUpdater::Resource> BitmapContentLayerUpdater::createResource(Pri return scoped_ptr<LayerUpdater::Resource>(new Resource(this, PrioritizedResource::create(manager))); } -void BitmapContentLayerUpdater::prepareToUpdate(const gfx::Rect& contentRect, const gfx::Size& tileSize, float contentsWidthScale, float contentsHeightScale, gfx::Rect& resultingOpaqueRect, RenderingStats& stats) +void BitmapContentLayerUpdater::prepareToUpdate(const gfx::Rect& contentRect, const gfx::Size& tileSize, float contentsWidthScale, float contentsHeightScale, gfx::Rect& resultingOpaqueRect, RenderingStats* stats) { if (m_canvasSize != contentRect.size()) { m_canvasSize = contentRect.size(); m_canvas = make_scoped_ptr(skia::CreateBitmapCanvas(m_canvasSize.width(), m_canvasSize.height(), m_opaque)); } - stats.totalPixelsRasterized += contentRect.width() * contentRect.height(); + if (stats) + stats->totalPixelsRasterized += contentRect.width() * contentRect.height(); paintContents(m_canvas.get(), contentRect, contentsWidthScale, contentsHeightScale, resultingOpaqueRect, stats); } diff --git a/cc/bitmap_content_layer_updater.h b/cc/bitmap_content_layer_updater.h index f951a55d..9f6af1c 100644 --- a/cc/bitmap_content_layer_updater.h +++ b/cc/bitmap_content_layer_updater.h @@ -25,7 +25,7 @@ public: Resource(BitmapContentLayerUpdater*, scoped_ptr<PrioritizedResource>); virtual ~Resource(); - virtual void update(ResourceUpdateQueue&, const gfx::Rect& sourceRect, const gfx::Vector2d& destOffset, bool partialUpdate, RenderingStats&) OVERRIDE; + virtual void update(ResourceUpdateQueue&, const gfx::Rect& sourceRect, const gfx::Vector2d& destOffset, bool partialUpdate, RenderingStats*) OVERRIDE; private: BitmapContentLayerUpdater* updater() { return m_updater; } @@ -36,7 +36,7 @@ public: static scoped_refptr<BitmapContentLayerUpdater> create(scoped_ptr<LayerPainter>); virtual scoped_ptr<LayerUpdater::Resource> createResource(PrioritizedResourceManager*) OVERRIDE; - virtual void prepareToUpdate(const gfx::Rect& contentRect, const gfx::Size& tileSize, float contentsWidthScale, float contentsHeightScale, gfx::Rect& resultingOpaqueRect, RenderingStats&) OVERRIDE; + virtual void prepareToUpdate(const gfx::Rect& contentRect, const gfx::Size& tileSize, float contentsWidthScale, float contentsHeightScale, gfx::Rect& resultingOpaqueRect, RenderingStats*) OVERRIDE; void updateTexture(ResourceUpdateQueue&, PrioritizedResource*, const gfx::Rect& sourceRect, const gfx::Vector2d& destOffset, bool partialUpdate); virtual void setOpaque(bool) OVERRIDE; diff --git a/cc/bitmap_skpicture_content_layer_updater.cc b/cc/bitmap_skpicture_content_layer_updater.cc index 5c0e512..dab97b1 100644 --- a/cc/bitmap_skpicture_content_layer_updater.cc +++ b/cc/bitmap_skpicture_content_layer_updater.cc @@ -20,16 +20,19 @@ BitmapSkPictureContentLayerUpdater::Resource::Resource(BitmapSkPictureContentLay { } -void BitmapSkPictureContentLayerUpdater::Resource::update(ResourceUpdateQueue& queue, const gfx::Rect& sourceRect, const gfx::Vector2d& destOffset, bool partialUpdate, RenderingStats& stats) +void BitmapSkPictureContentLayerUpdater::Resource::update(ResourceUpdateQueue& queue, const gfx::Rect& sourceRect, const gfx::Vector2d& destOffset, bool partialUpdate, RenderingStats* stats) { m_bitmap.setConfig(SkBitmap::kARGB_8888_Config, sourceRect.width(), sourceRect.height()); m_bitmap.allocPixels(); m_bitmap.setIsOpaque(m_updater->layerIsOpaque()); SkDevice device(m_bitmap); SkCanvas canvas(&device); - base::TimeTicks paintBeginTime = base::TimeTicks::Now(); + base::TimeTicks paintBeginTime; + if (stats) + paintBeginTime = base::TimeTicks::Now(); updater()->paintContentsRect(&canvas, sourceRect, stats); - stats.totalPaintTime += base::TimeTicks::Now() - paintBeginTime; + if (stats) + stats->totalPaintTime += base::TimeTicks::Now() - paintBeginTime; ResourceUpdate upload = ResourceUpdate::Create( texture(), &m_bitmap, sourceRect, sourceRect, destOffset); @@ -58,15 +61,19 @@ scoped_ptr<LayerUpdater::Resource> BitmapSkPictureContentLayerUpdater::createRes return scoped_ptr<LayerUpdater::Resource>(new Resource(this, PrioritizedResource::create(manager))); } -void BitmapSkPictureContentLayerUpdater::paintContentsRect(SkCanvas* canvas, const gfx::Rect& sourceRect, RenderingStats& stats) +void BitmapSkPictureContentLayerUpdater::paintContentsRect(SkCanvas* canvas, const gfx::Rect& sourceRect, RenderingStats* stats) { // Translate the origin of contentRect to that of sourceRect. canvas->translate(contentRect().x() - sourceRect.x(), contentRect().y() - sourceRect.y()); - base::TimeTicks rasterizeBeginTime = base::TimeTicks::Now(); + base::TimeTicks rasterizeBeginTime; + if (stats) + rasterizeBeginTime = base::TimeTicks::Now(); drawPicture(canvas); - stats.totalRasterizeTime += base::TimeTicks::Now() - rasterizeBeginTime; - stats.totalPixelsRasterized += sourceRect.width() * sourceRect.height(); + if (stats) { + stats->totalRasterizeTime += base::TimeTicks::Now() - rasterizeBeginTime; + stats->totalPixelsRasterized += sourceRect.width() * sourceRect.height(); + } } } // namespace cc diff --git a/cc/bitmap_skpicture_content_layer_updater.h b/cc/bitmap_skpicture_content_layer_updater.h index db09eb7..60c7745 100644 --- a/cc/bitmap_skpicture_content_layer_updater.h +++ b/cc/bitmap_skpicture_content_layer_updater.h @@ -18,7 +18,7 @@ public: public: Resource(BitmapSkPictureContentLayerUpdater*, scoped_ptr<PrioritizedResource>); - virtual void update(ResourceUpdateQueue&, const gfx::Rect& sourceRect, const gfx::Vector2d& destOffset, bool partialUpdate, RenderingStats&) OVERRIDE; + virtual void update(ResourceUpdateQueue&, const gfx::Rect& sourceRect, const gfx::Vector2d& destOffset, bool partialUpdate, RenderingStats*) OVERRIDE; private: BitmapSkPictureContentLayerUpdater* updater() { return m_updater; } @@ -30,7 +30,7 @@ public: static scoped_refptr<BitmapSkPictureContentLayerUpdater> create(scoped_ptr<LayerPainter>); virtual scoped_ptr<LayerUpdater::Resource> createResource(PrioritizedResourceManager*) OVERRIDE; - void paintContentsRect(SkCanvas*, const gfx::Rect& sourceRect, RenderingStats&); + void paintContentsRect(SkCanvas*, const gfx::Rect& sourceRect, RenderingStats*); private: explicit BitmapSkPictureContentLayerUpdater(scoped_ptr<LayerPainter>); diff --git a/cc/caching_bitmap_content_layer_updater.cc b/cc/caching_bitmap_content_layer_updater.cc index 18e9768..83280bc 100644 --- a/cc/caching_bitmap_content_layer_updater.cc +++ b/cc/caching_bitmap_content_layer_updater.cc @@ -34,7 +34,7 @@ void CachingBitmapContentLayerUpdater::prepareToUpdate( float contents_width_scale, float contents_height_scale, gfx::Rect& resulting_opaque_rect, - RenderingStats& stats) { + RenderingStats* stats) { BitmapContentLayerUpdater::prepareToUpdate( content_rect, tile_size, diff --git a/cc/caching_bitmap_content_layer_updater.h b/cc/caching_bitmap_content_layer_updater.h index 630e2f3..79f215ce 100644 --- a/cc/caching_bitmap_content_layer_updater.h +++ b/cc/caching_bitmap_content_layer_updater.h @@ -22,7 +22,7 @@ class CachingBitmapContentLayerUpdater float contents_width_scale, float contents_height_scale, gfx::Rect& resulting_opaque_rect, - RenderingStats&) OVERRIDE; + RenderingStats*) OVERRIDE; bool pixelsDidChange() const; diff --git a/cc/content_layer.cc b/cc/content_layer.cc index 5fa5636..da7113a 100644 --- a/cc/content_layer.cc +++ b/cc/content_layer.cc @@ -66,7 +66,7 @@ void ContentLayer::setTexturePriorities(const PriorityCalculator& priorityCalc) TiledLayer::setTexturePriorities(priorityCalc); } -void ContentLayer::update(ResourceUpdateQueue& queue, const OcclusionTracker* occlusion, RenderingStats& stats) +void ContentLayer::update(ResourceUpdateQueue& queue, const OcclusionTracker* occlusion, RenderingStats* stats) { { base::AutoReset<bool> ignoreSetNeedsCommit(&m_ignoreSetNeedsCommit, true); diff --git a/cc/content_layer.h b/cc/content_layer.h index a1a2e22..be7139b 100644 --- a/cc/content_layer.h +++ b/cc/content_layer.h @@ -40,7 +40,7 @@ public: virtual bool drawsContent() const OVERRIDE; virtual void setTexturePriorities(const PriorityCalculator&) OVERRIDE; - virtual void update(ResourceUpdateQueue&, const OcclusionTracker*, RenderingStats&) OVERRIDE; + virtual void update(ResourceUpdateQueue&, const OcclusionTracker*, RenderingStats*) OVERRIDE; virtual bool needMoreUpdates() OVERRIDE; virtual void setContentsOpaque(bool) OVERRIDE; diff --git a/cc/content_layer_unittest.cc b/cc/content_layer_unittest.cc index c7f32be..5afb588 100644 --- a/cc/content_layer_unittest.cc +++ b/cc/content_layer_unittest.cc @@ -6,7 +6,6 @@ #include "cc/bitmap_content_layer_updater.h" #include "cc/content_layer_client.h" -#include "cc/rendering_stats.h" #include "cc/test/geometry_test_utils.h" #include "skia/ext/platform_canvas.h" #include "testing/gtest/include/gtest/gtest.h" @@ -43,8 +42,7 @@ TEST(ContentLayerTest, ContentLayerPainterWithDeviceScale) scoped_refptr<BitmapContentLayerUpdater> updater = BitmapContentLayerUpdater::create(ContentLayerPainter::create(&client).PassAs<LayerPainter>()); gfx::Rect resultingOpaqueRect; - RenderingStats stats; - updater->prepareToUpdate(contentRect, gfx::Size(256, 256), contentsScale, contentsScale, resultingOpaqueRect, stats); + updater->prepareToUpdate(contentRect, gfx::Size(256, 256), contentsScale, contentsScale, resultingOpaqueRect, NULL); EXPECT_RECT_EQ(gfx::ToEnclosingRect(opaqueRectInContentSpace), resultingOpaqueRect); } diff --git a/cc/content_layer_updater.cc b/cc/content_layer_updater.cc index 6e4858e..c9b7d3a 100644 --- a/cc/content_layer_updater.cc +++ b/cc/content_layer_updater.cc @@ -26,7 +26,7 @@ ContentLayerUpdater::~ContentLayerUpdater() { } -void ContentLayerUpdater::paintContents(SkCanvas* canvas, const gfx::Rect& contentRect, float contentsWidthScale, float contentsHeightScale, gfx::Rect& resultingOpaqueRect, RenderingStats& stats) +void ContentLayerUpdater::paintContents(SkCanvas* canvas, const gfx::Rect& contentRect, float contentsWidthScale, float contentsHeightScale, gfx::Rect& resultingOpaqueRect, RenderingStats* stats) { TRACE_EVENT0("cc", "ContentLayerUpdater::paintContents"); canvas->save(); @@ -49,13 +49,16 @@ void ContentLayerUpdater::paintContents(SkCanvas* canvas, const gfx::Rect& conte canvas->clipRect(layerSkRect); gfx::RectF opaqueLayerRect; - base::TimeTicks paintBeginTime = base::TimeTicks::Now(); + base::TimeTicks paintBeginTime; + if (stats) + paintBeginTime = base::TimeTicks::Now(); m_painter->paint(canvas, layerRect, opaqueLayerRect); - stats.totalPaintTime += base::TimeTicks::Now() - paintBeginTime; + if (stats) { + stats->totalPaintTime += base::TimeTicks::Now() - paintBeginTime; + stats->totalPixelsPainted += contentRect.width() * contentRect.height(); + } canvas->restore(); - stats.totalPixelsPainted += contentRect.width() * contentRect.height(); - gfx::RectF opaqueContentRect = gfx::ScaleRect(opaqueLayerRect, contentsWidthScale, contentsHeightScale); resultingOpaqueRect = gfx::ToEnclosedRect(opaqueContentRect); diff --git a/cc/content_layer_updater.h b/cc/content_layer_updater.h index a51b0e9..7924a37 100644 --- a/cc/content_layer_updater.h +++ b/cc/content_layer_updater.h @@ -23,7 +23,7 @@ protected: explicit ContentLayerUpdater(scoped_ptr<LayerPainter>); virtual ~ContentLayerUpdater(); - void paintContents(SkCanvas*, const gfx::Rect& contentRect, float contentsWidthScale, float contentsHeightScale, gfx::Rect& resultingOpaqueRect, RenderingStats&); + void paintContents(SkCanvas*, const gfx::Rect& contentRect, float contentsWidthScale, float contentsHeightScale, gfx::Rect& resultingOpaqueRect, RenderingStats*); const gfx::Rect& contentRect() const { return m_contentRect; } private: diff --git a/cc/contents_scaling_layer.cc b/cc/contents_scaling_layer.cc index a9a8bef..5d3502b 100644 --- a/cc/contents_scaling_layer.cc +++ b/cc/contents_scaling_layer.cc @@ -41,7 +41,7 @@ void ContentsScalingLayer::didUpdateBounds() { void ContentsScalingLayer::update( ResourceUpdateQueue& queue, const OcclusionTracker* occlusion, - RenderingStats& stats) { + RenderingStats* stats) { if (drawProperties().contents_scale_x == last_update_contents_scale_x_ && drawProperties().contents_scale_y == last_update_contents_scale_y_) return; diff --git a/cc/contents_scaling_layer.h b/cc/contents_scaling_layer.h index c535d04..fa5357e 100644 --- a/cc/contents_scaling_layer.h +++ b/cc/contents_scaling_layer.h @@ -24,7 +24,7 @@ class CC_EXPORT ContentsScalingLayer : public Layer { virtual void update( ResourceUpdateQueue& queue, const OcclusionTracker* occlusion, - RenderingStats& stats) OVERRIDE; + RenderingStats* stats) OVERRIDE; protected: ContentsScalingLayer(); diff --git a/cc/heads_up_display_layer.cc b/cc/heads_up_display_layer.cc index 71145b7..c3f7340 100644 --- a/cc/heads_up_display_layer.cc +++ b/cc/heads_up_display_layer.cc @@ -26,7 +26,7 @@ HeadsUpDisplayLayer::~HeadsUpDisplayLayer() { } -void HeadsUpDisplayLayer::update(ResourceUpdateQueue&, const OcclusionTracker*, RenderingStats&) +void HeadsUpDisplayLayer::update(ResourceUpdateQueue&, const OcclusionTracker*, RenderingStats*) { const LayerTreeDebugState& debugState = layerTreeHost()->debugState(); int maxTextureSize = layerTreeHost()->rendererCapabilities().maxTextureSize; diff --git a/cc/heads_up_display_layer.h b/cc/heads_up_display_layer.h index 2c97a86..0100c8e 100644 --- a/cc/heads_up_display_layer.h +++ b/cc/heads_up_display_layer.h @@ -16,7 +16,7 @@ class CC_EXPORT HeadsUpDisplayLayer : public Layer { public: static scoped_refptr<HeadsUpDisplayLayer> create(); - virtual void update(ResourceUpdateQueue&, const OcclusionTracker*, RenderingStats&) OVERRIDE; + virtual void update(ResourceUpdateQueue&, const OcclusionTracker*, RenderingStats*) OVERRIDE; virtual bool drawsContent() const OVERRIDE; void setFontAtlas(scoped_ptr<FontAtlas>); diff --git a/cc/image_layer.cc b/cc/image_layer.cc index 5ecff78..9b95968 100644 --- a/cc/image_layer.cc +++ b/cc/image_layer.cc @@ -48,7 +48,7 @@ void ImageLayer::setTexturePriorities(const PriorityCalculator& priorityCalc) TiledLayer::setTexturePriorities(priorityCalc); } -void ImageLayer::update(ResourceUpdateQueue& queue, const OcclusionTracker* occlusion, RenderingStats& stats) +void ImageLayer::update(ResourceUpdateQueue& queue, const OcclusionTracker* occlusion, RenderingStats* stats) { createUpdaterIfNeeded(); if (m_needsDisplay) { diff --git a/cc/image_layer.h b/cc/image_layer.h index 86d0dac..c3a4b90 100644 --- a/cc/image_layer.h +++ b/cc/image_layer.h @@ -20,7 +20,7 @@ public: virtual bool drawsContent() const OVERRIDE; virtual void setTexturePriorities(const PriorityCalculator&) OVERRIDE; - virtual void update(ResourceUpdateQueue&, const OcclusionTracker*, RenderingStats&) OVERRIDE; + virtual void update(ResourceUpdateQueue&, const OcclusionTracker*, RenderingStats*) OVERRIDE; virtual void calculateContentsScale( float idealContentsScale, float* contentsScaleX, diff --git a/cc/image_layer_updater.cc b/cc/image_layer_updater.cc index 9ba902e..621b1eb 100644 --- a/cc/image_layer_updater.cc +++ b/cc/image_layer_updater.cc @@ -18,7 +18,7 @@ ImageLayerUpdater::Resource::~Resource() { } -void ImageLayerUpdater::Resource::update(ResourceUpdateQueue& queue, const gfx::Rect& sourceRect, const gfx::Vector2d& destOffset, bool partialUpdate, RenderingStats&) +void ImageLayerUpdater::Resource::update(ResourceUpdateQueue& queue, const gfx::Rect& sourceRect, const gfx::Vector2d& destOffset, bool partialUpdate, RenderingStats*) { m_updater->updateTexture(queue, texture(), sourceRect, destOffset, partialUpdate); } diff --git a/cc/image_layer_updater.h b/cc/image_layer_updater.h index 938d07a..042047aa 100644 --- a/cc/image_layer_updater.h +++ b/cc/image_layer_updater.h @@ -19,7 +19,7 @@ public: Resource(ImageLayerUpdater* updater, scoped_ptr<PrioritizedResource> texture); virtual ~Resource(); - virtual void update(ResourceUpdateQueue&, const gfx::Rect& sourceRect, const gfx::Vector2d& destOffset, bool partialUpdate, RenderingStats&) OVERRIDE; + virtual void update(ResourceUpdateQueue&, const gfx::Rect& sourceRect, const gfx::Vector2d& destOffset, bool partialUpdate, RenderingStats*) OVERRIDE; private: ImageLayerUpdater* m_updater; @@ -209,7 +209,7 @@ public: // These methods typically need to be overwritten by derived classes. virtual bool drawsContent() const; - virtual void update(ResourceUpdateQueue&, const OcclusionTracker*, RenderingStats&) { } + virtual void update(ResourceUpdateQueue&, const OcclusionTracker*, RenderingStats*) { } virtual bool needMoreUpdates(); virtual void setIsMask(bool) { } diff --git a/cc/layer_tree_host.cc b/cc/layer_tree_host.cc index 1b54271..74d3cae 100644 --- a/cc/layer_tree_host.cc +++ b/cc/layer_tree_host.cc @@ -405,6 +405,7 @@ void LayerTreeHost::didDeferCommit() void LayerTreeHost::renderingStats(RenderingStats* stats) const { + CHECK(m_settings.recordRenderingStats); *stats = m_renderingStats; m_proxy->renderingStats(stats); } @@ -695,16 +696,18 @@ bool LayerTreeHost::paintMasksForRenderSurface(Layer* renderSurfaceLayer, Resour // in code, we already know that at least something will be drawn into this render surface, so the // mask and replica should be painted. + RenderingStats* stats = m_settings.recordRenderingStats ? &m_renderingStats : NULL; + bool needMoreUpdates = false; Layer* maskLayer = renderSurfaceLayer->maskLayer(); if (maskLayer) { - maskLayer->update(queue, 0, m_renderingStats); + maskLayer->update(queue, 0, stats); needMoreUpdates |= maskLayer->needMoreUpdates(); } Layer* replicaMaskLayer = renderSurfaceLayer->replicaLayer() ? renderSurfaceLayer->replicaLayer()->maskLayer() : 0; if (replicaMaskLayer) { - replicaMaskLayer->update(queue, 0, m_renderingStats); + replicaMaskLayer->update(queue, 0, stats); needMoreUpdates |= replicaMaskLayer->needMoreUpdates(); } return needMoreUpdates; @@ -722,6 +725,8 @@ bool LayerTreeHost::paintLayerContents(const LayerList& renderSurfaceLayerList, prioritizeTextures(renderSurfaceLayerList, occlusionTracker.overdrawMetrics()); + RenderingStats* stats = m_settings.recordRenderingStats ? &m_renderingStats : NULL; + LayerIteratorType end = LayerIteratorType::end(&renderSurfaceLayerList); for (LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList); it != end; ++it) { occlusionTracker.enterLayer(it); @@ -731,7 +736,7 @@ bool LayerTreeHost::paintLayerContents(const LayerList& renderSurfaceLayerList, needMoreUpdates |= paintMasksForRenderSurface(*it, queue); } else if (it.representsItself()) { DCHECK(!it->bounds().IsEmpty()); - it->update(queue, &occlusionTracker, m_renderingStats); + it->update(queue, &occlusionTracker, stats); needMoreUpdates |= it->needMoreUpdates(); } diff --git a/cc/layer_tree_host_impl.cc b/cc/layer_tree_host_impl.cc index e846f1d..f9401fb 100644 --- a/cc/layer_tree_host_impl.cc +++ b/cc/layer_tree_host_impl.cc @@ -1050,7 +1050,7 @@ bool LayerTreeHostImpl::initializeRenderer(scoped_ptr<OutputSurface> outputSurfa return false; if (m_settings.implSidePainting) - m_tileManager.reset(new TileManager(this, resourceProvider.get(), m_settings.numRasterThreads)); + m_tileManager.reset(new TileManager(this, resourceProvider.get(), m_settings.numRasterThreads, m_settings.recordRenderingStats)); if (outputSurface->Capabilities().has_parent_compositor) m_renderer = DelegatingRenderer::Create(this, outputSurface.get(), resourceProvider.get()); diff --git a/cc/layer_tree_host_unittest.cc b/cc/layer_tree_host_unittest.cc index bcad5b69..7cb46ba 100644 --- a/cc/layer_tree_host_unittest.cc +++ b/cc/layer_tree_host_unittest.cc @@ -795,7 +795,7 @@ public: int paintContentsCount() { return m_paintContentsCount; } void resetPaintContentsCount() { m_paintContentsCount = 0; } - virtual void update(ResourceUpdateQueue& queue, const OcclusionTracker* occlusion, RenderingStats& stats) OVERRIDE + virtual void update(ResourceUpdateQueue& queue, const OcclusionTracker* occlusion, RenderingStats* stats) OVERRIDE { ContentLayer::update(queue, occlusion, stats); m_paintContentsCount++; @@ -1477,7 +1477,7 @@ class EvictionTestLayer : public Layer { public: static scoped_refptr<EvictionTestLayer> create() { return make_scoped_refptr(new EvictionTestLayer()); } - virtual void update(ResourceUpdateQueue&, const OcclusionTracker*, RenderingStats&) OVERRIDE; + virtual void update(ResourceUpdateQueue&, const OcclusionTracker*, RenderingStats*) OVERRIDE; virtual bool drawsContent() const OVERRIDE { return true; } virtual scoped_ptr<LayerImpl> createLayerImpl(LayerTreeImpl* treeImpl) OVERRIDE; @@ -1535,7 +1535,7 @@ void EvictionTestLayer::setTexturePriorities(const PriorityCalculator&) m_texture->setRequestPriority(PriorityCalculator::uiPriority(true)); } -void EvictionTestLayer::update(ResourceUpdateQueue& queue, const OcclusionTracker*, RenderingStats&) +void EvictionTestLayer::update(ResourceUpdateQueue& queue, const OcclusionTracker*, RenderingStats*) { createTextureIfNeeded(); if (!m_texture.get()) diff --git a/cc/layer_tree_host_unittest_occlusion.cc b/cc/layer_tree_host_unittest_occlusion.cc index 5514186..20434f6 100644 --- a/cc/layer_tree_host_unittest_occlusion.cc +++ b/cc/layer_tree_host_unittest_occlusion.cc @@ -20,7 +20,7 @@ class TestLayer : public Layer { virtual void update( ResourceUpdateQueue& update_queue, const OcclusionTracker* occlusion, - RenderingStats& stats) OVERRIDE { + RenderingStats* stats) OVERRIDE { if (!occlusion) return; diff --git a/cc/layer_tree_settings.cc b/cc/layer_tree_settings.cc index 601836b..03ba96a 100644 --- a/cc/layer_tree_settings.cc +++ b/cc/layer_tree_settings.cc @@ -29,6 +29,7 @@ LayerTreeSettings::LayerTreeSettings() , shouldClearRootRenderPass(true) , useLinearFadeScrollbarAnimator(false) , calculateTopControlsPosition(false) + , recordRenderingStats(false) , minimumContentsScale(0.0625f) , lowResContentsScaleFactor(0.125f) , topControlsHeight(0.f) diff --git a/cc/layer_tree_settings.h b/cc/layer_tree_settings.h index dc086fe..b35fd29 100644 --- a/cc/layer_tree_settings.h +++ b/cc/layer_tree_settings.h @@ -32,6 +32,7 @@ class CC_EXPORT LayerTreeSettings { bool shouldClearRootRenderPass; bool useLinearFadeScrollbarAnimator; bool calculateTopControlsPosition; + bool recordRenderingStats; float minimumContentsScale; float lowResContentsScaleFactor; float topControlsHeight; diff --git a/cc/layer_updater.h b/cc/layer_updater.h index 5ee4a2c..ee2287e 100644 --- a/cc/layer_updater.h +++ b/cc/layer_updater.h @@ -34,7 +34,7 @@ public: void swapTextureWith(scoped_ptr<PrioritizedResource>& texture); // TODO(reveman): partialUpdate should be a property of this class // instead of an argument passed to update(). - virtual void update(ResourceUpdateQueue&, const gfx::Rect& sourceRect, const gfx::Vector2d& destOffset, bool partialUpdate, RenderingStats&) = 0; + virtual void update(ResourceUpdateQueue&, const gfx::Rect& sourceRect, const gfx::Vector2d& destOffset, bool partialUpdate, RenderingStats*) = 0; protected: explicit Resource(scoped_ptr<PrioritizedResource> texture); @@ -49,7 +49,7 @@ public: virtual scoped_ptr<Resource> createResource(PrioritizedResourceManager*) = 0; // The |resultingOpaqueRect| gives back a region of the layer that was painted opaque. If the layer is marked opaque in the updater, // then this region should be ignored in preference for the entire layer's area. - virtual void prepareToUpdate(const gfx::Rect& contentRect, const gfx::Size& tileSize, float contentsWidthScale, float contentsHeightScale, gfx::Rect& resultingOpaqueRect, RenderingStats&) { } + virtual void prepareToUpdate(const gfx::Rect& contentRect, const gfx::Size& tileSize, float contentsWidthScale, float contentsHeightScale, gfx::Rect& resultingOpaqueRect, RenderingStats*) { } // Set true by the layer when it is known that the entire output is going to be opaque. virtual void setOpaque(bool) { } diff --git a/cc/nine_patch_layer.cc b/cc/nine_patch_layer.cc index 54f50f3..56ae43c 100644 --- a/cc/nine_patch_layer.cc +++ b/cc/nine_patch_layer.cc @@ -57,7 +57,7 @@ void NinePatchLayer::setBitmap(const SkBitmap& bitmap, const gfx::Rect& aperture setNeedsDisplay(); } -void NinePatchLayer::update(ResourceUpdateQueue& queue, const OcclusionTracker* occlusion, RenderingStats& stats) +void NinePatchLayer::update(ResourceUpdateQueue& queue, const OcclusionTracker* occlusion, RenderingStats* stats) { createUpdaterIfNeeded(); diff --git a/cc/nine_patch_layer.h b/cc/nine_patch_layer.h index d852d8e..65b9082 100644 --- a/cc/nine_patch_layer.h +++ b/cc/nine_patch_layer.h @@ -22,7 +22,7 @@ public: virtual bool drawsContent() const OVERRIDE; virtual void setTexturePriorities(const PriorityCalculator&) OVERRIDE; - virtual void update(ResourceUpdateQueue&, const OcclusionTracker*, RenderingStats&) OVERRIDE; + virtual void update(ResourceUpdateQueue&, const OcclusionTracker*, RenderingStats*) OVERRIDE; virtual void pushPropertiesTo(LayerImpl*) OVERRIDE; // aperture is in the pixel space of the bitmap resource and refers to diff --git a/cc/nine_patch_layer_unittest.cc b/cc/nine_patch_layer_unittest.cc index b1738dd..b7a5bb9 100644 --- a/cc/nine_patch_layer_unittest.cc +++ b/cc/nine_patch_layer_unittest.cc @@ -8,7 +8,6 @@ #include "cc/occlusion_tracker.h" #include "cc/overdraw_metrics.h" #include "cc/prioritized_resource_manager.h" -#include "cc/rendering_stats.h" #include "cc/resource_provider.h" #include "cc/resource_update_queue.h" #include "cc/single_thread_proxy.h" @@ -80,11 +79,10 @@ TEST_F(NinePatchLayerTest, triggerFullUploadOnceWhenChangingBitmap) PriorityCalculator calculator; ResourceUpdateQueue queue; OcclusionTracker occlusionTracker(gfx::Rect(), false); - RenderingStats stats; // No bitmap set should not trigger any uploads. testLayer->setTexturePriorities(calculator); - testLayer->update(queue, &occlusionTracker, stats); + testLayer->update(queue, &occlusionTracker, NULL); EXPECT_EQ(queue.fullUploadSize(), 0); EXPECT_EQ(queue.partialUploadSize(), 0); @@ -94,7 +92,7 @@ TEST_F(NinePatchLayerTest, triggerFullUploadOnceWhenChangingBitmap) bitmap.allocPixels(); testLayer->setBitmap(bitmap, gfx::Rect(5, 5, 1, 1)); testLayer->setTexturePriorities(calculator); - testLayer->update(queue, &occlusionTracker, stats); + testLayer->update(queue, &occlusionTracker, NULL); EXPECT_EQ(queue.fullUploadSize(), 1); EXPECT_EQ(queue.partialUploadSize(), 0); ResourceUpdate params = queue.takeFirstFullUpload(); @@ -117,7 +115,7 @@ TEST_F(NinePatchLayerTest, triggerFullUploadOnceWhenChangingBitmap) // Nothing changed, so no repeated upload. testLayer->setTexturePriorities(calculator); - testLayer->update(queue, &occlusionTracker, stats); + testLayer->update(queue, &occlusionTracker, NULL); EXPECT_EQ(queue.fullUploadSize(), 0); EXPECT_EQ(queue.partialUploadSize(), 0); @@ -129,7 +127,7 @@ TEST_F(NinePatchLayerTest, triggerFullUploadOnceWhenChangingBitmap) // Reupload after eviction testLayer->setTexturePriorities(calculator); - testLayer->update(queue, &occlusionTracker, stats); + testLayer->update(queue, &occlusionTracker, NULL); EXPECT_EQ(queue.fullUploadSize(), 1); EXPECT_EQ(queue.partialUploadSize(), 0); @@ -138,7 +136,7 @@ TEST_F(NinePatchLayerTest, triggerFullUploadOnceWhenChangingBitmap) EXPECT_EQ(NULL, params.texture->resourceManager()); testLayer->setTexturePriorities(calculator); ResourceUpdateQueue queue2; - testLayer->update(queue2, &occlusionTracker, stats); + testLayer->update(queue2, &occlusionTracker, NULL); EXPECT_EQ(queue2.fullUploadSize(), 1); EXPECT_EQ(queue2.partialUploadSize(), 0); params = queue2.takeFirstFullUpload(); diff --git a/cc/picture.cc b/cc/picture.cc index 1407f55..c8fcd45 100644 --- a/cc/picture.cc +++ b/cc/picture.cc @@ -50,7 +50,7 @@ scoped_refptr<Picture> Picture::Clone() const { } void Picture::Record(ContentLayerClient* painter, - RenderingStats& stats) { + RenderingStats* stats) { TRACE_EVENT2("cc", "Picture::Record", "width", layer_rect_.width(), "height", layer_rect_.height()); @@ -80,11 +80,15 @@ void Picture::Record(ContentLayerClient* painter, canvas->drawRect(layer_skrect, paint); gfx::RectF opaque_layer_rect; - base::TimeTicks beginPaintTime = base::TimeTicks::Now(); + base::TimeTicks begin_paint_time; + if (stats) + begin_paint_time = base::TimeTicks::Now(); painter->paintContents(canvas, layer_rect_, opaque_layer_rect); - stats.totalPaintTime += base::TimeTicks::Now() - beginPaintTime; - stats.totalPixelsPainted += layer_rect_.width() * - layer_rect_.height(); + if (stats) { + stats->totalPaintTime += base::TimeTicks::Now() - begin_paint_time; + stats->totalPixelsPainted += + layer_rect_.width() * layer_rect_.height(); + } canvas->restore(); picture_->endRecording(); diff --git a/cc/picture.h b/cc/picture.h index f64c6e8..44abb9a 100644 --- a/cc/picture.h +++ b/cc/picture.h @@ -34,7 +34,7 @@ class CC_EXPORT Picture // Record a paint operation. To be able to safely use this SkPicture for // playback on a different thread this can only be called once. - void Record(ContentLayerClient*, RenderingStats&); + void Record(ContentLayerClient*, RenderingStats*); // Has Record() been called yet? bool HasRecording() const { return picture_.get() != NULL; } diff --git a/cc/picture_image_layer.cc b/cc/picture_image_layer.cc index b87c6e6..1486446 100644 --- a/cc/picture_image_layer.cc +++ b/cc/picture_image_layer.cc @@ -39,7 +39,7 @@ void PictureImageLayer::setBitmap(const SkBitmap& bitmap) void PictureImageLayer::update( ResourceUpdateQueue& queue, const OcclusionTracker* tracker, - RenderingStats& stats) { + RenderingStats* stats) { if (bounds() != bounds_) { // Pictures are recorded in layer space, so if the layer size changes, // then the picture needs to be re-scaled, as a directly composited image diff --git a/cc/picture_image_layer.h b/cc/picture_image_layer.h index 179102d..442f687 100644 --- a/cc/picture_image_layer.h +++ b/cc/picture_image_layer.h @@ -23,7 +23,7 @@ class CC_EXPORT PictureImageLayer : public PictureLayer, ContentLayerClient { virtual void update( ResourceUpdateQueue& queue, const OcclusionTracker* tracker, - RenderingStats& stats) OVERRIDE; + RenderingStats* stats) OVERRIDE; // ContentLayerClient implementation. virtual void paintContents( diff --git a/cc/picture_layer.cc b/cc/picture_layer.cc index 0845af8..b9ce65a 100644 --- a/cc/picture_layer.cc +++ b/cc/picture_layer.cc @@ -61,7 +61,7 @@ void PictureLayer::setNeedsDisplayRect(const gfx::RectF& layer_rect) { } void PictureLayer::update(ResourceUpdateQueue&, const OcclusionTracker*, - RenderingStats& stats) { + RenderingStats* stats) { // Do not early-out of this function so that PicturePile::Update has a chance // to record pictures due to changing visibility of this layer. diff --git a/cc/picture_layer.h b/cc/picture_layer.h index 731b90b..a0739d9 100644 --- a/cc/picture_layer.h +++ b/cc/picture_layer.h @@ -32,7 +32,7 @@ class CC_EXPORT PictureLayer : public ContentsScalingLayer { virtual void update( ResourceUpdateQueue& queue, const OcclusionTracker* occlusion, - RenderingStats& stats) OVERRIDE; + RenderingStats* stats) OVERRIDE; virtual void setIsMask(bool is_mask) OVERRIDE; protected: diff --git a/cc/picture_layer_impl_unittest.cc b/cc/picture_layer_impl_unittest.cc index 56fc0e8..18a4ff7 100644 --- a/cc/picture_layer_impl_unittest.cc +++ b/cc/picture_layer_impl_unittest.cc @@ -81,8 +81,7 @@ class TestablePicturePileImpl : public PicturePileImpl { gfx::Rect bounds(tiling().TileBounds(x, y)); scoped_refptr<Picture> picture(Picture::Create(bounds)); FakeContentLayerClient client; - RenderingStats stats; - picture->Record(&client, stats); + picture->Record(&client, NULL); picture_list_map_[std::pair<int, int>(x, y)].push_back(picture); EXPECT_TRUE(HasRecordingAt(x, y)); } diff --git a/cc/picture_pile.cc b/cc/picture_pile.cc index e52498a..1db3f4b 100644 --- a/cc/picture_pile.cc +++ b/cc/picture_pile.cc @@ -33,7 +33,7 @@ void PicturePile::Update( ContentLayerClient* painter, const Region& invalidation, gfx::Rect visible_layer_rect, - RenderingStats& stats) { + RenderingStats* stats) { gfx::Rect interest_rect = visible_layer_rect; interest_rect.Inset( -kPixelDistanceToRecord, diff --git a/cc/picture_pile.h b/cc/picture_pile.h index e5818ce..a6271fa 100644 --- a/cc/picture_pile.h +++ b/cc/picture_pile.h @@ -23,7 +23,7 @@ class CC_EXPORT PicturePile : public PicturePileBase { ContentLayerClient* painter, const Region& invalidation, gfx::Rect visible_layer_rect, - RenderingStats& stats); + RenderingStats* stats); // Update other with a shallow copy of this (main => compositor thread commit) void PushPropertiesTo(PicturePileImpl* other); diff --git a/cc/picture_pile_impl.cc b/cc/picture_pile_impl.cc index 02fabb5..233d524 100644 --- a/cc/picture_pile_impl.cc +++ b/cc/picture_pile_impl.cc @@ -65,7 +65,9 @@ void PicturePileImpl::Raster( DCHECK(contents_scale >= min_contents_scale_); - base::TimeTicks rasterizeBeginTime = base::TimeTicks::Now(); + base::TimeTicks rasterize_begin_time; + if (stats) + rasterize_begin_time = base::TimeTicks::Now(); canvas->save(); canvas->translate(-content_rect.x(), -content_rect.y()); @@ -112,13 +114,15 @@ void PicturePileImpl::Raster( SkRegion::kDifference_Op); unclipped.Subtract(content_clip); - stats->totalPixelsRasterized += - content_clip.width() * content_clip.height(); + if (stats) + stats->totalPixelsRasterized += + content_clip.width() * content_clip.height(); } } canvas->restore(); - stats->totalRasterizeTime += base::TimeTicks::Now() - rasterizeBeginTime; + if (stats) + stats->totalRasterizeTime += base::TimeTicks::Now() - rasterize_begin_time; } void PicturePileImpl::GatherPixelRefs( diff --git a/cc/raster_worker_pool.cc b/cc/raster_worker_pool.cc index c7b88e9..d461d8c 100644 --- a/cc/raster_worker_pool.cc +++ b/cc/raster_worker_pool.cc @@ -21,8 +21,8 @@ class RasterWorkerPoolTaskImpl : public internal::WorkerPoolTask { DCHECK(picture_pile_); } - virtual void Run() OVERRIDE { - task_.Run(picture_pile_.get(), &rendering_stats_); + virtual void Run(RenderingStats* rendering_stats) OVERRIDE { + task_.Run(picture_pile_.get(), rendering_stats); } private: @@ -32,8 +32,9 @@ class RasterWorkerPoolTaskImpl : public internal::WorkerPoolTask { } // namespace -RasterWorkerPool::RasterWorkerPool(size_t num_threads) - : WorkerPool(num_threads) { +RasterWorkerPool::RasterWorkerPool( + size_t num_threads, bool record_rendering_stats) + : WorkerPool(num_threads, record_rendering_stats) { } RasterWorkerPool::~RasterWorkerPool() { diff --git a/cc/raster_worker_pool.h b/cc/raster_worker_pool.h index d58df2d..535c818 100644 --- a/cc/raster_worker_pool.h +++ b/cc/raster_worker_pool.h @@ -20,8 +20,10 @@ class RasterWorkerPool : public WorkerPool { virtual ~RasterWorkerPool(); - static scoped_ptr<RasterWorkerPool> Create(size_t num_threads) { - return make_scoped_ptr(new RasterWorkerPool(num_threads)); + static scoped_ptr<RasterWorkerPool> Create( + size_t num_threads, bool record_rendering_stats) { + return make_scoped_ptr( + new RasterWorkerPool(num_threads, record_rendering_stats)); } void PostRasterTaskAndReply(PicturePileImpl* picture_pile, @@ -29,7 +31,7 @@ class RasterWorkerPool : public WorkerPool { const base::Closure& reply); private: - explicit RasterWorkerPool(size_t num_threads); + RasterWorkerPool(size_t num_threads, bool record_rendering_stats); DISALLOW_COPY_AND_ASSIGN(RasterWorkerPool); }; diff --git a/cc/scrollbar_layer.cc b/cc/scrollbar_layer.cc index 2b2ec21..c3e1640 100644 --- a/cc/scrollbar_layer.cc +++ b/cc/scrollbar_layer.cc @@ -248,7 +248,7 @@ void ScrollbarLayer::createUpdaterIfNeeded() m_thumb = m_thumbUpdater->createResource(layerTreeHost()->contentsTextureManager()); } -void ScrollbarLayer::updatePart(CachingBitmapContentLayerUpdater* painter, LayerUpdater::Resource* resource, const gfx::Rect& rect, ResourceUpdateQueue& queue, RenderingStats& stats) +void ScrollbarLayer::updatePart(CachingBitmapContentLayerUpdater* painter, LayerUpdater::Resource* resource, const gfx::Rect& rect, ResourceUpdateQueue& queue, RenderingStats* stats) { // Skip painting and uploading if there are no invalidations and // we already have valid texture data. @@ -311,7 +311,7 @@ void ScrollbarLayer::setTexturePriorities(const PriorityCalculator&) } } -void ScrollbarLayer::update(ResourceUpdateQueue& queue, const OcclusionTracker* occlusion, RenderingStats& stats) +void ScrollbarLayer::update(ResourceUpdateQueue& queue, const OcclusionTracker* occlusion, RenderingStats* stats) { ContentsScalingLayer::update(queue, occlusion, stats); diff --git a/cc/scrollbar_layer.h b/cc/scrollbar_layer.h index 30f4d2d..2d0c1a8 100644 --- a/cc/scrollbar_layer.h +++ b/cc/scrollbar_layer.h @@ -36,7 +36,7 @@ public: // Layer interface virtual void setTexturePriorities(const PriorityCalculator&) OVERRIDE; - virtual void update(ResourceUpdateQueue&, const OcclusionTracker*, RenderingStats&) OVERRIDE; + virtual void update(ResourceUpdateQueue&, const OcclusionTracker*, RenderingStats*) OVERRIDE; virtual void setLayerTreeHost(LayerTreeHost*) OVERRIDE; virtual void pushPropertiesTo(LayerImpl*) OVERRIDE; virtual void calculateContentsScale( @@ -56,7 +56,7 @@ protected: virtual ~ScrollbarLayer(); private: - void updatePart(CachingBitmapContentLayerUpdater*, LayerUpdater::Resource*, const gfx::Rect&, ResourceUpdateQueue&, RenderingStats&); + void updatePart(CachingBitmapContentLayerUpdater*, LayerUpdater::Resource*, const gfx::Rect&, ResourceUpdateQueue&, RenderingStats*); void createUpdaterIfNeeded(); gfx::Rect scrollbarLayerRectToContentRect(const gfx::Rect& layerRect) const; diff --git a/cc/skpicture_content_layer_updater.cc b/cc/skpicture_content_layer_updater.cc index 86a08a2..819e03f 100644 --- a/cc/skpicture_content_layer_updater.cc +++ b/cc/skpicture_content_layer_updater.cc @@ -22,7 +22,7 @@ SkPictureContentLayerUpdater::Resource::~Resource() { } -void SkPictureContentLayerUpdater::Resource::update(ResourceUpdateQueue& queue, const gfx::Rect& sourceRect, const gfx::Vector2d& destOffset, bool partialUpdate, RenderingStats&) +void SkPictureContentLayerUpdater::Resource::update(ResourceUpdateQueue& queue, const gfx::Rect& sourceRect, const gfx::Vector2d& destOffset, bool partialUpdate, RenderingStats*) { updater()->updateTexture(queue, texture(), sourceRect, destOffset, partialUpdate); } @@ -47,7 +47,7 @@ scoped_ptr<LayerUpdater::Resource> SkPictureContentLayerUpdater::createResource( return scoped_ptr<LayerUpdater::Resource>(new Resource(this, PrioritizedResource::create(manager))); } -void SkPictureContentLayerUpdater::prepareToUpdate(const gfx::Rect& contentRect, const gfx::Size&, float contentsWidthScale, float contentsHeightScale, gfx::Rect& resultingOpaqueRect, RenderingStats& stats) +void SkPictureContentLayerUpdater::prepareToUpdate(const gfx::Rect& contentRect, const gfx::Size&, float contentsWidthScale, float contentsHeightScale, gfx::Rect& resultingOpaqueRect, RenderingStats* stats) { SkCanvas* canvas = m_picture.beginRecording(contentRect.width(), contentRect.height()); paintContents(canvas, contentRect, contentsWidthScale, contentsHeightScale, resultingOpaqueRect, stats); diff --git a/cc/skpicture_content_layer_updater.h b/cc/skpicture_content_layer_updater.h index cc2d86c..840eba6 100644 --- a/cc/skpicture_content_layer_updater.h +++ b/cc/skpicture_content_layer_updater.h @@ -27,7 +27,7 @@ public: Resource(SkPictureContentLayerUpdater*, scoped_ptr<PrioritizedResource>); virtual ~Resource(); - virtual void update(ResourceUpdateQueue&, const gfx::Rect& sourceRect, const gfx::Vector2d& destOffset, bool partialUpdate, RenderingStats&) OVERRIDE; + virtual void update(ResourceUpdateQueue&, const gfx::Rect& sourceRect, const gfx::Vector2d& destOffset, bool partialUpdate, RenderingStats*) OVERRIDE; private: SkPictureContentLayerUpdater* updater() { return m_updater; } @@ -44,7 +44,7 @@ protected: explicit SkPictureContentLayerUpdater(scoped_ptr<LayerPainter>); virtual ~SkPictureContentLayerUpdater(); - virtual void prepareToUpdate(const gfx::Rect& contentRect, const gfx::Size& tileSize, float contentsWidthScale, float contentsHeightScale, gfx::Rect& resultingOpaqueRect, RenderingStats&) OVERRIDE; + virtual void prepareToUpdate(const gfx::Rect& contentRect, const gfx::Size& tileSize, float contentsWidthScale, float contentsHeightScale, gfx::Rect& resultingOpaqueRect, RenderingStats*) OVERRIDE; void drawPicture(SkCanvas*); void updateTexture(ResourceUpdateQueue& queue, PrioritizedResource* texture, const gfx::Rect& sourceRect, const gfx::Vector2d& destOffset, bool partialUpdate); diff --git a/cc/test/fake_content_layer.cc b/cc/test/fake_content_layer.cc index c103b24..ca1d859 100644 --- a/cc/test/fake_content_layer.cc +++ b/cc/test/fake_content_layer.cc @@ -27,7 +27,7 @@ scoped_ptr<LayerImpl> FakeContentLayer::createLayerImpl( void FakeContentLayer::update( ResourceUpdateQueue& queue, const OcclusionTracker* occlusion, - RenderingStats& stats) { + RenderingStats* stats) { ContentLayer::update(queue, occlusion, stats); update_count_++; } diff --git a/cc/test/fake_content_layer.h b/cc/test/fake_content_layer.h index 94b1266..96dc695 100644 --- a/cc/test/fake_content_layer.h +++ b/cc/test/fake_content_layer.h @@ -25,7 +25,7 @@ class FakeContentLayer : public ContentLayer { virtual void update( ResourceUpdateQueue& queue, const OcclusionTracker* occlusion, - RenderingStats& stats) OVERRIDE; + RenderingStats* stats) OVERRIDE; bool HaveBackingAt(int i, int j); diff --git a/cc/test/fake_picture_layer_tiling_client.cc b/cc/test/fake_picture_layer_tiling_client.cc index 4e2ee00..689d50e 100644 --- a/cc/test/fake_picture_layer_tiling_client.cc +++ b/cc/test/fake_picture_layer_tiling_client.cc @@ -7,7 +7,7 @@ namespace cc { FakePictureLayerTilingClient::FakePictureLayerTilingClient() - : tile_manager_(&tile_manager_client_, NULL, 1), + : tile_manager_(&tile_manager_client_, NULL, 1, false), pile_(PicturePileImpl::Create()) { } diff --git a/cc/test/fake_scrollbar_layer.cc b/cc/test/fake_scrollbar_layer.cc index 96c9daf..eb4c38d 100644 --- a/cc/test/fake_scrollbar_layer.cc +++ b/cc/test/fake_scrollbar_layer.cc @@ -33,7 +33,7 @@ FakeScrollbarLayer::~FakeScrollbarLayer() {} void FakeScrollbarLayer::update( ResourceUpdateQueue& queue, const OcclusionTracker* occlusion, - RenderingStats& stats) { + RenderingStats* stats) { size_t full = queue.fullUploadSize(); size_t partial = queue.partialUploadSize(); ScrollbarLayer::update(queue, occlusion, stats); diff --git a/cc/test/fake_scrollbar_layer.h b/cc/test/fake_scrollbar_layer.h index 222a022..c6f4520 100644 --- a/cc/test/fake_scrollbar_layer.h +++ b/cc/test/fake_scrollbar_layer.h @@ -30,7 +30,7 @@ public: virtual void update( ResourceUpdateQueue& queue, const OcclusionTracker* occlusion, - RenderingStats& stats) OVERRIDE; + RenderingStats* stats) OVERRIDE; private: FakeScrollbarLayer( diff --git a/cc/test/tiled_layer_test_common.cc b/cc/test/tiled_layer_test_common.cc index 2caba80..d78facb 100644 --- a/cc/test/tiled_layer_test_common.cc +++ b/cc/test/tiled_layer_test_common.cc @@ -27,7 +27,7 @@ FakeLayerUpdater::Resource::~Resource() { } -void FakeLayerUpdater::Resource::update(ResourceUpdateQueue& queue, const gfx::Rect&, const gfx::Vector2d&, bool partialUpdate, RenderingStats&) +void FakeLayerUpdater::Resource::update(ResourceUpdateQueue& queue, const gfx::Rect&, const gfx::Vector2d&, bool partialUpdate, RenderingStats*) { const gfx::Rect rect(0, 0, 10, 10); ResourceUpdate upload = ResourceUpdate::Create( @@ -50,7 +50,7 @@ FakeLayerUpdater::~FakeLayerUpdater() { } -void FakeLayerUpdater::prepareToUpdate(const gfx::Rect& contentRect, const gfx::Size&, float, float, gfx::Rect& resultingOpaqueRect, RenderingStats&) +void FakeLayerUpdater::prepareToUpdate(const gfx::Rect& contentRect, const gfx::Size&, float, float, gfx::Rect& resultingOpaqueRect, RenderingStats*) { m_prepareCount++; m_lastUpdateRect = contentRect; diff --git a/cc/test/tiled_layer_test_common.h b/cc/test/tiled_layer_test_common.h index 78d661d..954e8cf 100644 --- a/cc/test/tiled_layer_test_common.h +++ b/cc/test/tiled_layer_test_common.h @@ -28,7 +28,7 @@ public: Resource(FakeLayerUpdater*, scoped_ptr<cc::PrioritizedResource>); virtual ~Resource(); - virtual void update(cc::ResourceUpdateQueue&, const gfx::Rect&, const gfx::Vector2d&, bool, cc::RenderingStats&) OVERRIDE; + virtual void update(cc::ResourceUpdateQueue&, const gfx::Rect&, const gfx::Vector2d&, bool, cc::RenderingStats*) OVERRIDE; private: FakeLayerUpdater* m_layer; @@ -39,7 +39,7 @@ public: virtual scoped_ptr<cc::LayerUpdater::Resource> createResource(cc::PrioritizedResourceManager*) OVERRIDE; - virtual void prepareToUpdate(const gfx::Rect& contentRect, const gfx::Size&, float, float, gfx::Rect& resultingOpaqueRect, cc::RenderingStats&) OVERRIDE; + virtual void prepareToUpdate(const gfx::Rect& contentRect, const gfx::Size&, float, float, gfx::Rect& resultingOpaqueRect, cc::RenderingStats*) OVERRIDE; // Sets the rect to invalidate during the next call to prepareToUpdate(). After the next // call to prepareToUpdate() the rect is reset. void setRectToInvalidate(const gfx::Rect&, FakeTiledLayer*); diff --git a/cc/texture_layer.cc b/cc/texture_layer.cc index 32a9fad..8eb4ae4 100644 --- a/cc/texture_layer.cc +++ b/cc/texture_layer.cc @@ -162,7 +162,7 @@ bool TextureLayer::drawsContent() const return (m_client || m_textureId || !m_textureMailbox.IsEmpty()) && !m_contextLost && Layer::drawsContent(); } -void TextureLayer::update(ResourceUpdateQueue& queue, const OcclusionTracker*, RenderingStats&) +void TextureLayer::update(ResourceUpdateQueue& queue, const OcclusionTracker*, RenderingStats*) { if (m_client) { m_textureId = m_client->prepareTexture(queue); diff --git a/cc/texture_layer.h b/cc/texture_layer.h index f6b17fe..4e0dc03 100644 --- a/cc/texture_layer.h +++ b/cc/texture_layer.h @@ -64,7 +64,7 @@ public: virtual void setLayerTreeHost(LayerTreeHost*) OVERRIDE; virtual bool drawsContent() const OVERRIDE; - virtual void update(ResourceUpdateQueue&, const OcclusionTracker*, RenderingStats&) OVERRIDE; + virtual void update(ResourceUpdateQueue&, const OcclusionTracker*, RenderingStats*) OVERRIDE; virtual void pushPropertiesTo(LayerImpl*) OVERRIDE; virtual bool blocksPendingCommit() const OVERRIDE; diff --git a/cc/tile_manager.cc b/cc/tile_manager.cc index 612e39d..6c60aec 100644 --- a/cc/tile_manager.cc +++ b/cc/tile_manager.cc @@ -114,14 +114,16 @@ ManagedTileState::~ManagedTileState() { TileManager::TileManager( TileManagerClient* client, ResourceProvider* resource_provider, - size_t num_raster_threads) + size_t num_raster_threads, + bool record_rendering_stats) : client_(client), resource_pool_(ResourcePool::Create(resource_provider)), - raster_worker_pool_(RasterWorkerPool::Create(num_raster_threads)), + raster_worker_pool_(RasterWorkerPool::Create(num_raster_threads, record_rendering_stats)), manage_tiles_pending_(false), manage_tiles_call_count_(0), bytes_pending_set_pixels_(0), - ever_exceeded_memory_budget_(false) { + ever_exceeded_memory_budget_(false), + record_rendering_stats_(record_rendering_stats) { for (int i = 0; i < NUM_STATES; ++i) { for (int j = 0; j < NUM_TREES; ++j) { for (int k = 0; k < NUM_BINS; ++k) @@ -398,6 +400,7 @@ scoped_ptr<base::Value> TileManager::GetMemoryRequirementsAsValue() const { } void TileManager::GetRenderingStats(RenderingStats* stats) { + CHECK(record_rendering_stats_); raster_worker_pool_->GetRenderingStats(stats); stats->totalDeferredImageCacheHitCount = rendering_stats_.totalDeferredImageCacheHitCount; @@ -562,15 +565,19 @@ void TileManager::GatherPixelRefsForTile(Tile* tile) { TRACE_EVENT0("cc", "TileManager::GatherPixelRefsForTile"); ManagedTileState& managed_state = tile->managed_state(); if (managed_state.need_to_gather_pixel_refs) { - base::TimeTicks gather_begin_time = base::TimeTicks::Now(); + base::TimeTicks gather_begin_time; + if (record_rendering_stats_) + gather_begin_time = base::TimeTicks::Now(); tile->picture_pile()->GatherPixelRefs( tile->content_rect_, tile->contents_scale_, managed_state.pending_pixel_refs); - rendering_stats_.totalImageGatheringCount++; - rendering_stats_.totalImageGatheringTime += - base::TimeTicks::Now() - gather_begin_time; managed_state.need_to_gather_pixel_refs = false; + if (record_rendering_stats_) { + rendering_stats_.totalImageGatheringCount++; + rendering_stats_.totalImageGatheringTime += + base::TimeTicks::Now() - gather_begin_time; + } } } @@ -772,11 +779,15 @@ void TileManager::RunRasterTask(uint8* buffer, void TileManager::RunImageDecodeTask(skia::LazyPixelRef* pixel_ref, RenderingStats* stats) { TRACE_EVENT0("cc", "TileManager::RunImageDecodeTask"); - base::TimeTicks decode_begin_time = base::TimeTicks::Now(); + base::TimeTicks decode_begin_time; + if (stats) + decode_begin_time = base::TimeTicks::Now(); pixel_ref->Decode(); - stats->totalDeferredImageDecodeCount++; - stats->totalDeferredImageDecodeTime += - base::TimeTicks::Now() - decode_begin_time; + if (stats) { + stats->totalDeferredImageDecodeCount++; + stats->totalDeferredImageDecodeTime += + base::TimeTicks::Now() - decode_begin_time; + } } } // namespace cc diff --git a/cc/tile_manager.h b/cc/tile_manager.h index 6137aab..46d374e 100644 --- a/cc/tile_manager.h +++ b/cc/tile_manager.h @@ -93,7 +93,8 @@ class CC_EXPORT TileManager { public: TileManager(TileManagerClient* client, ResourceProvider *resource_provider, - size_t num_raster_threads); + size_t num_raster_threads, + bool record_rendering_stats); virtual ~TileManager(); const GlobalStateThatImpactsTilePriority& GlobalState() const { @@ -177,6 +178,7 @@ class CC_EXPORT TileManager { size_t bytes_pending_set_pixels_; bool ever_exceeded_memory_budget_; + bool record_rendering_stats_; RenderingStats rendering_stats_; int raster_state_count_[NUM_STATES][NUM_TREES][NUM_BINS]; diff --git a/cc/tiled_layer.cc b/cc/tiled_layer.cc index 2d7d827..464e4f4 100644 --- a/cc/tiled_layer.cc +++ b/cc/tiled_layer.cc @@ -309,7 +309,7 @@ bool TiledLayer::tileOnlyNeedsPartialUpdate(UpdatableTile* tile) return !tile->dirtyRect.Contains(m_tiler->tileRect(tile)) && tile->managedResource()->haveBackingTexture(); } -bool TiledLayer::updateTiles(int left, int top, int right, int bottom, ResourceUpdateQueue& queue, const OcclusionTracker* occlusion, RenderingStats& stats, bool& didPaint) +bool TiledLayer::updateTiles(int left, int top, int right, int bottom, ResourceUpdateQueue& queue, const OcclusionTracker* occlusion, RenderingStats* stats, bool& didPaint) { didPaint = false; createUpdaterIfNeeded(); @@ -427,7 +427,7 @@ gfx::Rect TiledLayer::markTilesForUpdate(int left, int top, int right, int botto return paintRect; } -void TiledLayer::updateTileTextures(const gfx::Rect& paintRect, int left, int top, int right, int bottom, ResourceUpdateQueue& queue, const OcclusionTracker* occlusion, RenderingStats& stats) +void TiledLayer::updateTileTextures(const gfx::Rect& paintRect, int left, int top, int right, int bottom, ResourceUpdateQueue& queue, const OcclusionTracker* occlusion, RenderingStats* stats) { // The updateRect should be in layer space. So we have to convert the paintRect from content space to layer space. float widthScale = bounds().width() / static_cast<float>(contentBounds().width()); @@ -640,7 +640,7 @@ void TiledLayer::updateScrollPrediction() m_previousVisibleRect = visibleContentRect(); } -void TiledLayer::update(ResourceUpdateQueue& queue, const OcclusionTracker* occlusion, RenderingStats& stats) +void TiledLayer::update(ResourceUpdateQueue& queue, const OcclusionTracker* occlusion, RenderingStats* stats) { DCHECK(!m_skipsDraw && !m_failedUpdate); // Did resetUpdateState get skipped? diff --git a/cc/tiled_layer.h b/cc/tiled_layer.h index 95fb843..6903fd5 100644 --- a/cc/tiled_layer.h +++ b/cc/tiled_layer.h @@ -35,7 +35,7 @@ public: virtual Region visibleContentOpaqueRegion() const OVERRIDE; - virtual void update(ResourceUpdateQueue&, const OcclusionTracker*, RenderingStats&) OVERRIDE; + virtual void update(ResourceUpdateQueue&, const OcclusionTracker*, RenderingStats*) OVERRIDE; protected: TiledLayer(); @@ -81,10 +81,10 @@ private: void markOcclusionsAndRequestTextures(int left, int top, int right, int bottom, const OcclusionTracker*); - bool updateTiles(int left, int top, int right, int bottom, ResourceUpdateQueue&, const OcclusionTracker*, RenderingStats&, bool& didPaint); + bool updateTiles(int left, int top, int right, int bottom, ResourceUpdateQueue&, const OcclusionTracker*, RenderingStats*, bool& didPaint); bool haveTexturesForTiles(int left, int top, int right, int bottom, bool ignoreOcclusions); gfx::Rect markTilesForUpdate(int left, int top, int right, int bottom, bool ignoreOcclusions); - void updateTileTextures(const gfx::Rect& paintRect, int left, int top, int right, int bottom, ResourceUpdateQueue&, const OcclusionTracker*, RenderingStats&); + void updateTileTextures(const gfx::Rect& paintRect, int left, int top, int right, int bottom, ResourceUpdateQueue&, const OcclusionTracker*, RenderingStats*); void updateScrollPrediction(); UpdatableTile* tileAt(int, int) const; diff --git a/cc/tiled_layer_unittest.cc b/cc/tiled_layer_unittest.cc index 16740a1..ac8baf5 100644 --- a/cc/tiled_layer_unittest.cc +++ b/cc/tiled_layer_unittest.cc @@ -8,7 +8,6 @@ #include "cc/layer_painter.h" #include "cc/overdraw_metrics.h" #include "cc/prioritized_resource_manager.h" -#include "cc/rendering_stats.h" #include "cc/resource_update_controller.h" #include "cc/single_thread_proxy.h" // For DebugScopedSetImplThread #include "cc/test/animation_test_common.h" @@ -107,7 +106,7 @@ public: void layerUpdate(FakeTiledLayer* layer, TestOcclusionTracker* occluded) { DebugScopedSetMainThread mainThread(m_proxy); - layer->update(*m_queue.get(), occluded, m_stats); + layer->update(*m_queue.get(), occluded, NULL); } void calcDrawProps(const scoped_refptr<FakeTiledLayer>& layer1) @@ -160,9 +159,9 @@ public: // Update content if (layer1) - layer1->update(*m_queue.get(), m_occlusion, m_stats); + layer1->update(*m_queue.get(), m_occlusion, NULL); if (layer2) - layer2->update(*m_queue.get(), m_occlusion, m_stats); + layer2->update(*m_queue.get(), m_occlusion, NULL); bool needsUpdate = false; if (layer1) @@ -186,7 +185,6 @@ public: scoped_ptr<OutputSurface> m_outputSurface; scoped_ptr<ResourceProvider> m_resourceProvider; scoped_ptr<ResourceUpdateQueue> m_queue; - RenderingStats m_stats; PriorityCalculator m_priorityCalculator; FakeLayerImplTreeHostClient m_fakeLayerImplTreeHostClient; scoped_ptr<LayerTreeHost> m_layerTreeHost; @@ -583,7 +581,7 @@ TEST_F(TiledLayerTest, paintSmallAnimatedLayersImmediately) // if it is close to the viewport size and has the available memory. layer->setTexturePriorities(m_priorityCalculator); m_resourceManager->prioritizeTextures(); - layer->update(*m_queue.get(), 0, m_stats); + layer->update(*m_queue.get(), 0, NULL); updateTextures(); layerPushPropertiesTo(layer.get(), layerImpl.get()); @@ -740,7 +738,7 @@ TEST_F(TiledLayerTest, verifyUpdateRectWhenContentBoundsAreScaled) layer->setTexturePriorities(m_priorityCalculator); m_resourceManager->prioritizeTextures(); - layer->update(*m_queue.get(), 0, m_stats); + layer->update(*m_queue.get(), 0, NULL); EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 300, 300 * 0.8), layer->updateRect()); updateTextures(); @@ -748,7 +746,7 @@ TEST_F(TiledLayerTest, verifyUpdateRectWhenContentBoundsAreScaled) layer->setTexturePriorities(m_priorityCalculator); m_resourceManager->prioritizeTextures(); layer->invalidateContentRect(contentBounds); - layer->update(*m_queue.get(), 0, m_stats); + layer->update(*m_queue.get(), 0, NULL); EXPECT_FLOAT_RECT_EQ(gfx::RectF(layerBounds), layer->updateRect()); updateTextures(); @@ -757,7 +755,7 @@ TEST_F(TiledLayerTest, verifyUpdateRectWhenContentBoundsAreScaled) layer->invalidateContentRect(partialDamage); layer->setTexturePriorities(m_priorityCalculator); m_resourceManager->prioritizeTextures(); - layer->update(*m_queue.get(), 0, m_stats); + layer->update(*m_queue.get(), 0, NULL); EXPECT_FLOAT_RECT_EQ(gfx::RectF(45, 80, 15, 8), layer->updateRect()); } @@ -777,7 +775,7 @@ TEST_F(TiledLayerTest, verifyInvalidationWhenContentsScaleChanges) // Push the tiles to the impl side and check that there is exactly one. layer->setTexturePriorities(m_priorityCalculator); m_resourceManager->prioritizeTextures(); - layer->update(*m_queue.get(), 0, m_stats); + layer->update(*m_queue.get(), 0, NULL); updateTextures(); layerPushPropertiesTo(layer.get(), layerImpl.get()); EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); @@ -795,7 +793,7 @@ TEST_F(TiledLayerTest, verifyInvalidationWhenContentsScaleChanges) // The impl side should get 2x2 tiles now. layer->setTexturePriorities(m_priorityCalculator); m_resourceManager->prioritizeTextures(); - layer->update(*m_queue.get(), 0, m_stats); + layer->update(*m_queue.get(), 0, NULL); updateTextures(); layerPushPropertiesTo(layer.get(), layerImpl.get()); EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); @@ -873,7 +871,7 @@ TEST_F(TiledLayerTest, resizeToSmaller) layer->setTexturePriorities(m_priorityCalculator); m_resourceManager->prioritizeTextures(); - layer->update(*m_queue.get(), 0, m_stats); + layer->update(*m_queue.get(), 0, NULL); layer->setBounds(gfx::Size(200, 200)); layer->invalidateContentRect(gfx::Rect(0, 0, 200, 200)); @@ -891,7 +889,7 @@ TEST_F(TiledLayerTest, hugeLayerUpdateCrash) // Ensure no crash for bounds where size * size would overflow an int. layer->setTexturePriorities(m_priorityCalculator); m_resourceManager->prioritizeTextures(); - layer->update(*m_queue.get(), 0, m_stats); + layer->update(*m_queue.get(), 0, NULL); } class TiledLayerPartialUpdateTest : public TiledLayerTest { @@ -1016,7 +1014,7 @@ TEST_F(TiledLayerTest, tilesPaintedWithoutOcclusion) layer->setTexturePriorities(m_priorityCalculator); m_resourceManager->prioritizeTextures(); - layer->update(*m_queue.get(), 0, m_stats); + layer->update(*m_queue.get(), 0, NULL); EXPECT_EQ(2, layer->fakeLayerUpdater()->updateCount()); } @@ -1039,7 +1037,7 @@ TEST_F(TiledLayerTest, tilesPaintedWithOcclusion) layer->setTexturePriorities(m_priorityCalculator); m_resourceManager->prioritizeTextures(); - layer->update(*m_queue.get(), &occluded, m_stats); + layer->update(*m_queue.get(), &occluded, NULL); EXPECT_EQ(36-3, layer->fakeLayerUpdater()->updateCount()); EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); @@ -1052,7 +1050,7 @@ TEST_F(TiledLayerTest, tilesPaintedWithOcclusion) occluded.setOcclusion(gfx::Rect(250, 200, 300, 100)); layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600)); - layer->update(*m_queue.get(), &occluded, m_stats); + layer->update(*m_queue.get(), &occluded, NULL); EXPECT_EQ(36-2, layer->fakeLayerUpdater()->updateCount()); EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); @@ -1065,7 +1063,7 @@ TEST_F(TiledLayerTest, tilesPaintedWithOcclusion) occluded.setOcclusion(gfx::Rect(250, 250, 300, 100)); layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600)); - layer->update(*m_queue.get(), &occluded, m_stats); + layer->update(*m_queue.get(), &occluded, NULL); EXPECT_EQ(36, layer->fakeLayerUpdater()->updateCount()); EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); @@ -1093,7 +1091,7 @@ TEST_F(TiledLayerTest, tilesPaintedWithOcclusionAndVisiblityConstraints) layer->setTexturePriorities(m_priorityCalculator); m_resourceManager->prioritizeTextures(); - layer->update(*m_queue.get(), &occluded, m_stats); + layer->update(*m_queue.get(), &occluded, NULL); EXPECT_EQ(24-3, layer->fakeLayerUpdater()->updateCount()); EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); @@ -1109,7 +1107,7 @@ TEST_F(TiledLayerTest, tilesPaintedWithOcclusionAndVisiblityConstraints) layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600)); layer->setTexturePriorities(m_priorityCalculator); m_resourceManager->prioritizeTextures(); - layer->update(*m_queue.get(), &occluded, m_stats); + layer->update(*m_queue.get(), &occluded, NULL); EXPECT_EQ(24-6, layer->fakeLayerUpdater()->updateCount()); EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); @@ -1125,7 +1123,7 @@ TEST_F(TiledLayerTest, tilesPaintedWithOcclusionAndVisiblityConstraints) layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600)); layer->setTexturePriorities(m_priorityCalculator); m_resourceManager->prioritizeTextures(); - layer->update(*m_queue.get(), &occluded, m_stats); + layer->update(*m_queue.get(), &occluded, NULL); EXPECT_EQ(24-6, layer->fakeLayerUpdater()->updateCount()); EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); @@ -1152,7 +1150,7 @@ TEST_F(TiledLayerTest, tilesNotPaintedWithoutInvalidation) layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600)); layer->setTexturePriorities(m_priorityCalculator); m_resourceManager->prioritizeTextures(); - layer->update(*m_queue.get(), &occluded, m_stats); + layer->update(*m_queue.get(), &occluded, NULL); EXPECT_EQ(36-3, layer->fakeLayerUpdater()->updateCount()); { updateTextures(); @@ -1167,7 +1165,7 @@ TEST_F(TiledLayerTest, tilesNotPaintedWithoutInvalidation) m_resourceManager->prioritizeTextures(); // Repaint without marking it dirty. The 3 culled tiles will be pre-painted now. - layer->update(*m_queue.get(), &occluded, m_stats); + layer->update(*m_queue.get(), &occluded, NULL); EXPECT_EQ(3, layer->fakeLayerUpdater()->updateCount()); EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); @@ -1199,7 +1197,7 @@ TEST_F(TiledLayerTest, tilesPaintedWithOcclusionAndTransforms) layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600)); layer->setTexturePriorities(m_priorityCalculator); m_resourceManager->prioritizeTextures(); - layer->update(*m_queue.get(), &occluded, m_stats); + layer->update(*m_queue.get(), &occluded, NULL); EXPECT_EQ(36-3, layer->fakeLayerUpdater()->updateCount()); EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); @@ -1235,7 +1233,7 @@ TEST_F(TiledLayerTest, tilesPaintedWithOcclusionAndScaling) layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600)); layer->setTexturePriorities(m_priorityCalculator); m_resourceManager->prioritizeTextures(); - layer->update(*m_queue.get(), &occluded, m_stats); + layer->update(*m_queue.get(), &occluded, NULL); // The content is half the size of the layer (so the number of tiles is fewer). // In this case, the content is 300x300, and since the tile size is 100, the // number of tiles 3x3. @@ -1256,7 +1254,7 @@ TEST_F(TiledLayerTest, tilesPaintedWithOcclusionAndScaling) layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600)); layer->setTexturePriorities(m_priorityCalculator); m_resourceManager->prioritizeTextures(); - layer->update(*m_queue.get(), &occluded, m_stats); + layer->update(*m_queue.get(), &occluded, NULL); EXPECT_EQ(9-1, layer->fakeLayerUpdater()->updateCount()); EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); @@ -1279,7 +1277,7 @@ TEST_F(TiledLayerTest, tilesPaintedWithOcclusionAndScaling) layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600)); layer->setTexturePriorities(m_priorityCalculator); m_resourceManager->prioritizeTextures(); - layer->update(*m_queue.get(), &occluded, m_stats); + layer->update(*m_queue.get(), &occluded, NULL); EXPECT_EQ(9-1, layer->fakeLayerUpdater()->updateCount()); EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); @@ -1311,7 +1309,7 @@ TEST_F(TiledLayerTest, visibleContentOpaqueRegion) // If the layer doesn't paint opaque content, then the visibleContentOpaqueRegion should be empty. layer->fakeLayerUpdater()->setOpaquePaintRect(gfx::Rect()); layer->invalidateContentRect(contentBounds); - layer->update(*m_queue.get(), &occluded, m_stats); + layer->update(*m_queue.get(), &occluded, NULL); opaqueContents = layer->visibleContentOpaqueRegion(); EXPECT_TRUE(opaqueContents.IsEmpty()); @@ -1324,7 +1322,7 @@ TEST_F(TiledLayerTest, visibleContentOpaqueRegion) opaquePaintRect = gfx::Rect(10, 10, 90, 190); layer->fakeLayerUpdater()->setOpaquePaintRect(opaquePaintRect); layer->invalidateContentRect(contentBounds); - layer->update(*m_queue.get(), &occluded, m_stats); + layer->update(*m_queue.get(), &occluded, NULL); updateTextures(); opaqueContents = layer->visibleContentOpaqueRegion(); EXPECT_EQ(gfx::IntersectRects(opaquePaintRect, visibleBounds).ToString(), opaqueContents.ToString()); @@ -1336,7 +1334,7 @@ TEST_F(TiledLayerTest, visibleContentOpaqueRegion) // If we paint again without invalidating, the same stuff should be opaque. layer->fakeLayerUpdater()->setOpaquePaintRect(gfx::Rect()); - layer->update(*m_queue.get(), &occluded, m_stats); + layer->update(*m_queue.get(), &occluded, NULL); updateTextures(); opaqueContents = layer->visibleContentOpaqueRegion(); EXPECT_EQ(gfx::IntersectRects(opaquePaintRect, visibleBounds).ToString(), opaqueContents.ToString()); @@ -1350,7 +1348,7 @@ TEST_F(TiledLayerTest, visibleContentOpaqueRegion) // not be affected. layer->fakeLayerUpdater()->setOpaquePaintRect(gfx::Rect()); layer->invalidateContentRect(gfx::Rect(0, 0, 1, 1)); - layer->update(*m_queue.get(), &occluded, m_stats); + layer->update(*m_queue.get(), &occluded, NULL); updateTextures(); opaqueContents = layer->visibleContentOpaqueRegion(); EXPECT_EQ(gfx::IntersectRects(opaquePaintRect, visibleBounds).ToString(), opaqueContents.ToString()); @@ -1364,7 +1362,7 @@ TEST_F(TiledLayerTest, visibleContentOpaqueRegion) // not be affected. layer->fakeLayerUpdater()->setOpaquePaintRect(gfx::Rect()); layer->invalidateContentRect(gfx::Rect(10, 10, 1, 1)); - layer->update(*m_queue.get(), &occluded, m_stats); + layer->update(*m_queue.get(), &occluded, NULL); updateTextures(); opaqueContents = layer->visibleContentOpaqueRegion(); EXPECT_EQ(gfx::IntersectRects(gfx::Rect(10, 100, 90, 100), visibleBounds).ToString(), opaqueContents.ToString()); @@ -1399,7 +1397,7 @@ TEST_F(TiledLayerTest, pixelsPaintedMetrics) // Invalidates and paints the whole layer. layer->fakeLayerUpdater()->setOpaquePaintRect(gfx::Rect()); layer->invalidateContentRect(contentBounds); - layer->update(*m_queue.get(), &occluded, m_stats); + layer->update(*m_queue.get(), &occluded, NULL); updateTextures(); opaqueContents = layer->visibleContentOpaqueRegion(); EXPECT_TRUE(opaqueContents.IsEmpty()); @@ -1414,7 +1412,7 @@ TEST_F(TiledLayerTest, pixelsPaintedMetrics) layer->fakeLayerUpdater()->setOpaquePaintRect(gfx::Rect()); layer->invalidateContentRect(gfx::Rect(0, 0, 1, 1)); layer->invalidateContentRect(gfx::Rect(50, 200, 10, 10)); - layer->update(*m_queue.get(), &occluded, m_stats); + layer->update(*m_queue.get(), &occluded, NULL); updateTextures(); opaqueContents = layer->visibleContentOpaqueRegion(); EXPECT_TRUE(opaqueContents.IsEmpty()); @@ -1632,7 +1630,7 @@ TEST_F(TiledLayerTest, nonIntegerContentsScaleIsNotDistortedDuringPaint) m_resourceManager->prioritizeTextures(); // Update the whole tile. - layer->update(*m_queue.get(), 0, m_stats); + layer->update(*m_queue.get(), 0, NULL); layer->trackingLayerPainter()->resetPaintedRect(); EXPECT_RECT_EQ(gfx::Rect(), layer->trackingLayerPainter()->paintedRect()); @@ -1640,7 +1638,7 @@ TEST_F(TiledLayerTest, nonIntegerContentsScaleIsNotDistortedDuringPaint) // Invalidate the entire layer in content space. When painting, the rect given to webkit should match the layer's bounds. layer->invalidateContentRect(contentRect); - layer->update(*m_queue.get(), 0, m_stats); + layer->update(*m_queue.get(), 0, NULL); EXPECT_RECT_EQ(layerRect, layer->trackingLayerPainter()->paintedRect()); } @@ -1662,7 +1660,7 @@ TEST_F(TiledLayerTest, nonIntegerContentsScaleIsNotDistortedDuringInvalidation) m_resourceManager->prioritizeTextures(); // Update the whole tile. - layer->update(*m_queue.get(), 0, m_stats); + layer->update(*m_queue.get(), 0, NULL); layer->trackingLayerPainter()->resetPaintedRect(); EXPECT_RECT_EQ(gfx::Rect(), layer->trackingLayerPainter()->paintedRect()); @@ -1670,7 +1668,7 @@ TEST_F(TiledLayerTest, nonIntegerContentsScaleIsNotDistortedDuringInvalidation) // Invalidate the entire layer in layer space. When painting, the rect given to webkit should match the layer's bounds. layer->setNeedsDisplayRect(layerRect); - layer->update(*m_queue.get(), 0, m_stats); + layer->update(*m_queue.get(), 0, NULL); EXPECT_RECT_EQ(layerRect, layer->trackingLayerPainter()->paintedRect()); } diff --git a/cc/worker_pool.cc b/cc/worker_pool.cc index 684e15e..5797ab4 100644 --- a/cc/worker_pool.cc +++ b/cc/worker_pool.cc @@ -26,8 +26,8 @@ class WorkerPoolTaskImpl : public internal::WorkerPoolTask { : internal::WorkerPoolTask(reply), task_(task) {} - virtual void Run() OVERRIDE { - task_.Run(&rendering_stats_); + virtual void Run(RenderingStats* rendering_stats) OVERRIDE { + task_.Run(rendering_stats); } private: @@ -57,10 +57,14 @@ void WorkerPoolTask::Completed() { } // namespace internal -WorkerPool::Worker::Worker(WorkerPool* worker_pool, const std::string name) +WorkerPool::Worker::Worker( + WorkerPool* worker_pool, + const std::string name, + scoped_ptr<RenderingStats> rendering_stats) : base::Thread(name.c_str()), worker_pool_(worker_pool), - weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { + weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), + rendering_stats_(rendering_stats.Pass()) { Start(); DCHECK(IsRunning()); } @@ -88,7 +92,9 @@ void WorkerPool::Worker::PostTask(scoped_ptr<internal::WorkerPoolTask> task) { message_loop_proxy()->PostTaskAndReply( FROM_HERE, - base::Bind(&Worker::RunTask, base::Unretained(task.get())), + base::Bind(&Worker::RunTask, + base::Unretained(task.get()), + base::Unretained(rendering_stats_.get())), base::Bind(&Worker::OnTaskCompleted, weak_ptr_factory_.GetWeakPtr())); pending_tasks_.push_back(task.Pass()); @@ -105,39 +111,32 @@ void WorkerPool::Worker::Init() { } // static -void WorkerPool::Worker::RunTask(internal::WorkerPoolTask* task) { - task->Run(); +void WorkerPool::Worker::RunTask( + internal::WorkerPoolTask* task, RenderingStats* rendering_stats) { + task->Run(rendering_stats); } void WorkerPool::Worker::OnTaskCompleted() { CHECK(!pending_tasks_.empty()); scoped_ptr<internal::WorkerPoolTask> task = pending_tasks_.take_front(); - task->Completed(); - rendering_stats_.totalRasterizeTime += - task->rendering_stats().totalRasterizeTime; - rendering_stats_.totalPixelsRasterized += - task->rendering_stats().totalPixelsRasterized; - rendering_stats_.totalDeferredImageDecodeTime += - task->rendering_stats().totalDeferredImageDecodeTime; - rendering_stats_.totalDeferredImageDecodeCount += - task->rendering_stats().totalDeferredImageDecodeCount; - worker_pool_->DidNumPendingTasksChange(); } -WorkerPool::WorkerPool(size_t num_threads) +WorkerPool::WorkerPool(size_t num_threads, bool record_rendering_stats) : workers_need_sorting_(false), shutdown_(false) { const std::string thread_name_prefix = kWorkerThreadNamePrefix; while (workers_.size() < num_threads) { int thread_number = workers_.size() + 1; - workers_.push_back( - new Worker(this, - thread_name_prefix + - StringPrintf("Worker%d", thread_number).c_str())); + scoped_ptr<RenderingStats> rendering_stats = record_rendering_stats ? + make_scoped_ptr(new RenderingStats) : scoped_ptr<RenderingStats>(); + workers_.push_back(new Worker( + this, + thread_name_prefix + StringPrintf("Worker%d", thread_number).c_str(), + rendering_stats.Pass())); } } @@ -181,14 +180,15 @@ void WorkerPool::GetRenderingStats(RenderingStats* stats) { for (WorkerVector::iterator it = workers_.begin(); it != workers_.end(); ++it) { Worker* worker = *it; + CHECK(worker->rendering_stats()); stats->totalRasterizeTime += - worker->rendering_stats().totalRasterizeTime; + worker->rendering_stats()->totalRasterizeTime; stats->totalPixelsRasterized += - worker->rendering_stats().totalPixelsRasterized; + worker->rendering_stats()->totalPixelsRasterized; stats->totalDeferredImageDecodeCount += - worker->rendering_stats().totalDeferredImageDecodeCount; + worker->rendering_stats()->totalDeferredImageDecodeCount; stats->totalDeferredImageDecodeTime += - worker->rendering_stats().totalDeferredImageDecodeTime; + worker->rendering_stats()->totalDeferredImageDecodeTime; } } diff --git a/cc/worker_pool.h b/cc/worker_pool.h index 58ea57a..10fe71e 100644 --- a/cc/worker_pool.h +++ b/cc/worker_pool.h @@ -9,6 +9,7 @@ #include "base/basictypes.h" #include "base/callback.h" +#include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/threading/thread.h" #include "cc/rendering_stats.h" @@ -21,17 +22,14 @@ class WorkerPoolTask { public: virtual ~WorkerPoolTask(); - virtual void Run() = 0; + virtual void Run(RenderingStats* rendering_stats) = 0; void Completed(); - RenderingStats& rendering_stats() { return rendering_stats_; } - protected: WorkerPoolTask(const base::Closure& reply); base::Closure reply_; - RenderingStats rendering_stats_; }; } // namespace internal @@ -44,8 +42,10 @@ class WorkerPool { virtual ~WorkerPool(); - static scoped_ptr<WorkerPool> Create(size_t num_threads) { - return make_scoped_ptr(new WorkerPool(num_threads)); + static scoped_ptr<WorkerPool> Create( + size_t num_threads, bool record_rendering_stats) { + return make_scoped_ptr( + new WorkerPool(num_threads, record_rendering_stats)); } // Tells the worker pool to shutdown and returns once all pending tasks have @@ -66,7 +66,10 @@ class WorkerPool { protected: class Worker : public base::Thread { public: - Worker(WorkerPool* worker_pool, const std::string name); + Worker( + WorkerPool* worker_pool, + const std::string name, + scoped_ptr<RenderingStats> rendering_stats); virtual ~Worker(); // This must be called before the destructor. @@ -76,23 +79,26 @@ class WorkerPool { void PostTask(scoped_ptr<internal::WorkerPoolTask> task); int num_pending_tasks() const { return pending_tasks_.size(); } - const RenderingStats& rendering_stats() const { return rendering_stats_; } + const RenderingStats* rendering_stats() const { + return rendering_stats_.get(); + } // Overridden from base::Thread: virtual void Init() OVERRIDE; private: - static void RunTask(internal::WorkerPoolTask* task); + static void RunTask( + internal::WorkerPoolTask* task, RenderingStats* rendering_stats); void OnTaskCompleted(); WorkerPool* worker_pool_; base::WeakPtrFactory<Worker> weak_ptr_factory_; ScopedPtrDeque<internal::WorkerPoolTask> pending_tasks_; - RenderingStats rendering_stats_; + scoped_ptr<RenderingStats> rendering_stats_; }; - explicit WorkerPool(size_t num_threads); + WorkerPool(size_t num_threads, bool record_rendering_stats); WorkerPool::Worker* GetWorkerForNextTask(); diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc index 5c5289b..2db6514 100644 --- a/content/browser/web_contents/web_contents_impl.cc +++ b/content/browser/web_contents/web_contents_impl.cc @@ -536,6 +536,8 @@ WebPreferences WebContentsImpl::GetWebkitPrefs(RenderViewHost* rvh, command_line.HasSwitch(switches::kEnableExperimentalWebKitFeatures); prefs.css_grid_layout_enabled = command_line.HasSwitch(switches::kEnableExperimentalWebKitFeatures); + prefs.record_rendering_stats = + command_line.HasSwitch(switches::kEnableGpuBenchmarking); bool touch_device_present = false; #if defined(USE_AURA) && defined(USE_X11) diff --git a/content/public/common/common_param_traits_macros.h b/content/public/common/common_param_traits_macros.h index ab3ab39..2473f53 100644 --- a/content/public/common/common_param_traits_macros.h +++ b/content/public/common/common_param_traits_macros.h @@ -197,6 +197,7 @@ IPC_STRUCT_TRAITS_BEGIN(webkit_glue::WebPreferences) IPC_STRUCT_TRAITS_MEMBER(editing_behavior) IPC_STRUCT_TRAITS_MEMBER(supports_multiple_windows) IPC_STRUCT_TRAITS_MEMBER(viewport_enabled) + IPC_STRUCT_TRAITS_MEMBER(record_rendering_stats) IPC_STRUCT_TRAITS_MEMBER(cookie_enabled) IPC_STRUCT_TRAITS_MEMBER(apply_page_scale_factor_in_compositor) #if defined(OS_ANDROID) diff --git a/webkit/compositor_bindings/web_layer_tree_view_impl.cc b/webkit/compositor_bindings/web_layer_tree_view_impl.cc index 2b4d835..2b71187 100644 --- a/webkit/compositor_bindings/web_layer_tree_view_impl.cc +++ b/webkit/compositor_bindings/web_layer_tree_view_impl.cc @@ -53,6 +53,7 @@ bool WebLayerTreeViewImpl::initialize(const WebLayerTreeView::Settings& webSetti settings.initialDebugState.showPlatformLayerTree = webSettings.showPlatformLayerTree; settings.initialDebugState.showDebugBorders = webSettings.showDebugBorders; settings.implSidePainting = CommandLine::ForCurrentProcess()->HasSwitch(cc::switches::kEnableImplSidePainting); + settings.recordRenderingStats = webSettings.recordRenderingStats; settings.calculateTopControlsPosition = CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableTopControlsPositionCalculation); if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kTopControlsHeight)) { diff --git a/webkit/glue/webpreferences.cc b/webkit/glue/webpreferences.cc index f5f6886..a583954 100644 --- a/webkit/glue/webpreferences.cc +++ b/webkit/glue/webpreferences.cc @@ -140,6 +140,7 @@ WebPreferences::WebPreferences() #endif supports_multiple_windows(true), viewport_enabled(false), + record_rendering_stats(false), cookie_enabled(true) #if defined(OS_ANDROID) , @@ -382,6 +383,9 @@ void WebPreferences::Apply(WebView* web_view) const { // overlay of rects, if requested on the command line. settings->setShowPaintRects(show_paint_rects); + // Record rendering stats for benchmarks. + settings->setRecordRenderingStats(record_rendering_stats); + // Set whether to throttle framerate to Vsync. settings->setRenderVSyncEnabled(render_vsync_enabled); diff --git a/webkit/glue/webpreferences.h b/webkit/glue/webpreferences.h index d11b634..6f1861a 100644 --- a/webkit/glue/webpreferences.h +++ b/webkit/glue/webpreferences.h @@ -155,6 +155,7 @@ struct WEBKIT_GLUE_EXPORT WebPreferences { EditingBehavior editing_behavior; bool supports_multiple_windows; bool viewport_enabled; + bool record_rendering_stats; // This flags corresponds to a Page's Settings' setCookieEnabled state. It // only controls whether or not the "document.cookie" field is properly |