diff options
author | ernstm@chromium.org <ernstm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-17 06:34:12 +0000 |
---|---|---|
committer | ernstm@chromium.org <ernstm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-17 06:34:12 +0000 |
commit | 206a3926590cbf7e9d92fa15cade21f20f9245d7 (patch) | |
tree | afb2060ab5edc3889900c206d4ecc5874355bb20 | |
parent | 884e4d7aee2c082df99654b60e82b47194ed1242 (diff) | |
download | chromium_src-206a3926590cbf7e9d92fa15cade21f20f9245d7.zip chromium_src-206a3926590cbf7e9d92fa15cade21f20f9245d7.tar.gz chromium_src-206a3926590cbf7e9d92fa15cade21f20f9245d7.tar.bz2 |
cc: Added features for more accurate raster benchmark
- Added debug switch to rasterize only visible tiles
- Tagged all tiles and raster tasks with their source frame number
BUG=226489
Review URL: https://chromiumcodereview.appspot.com/14975007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@200736 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | cc/debug/layer_tree_debug_state.cc | 4 | ||||
-rw-r--r-- | cc/debug/layer_tree_debug_state.h | 1 | ||||
-rw-r--r-- | cc/layers/picture_layer_impl.cc | 3 | ||||
-rw-r--r-- | cc/resources/tile.cc | 6 | ||||
-rw-r--r-- | cc/resources/tile.h | 6 | ||||
-rw-r--r-- | cc/resources/tile_manager.cc | 1 | ||||
-rw-r--r-- | cc/resources/tile_manager.h | 1 | ||||
-rw-r--r-- | cc/resources/tile_manager_unittest.cc | 2 | ||||
-rw-r--r-- | cc/test/fake_picture_layer_tiling_client.cc | 1 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_impl.cc | 21 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_impl.h | 2 | ||||
-rw-r--r-- | content/renderer/gpu/gpu_benchmarking_extension.cc | 29 | ||||
-rw-r--r-- | content/renderer/gpu/render_widget_compositor.cc | 6 | ||||
-rw-r--r-- | content/renderer/gpu/render_widget_compositor.h | 1 | ||||
-rw-r--r-- | tools/perf/perf_tools/rasterize_and_record_benchmark.py | 4 |
15 files changed, 80 insertions, 8 deletions
diff --git a/cc/debug/layer_tree_debug_state.cc b/cc/debug/layer_tree_debug_state.cc index bde6e79..f6e61b7 100644 --- a/cc/debug/layer_tree_debug_state.cc +++ b/cc/debug/layer_tree_debug_state.cc @@ -22,6 +22,7 @@ LayerTreeDebugState::LayerTreeDebugState() show_occluding_rects(false), show_non_occluding_rects(false), slow_down_raster_scale_factor(0), + rasterize_only_visible_content(false), show_picture_borders(false), record_rendering_stats_(false) {} @@ -66,6 +67,8 @@ bool LayerTreeDebugState::Equal(const LayerTreeDebugState& a, a.show_occluding_rects == b.show_occluding_rects && a.show_non_occluding_rects == b.show_non_occluding_rects && a.slow_down_raster_scale_factor == b.slow_down_raster_scale_factor && + a.rasterize_only_visible_content == + b.rasterize_only_visible_content && a.show_picture_borders == b.show_picture_borders && a.record_rendering_stats_ == b.record_rendering_stats_); } @@ -89,6 +92,7 @@ LayerTreeDebugState LayerTreeDebugState::Unite(const LayerTreeDebugState& a, if (b.slow_down_raster_scale_factor) r.slow_down_raster_scale_factor = b.slow_down_raster_scale_factor; + r.rasterize_only_visible_content |= b.rasterize_only_visible_content; r.show_picture_borders |= b.show_picture_borders; r.record_rendering_stats_ |= b.record_rendering_stats_; diff --git a/cc/debug/layer_tree_debug_state.h b/cc/debug/layer_tree_debug_state.h index e5f6e1d..b7e44a0 100644 --- a/cc/debug/layer_tree_debug_state.h +++ b/cc/debug/layer_tree_debug_state.h @@ -29,6 +29,7 @@ class CC_EXPORT LayerTreeDebugState { bool show_non_occluding_rects; int slow_down_raster_scale_factor; + bool rasterize_only_visible_content; bool show_picture_borders; void SetRecordRenderingStats(bool enabled); diff --git a/cc/layers/picture_layer_impl.cc b/cc/layers/picture_layer_impl.cc index e281198..1cc9e6c 100644 --- a/cc/layers/picture_layer_impl.cc +++ b/cc/layers/picture_layer_impl.cc @@ -421,7 +421,8 @@ scoped_refptr<Tile> PictureLayerImpl::CreateTile(PictureLayerTiling* tiling, content_rect, contents_opaque() ? content_rect : gfx::Rect(), tiling->contents_scale(), - id())); + id(), + layer_tree_impl()->source_frame_number())); } void PictureLayerImpl::UpdatePile(Tile* tile) { diff --git a/cc/resources/tile.cc b/cc/resources/tile.cc index 1f98c3c..53f81ce 100644 --- a/cc/resources/tile.cc +++ b/cc/resources/tile.cc @@ -16,13 +16,15 @@ Tile::Tile(TileManager* tile_manager, gfx::Rect content_rect, gfx::Rect opaque_rect, float contents_scale, - int layer_id) + int layer_id, + int source_frame_number) : tile_manager_(tile_manager), tile_size_(tile_size), content_rect_(content_rect), contents_scale_(contents_scale), opaque_rect_(opaque_rect), - layer_id_(layer_id) { + layer_id_(layer_id), + source_frame_number_(source_frame_number) { set_picture_pile(picture_pile); tile_manager_->RegisterTile(this); } diff --git a/cc/resources/tile.h b/cc/resources/tile.h index f68fdf1..fa75bb0 100644 --- a/cc/resources/tile.h +++ b/cc/resources/tile.h @@ -28,7 +28,8 @@ class CC_EXPORT Tile : public base::RefCounted<Tile> { gfx::Rect content_rect, gfx::Rect opaque_rect, float contents_scale, - int layer_id); + int layer_id, + int source_frame_number); PicturePileImpl* picture_pile() { return picture_pile_.get(); @@ -64,6 +65,8 @@ class CC_EXPORT Tile : public base::RefCounted<Tile> { int layer_id() const { return layer_id_; } + int source_frame_number() const { return source_frame_number_; } + void set_picture_pile(scoped_refptr<PicturePileImpl> pile) { DCHECK(pile->CanRaster(contents_scale_, content_rect_)); picture_pile_ = pile; @@ -99,6 +102,7 @@ class CC_EXPORT Tile : public base::RefCounted<Tile> { TilePriority priority_[NUM_BIN_PRIORITIES]; ManagedTileState managed_state_; int layer_id_; + int source_frame_number_; DISALLOW_COPY_AND_ASSIGN(Tile); }; diff --git a/cc/resources/tile_manager.cc b/cc/resources/tile_manager.cc index 65dbea0..2cb9796 100644 --- a/cc/resources/tile_manager.cc +++ b/cc/resources/tile_manager.cc @@ -748,6 +748,7 @@ TileManager::RasterTaskMetadata TileManager::GetRasterTaskMetadata( metadata.tile_resolution = mts.resolution; metadata.layer_id = tile.layer_id(); metadata.tile_id = &tile; + metadata.source_frame_number = tile.source_frame_number(); return metadata; } diff --git a/cc/resources/tile_manager.h b/cc/resources/tile_manager.h index 23a16d4..f9b428b 100644 --- a/cc/resources/tile_manager.h +++ b/cc/resources/tile_manager.h @@ -114,6 +114,7 @@ class CC_EXPORT TileManager : public WorkerPoolClient { TileResolution tile_resolution; int layer_id; const void* tile_id; + int source_frame_number; }; RasterTaskMetadata GetRasterTaskMetadata(const Tile& tile) const; diff --git a/cc/resources/tile_manager_unittest.cc b/cc/resources/tile_manager_unittest.cc index 9cbbcad..0231762 100644 --- a/cc/resources/tile_manager_unittest.cc +++ b/cc/resources/tile_manager_unittest.cc @@ -70,6 +70,7 @@ TEST(TileManagerTest, OOM) { gfx::Rect(), gfx::Rect(), 1.0, + 0, 0)); tile->SetPriority(PENDING_TREE, TilePriority()); tile->SetPriority(ACTIVE_TREE, eventual_prio); @@ -84,6 +85,7 @@ TEST(TileManagerTest, OOM) { gfx::Rect(), gfx::Rect(), 1.0, + 0, 0)); tile->SetPriority(PENDING_TREE, now_prio); tile->SetPriority(ACTIVE_TREE, TilePriority()); diff --git a/cc/test/fake_picture_layer_tiling_client.cc b/cc/test/fake_picture_layer_tiling_client.cc index 77c902b..7c18d35 100644 --- a/cc/test/fake_picture_layer_tiling_client.cc +++ b/cc/test/fake_picture_layer_tiling_client.cc @@ -47,6 +47,7 @@ scoped_refptr<Tile> FakePictureLayerTilingClient::CreateTile( rect, gfx::Rect(), 1, + 0, 0); } diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc index 7e8d0c0..d8915db 100644 --- a/cc/trees/layer_tree_host_impl.cc +++ b/cc/trees/layer_tree_host_impl.cc @@ -909,6 +909,7 @@ bool LayerTreeHostImpl::PrepareToDraw(FrameData* frame, void LayerTreeHostImpl::EnforceManagedMemoryPolicy( const ManagedMemoryPolicy& policy) { + bool evicted_resources = client_->ReduceContentsTextureMemoryOnImplThread( visible_ ? policy.bytes_limit_when_visible : policy.bytes_limit_when_not_visible, @@ -996,10 +997,10 @@ void LayerTreeHostImpl::SetManagedMemoryPolicy( // In single-thread mode, this can be called on the main thread by // GLRenderer::OnMemoryAllocationChanged. DebugScopedSetImplThread impl_thread(proxy_); - EnforceManagedMemoryPolicy(managed_memory_policy_); + EnforceManagedMemoryPolicy(ActualManagedMemoryPolicy()); } else { DCHECK(proxy_->IsImplThread()); - EnforceManagedMemoryPolicy(managed_memory_policy_); + EnforceManagedMemoryPolicy(ActualManagedMemoryPolicy()); } if (needs_commit) @@ -1345,7 +1346,7 @@ void LayerTreeHostImpl::SetVisible(bool visible) { return; visible_ = visible; DidVisibilityChange(this, visible_); - EnforceManagedMemoryPolicy(managed_memory_policy_); + EnforceManagedMemoryPolicy(ActualManagedMemoryPolicy()); if (!renderer_) return; @@ -1353,6 +1354,18 @@ void LayerTreeHostImpl::SetVisible(bool visible) { renderer_->SetVisible(visible); } +ManagedMemoryPolicy LayerTreeHostImpl::ActualManagedMemoryPolicy() const { + if (!debug_state_.rasterize_only_visible_content) + return managed_memory_policy_; + + ManagedMemoryPolicy actual = managed_memory_policy_; + actual.priority_cutoff_when_not_visible = + ManagedMemoryPolicy::CUTOFF_ALLOW_NOTHING; + actual.priority_cutoff_when_visible = + ManagedMemoryPolicy::CUTOFF_ALLOW_REQUIRED_ONLY; + return actual; +} + bool LayerTreeHostImpl::InitializeRenderer( scoped_ptr<OutputSurface> output_surface) { // Since we will create a new resource provider, we cannot continue to use @@ -1389,7 +1402,7 @@ bool LayerTreeHostImpl::InitializeRenderer( settings_.num_raster_threads, settings_.use_color_estimator, rendering_stats_instrumentation_)); - UpdateTileManagerMemoryPolicy(managed_memory_policy_); + UpdateTileManagerMemoryPolicy(ActualManagedMemoryPolicy()); } if (output_surface->capabilities().has_parent_compositor) { diff --git a/cc/trees/layer_tree_host_impl.h b/cc/trees/layer_tree_host_impl.h index 5125c82..8c7edc4 100644 --- a/cc/trees/layer_tree_host_impl.h +++ b/cc/trees/layer_tree_host_impl.h @@ -248,6 +248,8 @@ class CC_EXPORT LayerTreeHostImpl : public InputHandler, void SetNeedsCommit() { client_->SetNeedsCommitOnImplThread(); } void SetNeedsRedraw() { client_->SetNeedsRedrawOnImplThread(); } + ManagedMemoryPolicy ActualManagedMemoryPolicy() const; + size_t memory_allocation_limit_bytes() const { return managed_memory_policy_.bytes_limit_when_visible; } diff --git a/content/renderer/gpu/gpu_benchmarking_extension.cc b/content/renderer/gpu/gpu_benchmarking_extension.cc index 64ccfb6..146769b 100644 --- a/content/renderer/gpu/gpu_benchmarking_extension.cc +++ b/content/renderer/gpu/gpu_benchmarking_extension.cc @@ -129,6 +129,10 @@ class GpuBenchmarkingWrapper : public v8::Extension { " native function SetNeedsDisplayOnAllLayers();" " return SetNeedsDisplayOnAllLayers();" "};" + "chrome.gpuBenchmarking.setRasterizeOnlyVisibleContent = function() {" + " native function SetRasterizeOnlyVisibleContent();" + " return SetRasterizeOnlyVisibleContent();" + "};" "chrome.gpuBenchmarking.renderingStats = function() {" " native function GetRenderingStats();" " return GetRenderingStats();" @@ -166,6 +170,8 @@ class GpuBenchmarkingWrapper : public v8::Extension { v8::Handle<v8::String> name) OVERRIDE { if (name->Equals(v8::String::New("SetNeedsDisplayOnAllLayers"))) return v8::FunctionTemplate::New(SetNeedsDisplayOnAllLayers); + if (name->Equals(v8::String::New("SetRasterizeOnlyVisibleContent"))) + return v8::FunctionTemplate::New(SetRasterizeOnlyVisibleContent); if (name->Equals(v8::String::New("GetRenderingStats"))) return v8::FunctionTemplate::New(GetRenderingStats); if (name->Equals(v8::String::New("PrintToSkPicture"))) @@ -203,6 +209,29 @@ class GpuBenchmarkingWrapper : public v8::Extension { return v8::Undefined(); } + static v8::Handle<v8::Value> SetRasterizeOnlyVisibleContent( + const v8::Arguments& args) { + WebFrame* web_frame = WebFrame::frameForCurrentContext(); + if (!web_frame) + return v8::Undefined(); + + WebView* web_view = web_frame->view(); + if (!web_view) + return v8::Undefined(); + + RenderViewImpl* render_view_impl = RenderViewImpl::FromWebView(web_view); + if (!render_view_impl) + return v8::Undefined(); + + RenderWidgetCompositor* compositor = render_view_impl->compositor(); + if (!compositor) + return v8::Undefined(); + + compositor->SetRasterizeOnlyVisibleContent(); + + return v8::Undefined(); + } + static v8::Handle<v8::Value> GetRenderingStats(const v8::Arguments& args) { WebFrame* web_frame = WebFrame::frameForCurrentContext(); diff --git a/content/renderer/gpu/render_widget_compositor.cc b/content/renderer/gpu/render_widget_compositor.cc index d834c31..89cc3d3 100644 --- a/content/renderer/gpu/render_widget_compositor.cc +++ b/content/renderer/gpu/render_widget_compositor.cc @@ -320,6 +320,12 @@ void RenderWidgetCompositor::SetNeedsDisplayOnAllLayers() { layer_tree_host_->SetNeedsDisplayOnAllLayers(); } +void RenderWidgetCompositor::SetRasterizeOnlyVisibleContent() { + cc::LayerTreeDebugState current = layer_tree_host_->debug_state(); + current.rasterize_only_visible_content = true; + layer_tree_host_->SetDebugState(current); +} + void RenderWidgetCompositor::GetRenderingStats(cc::RenderingStats* stats) { layer_tree_host_->CollectRenderingStats(stats); } diff --git a/content/renderer/gpu/render_widget_compositor.h b/content/renderer/gpu/render_widget_compositor.h index c8c8e0f..c66ab7c 100644 --- a/content/renderer/gpu/render_widget_compositor.h +++ b/content/renderer/gpu/render_widget_compositor.h @@ -36,6 +36,7 @@ class RenderWidgetCompositor : public WebKit::WebLayerTreeView, void Animate(base::TimeTicks time); void Composite(base::TimeTicks frame_begin_time); void SetNeedsDisplayOnAllLayers(); + void SetRasterizeOnlyVisibleContent(); void GetRenderingStats(cc::RenderingStats* stats); skia::RefPtr<SkPicture> CapturePicture(); void UpdateTopControlsState(bool enable_hiding, diff --git a/tools/perf/perf_tools/rasterize_and_record_benchmark.py b/tools/perf/perf_tools/rasterize_and_record_benchmark.py index 5834393..17cc63c 100644 --- a/tools/perf/perf_tools/rasterize_and_record_benchmark.py +++ b/tools/perf/perf_tools/rasterize_and_record_benchmark.py @@ -72,6 +72,10 @@ class RasterizeAndPaintMeasurement(page_measurement.PageMeasurement): def MeasurePage(self, page, tab, results): self._metrics = smoothness_metrics.SmoothnessMetrics(tab) + # Rasterize only what's visible + tab.ExecuteJavaScript( + 'chrome.gpuBenchmarking.setRasterizeOnlyVisibleContent();') + # Wait until the page has loaded and come to a somewhat steady state # (empirical wait time) time.sleep(5) |