Skip to content

Commit

Permalink
cc: Switch RenderingStats collection in Layer::Update() to RenderingS…
Browse files Browse the repository at this point in the history
…tatsInstrumentation

This change switches all of the remaining RenderingStats collection in
composited mode to use RenderinStatsInstrumentation.

BUG=181319


Review URL: https://chromiumcodereview.appspot.com/12426024

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@191086 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
egraether@chromium.org committed Mar 28, 2013
1 parent bd78698 commit 9d4f41f
Show file tree
Hide file tree
Showing 59 changed files with 280 additions and 316 deletions.
8 changes: 0 additions & 8 deletions cc/debug/rendering_stats_instrumentation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,6 @@ base::TimeDelta RenderingStatsInstrumentation::EndRecording(
return base::TimeDelta();
}

void RenderingStatsInstrumentation::AddStats(const RenderingStats& other) {
if (!record_rendering_stats_)
return;

base::AutoLock scoped_lock(lock_);
rendering_stats_.Add(other);
}

void RenderingStatsInstrumentation::IncrementAnimationFrameCount() {
if (!record_rendering_stats_)
return;
Expand Down
4 changes: 0 additions & 4 deletions cc/debug/rendering_stats_instrumentation.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ class CC_EXPORT RenderingStatsInstrumentation {
base::TimeTicks StartRecording() const;
base::TimeDelta EndRecording(base::TimeTicks start_time) const;

// TODO(egraether): Remove after switching Layer::update() to use this class.
// Used in LayerTreeHost::paintLayerContents().
void AddStats(const RenderingStats& other);

void IncrementAnimationFrameCount();
void SetScreenFrameCount(int64 count);
void SetDroppedFrameCount(int64 count);
Expand Down
17 changes: 11 additions & 6 deletions cc/layers/content_layer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ void ContentLayer::SetTexturePriorities(
}

void ContentLayer::Update(ResourceUpdateQueue* queue,
const OcclusionTracker* occlusion,
RenderingStats* stats) {
const OcclusionTracker* occlusion) {
{
base::AutoReset<bool> ignore_set_needs_commit(&ignore_set_needs_commit_,
true);
Expand All @@ -78,7 +77,7 @@ void ContentLayer::Update(ResourceUpdateQueue* queue,
UpdateCanUseLCDText();
}

TiledLayer::Update(queue, occlusion, stats);
TiledLayer::Update(queue, occlusion);
needs_display_ = false;
}

Expand All @@ -96,11 +95,17 @@ void ContentLayer::CreateUpdaterIfNeeded() {
scoped_ptr<LayerPainter> painter =
ContentLayerPainter::Create(client_).PassAs<LayerPainter>();
if (layer_tree_host()->settings().accelerate_painting)
updater_ = SkPictureContentLayerUpdater::Create(painter.Pass());
updater_ = SkPictureContentLayerUpdater::Create(
painter.Pass(),
rendering_stats_instrumentation());
else if (layer_tree_host()->settings().per_tile_painting_enabled)
updater_ = BitmapSkPictureContentLayerUpdater::Create(painter.Pass());
updater_ = BitmapSkPictureContentLayerUpdater::Create(
painter.Pass(),
rendering_stats_instrumentation());
else
updater_ = BitmapContentLayerUpdater::Create(painter.Pass());
updater_ = BitmapContentLayerUpdater::Create(
painter.Pass(),
rendering_stats_instrumentation());
updater_->SetOpaque(contents_opaque());

unsigned texture_format =
Expand Down
3 changes: 1 addition & 2 deletions cc/layers/content_layer.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ class CC_EXPORT ContentLayer : public TiledLayer {
virtual void SetTexturePriorities(const PriorityCalculator& priority_calc)
OVERRIDE;
virtual void Update(ResourceUpdateQueue* queue,
const OcclusionTracker* occlusion,
RenderingStats* stats) OVERRIDE;
const OcclusionTracker* occlusion) OVERRIDE;
virtual bool NeedMoreUpdates() OVERRIDE;

virtual void SetContentsOpaque(bool contents_opaque) OVERRIDE;
Expand Down
10 changes: 6 additions & 4 deletions cc/layers/content_layer_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include "cc/layers/content_layer_client.h"
#include "cc/resources/bitmap_content_layer_updater.h"
#include "cc/test/fake_rendering_stats_instrumentation.h"
#include "cc/test/geometry_test_utils.h"
#include "skia/ext/platform_canvas.h"
#include "testing/gtest/include/gtest/gtest.h"
Expand Down Expand Up @@ -37,17 +38,18 @@ TEST(ContentLayerTest, ContentLayerPainterWithDeviceScale) {
gfx::RectF opaque_rect_in_content_space = gfx::ScaleRect(
opaque_rect_in_layer_space, contents_scale, contents_scale);
MockContentLayerClient client(opaque_rect_in_layer_space);
FakeRenderingStatsInstrumentation stats_instrumentation;
scoped_refptr<BitmapContentLayerUpdater> updater =
BitmapContentLayerUpdater::Create(ContentLayerPainter::Create(&client).
PassAs<LayerPainter>());
BitmapContentLayerUpdater::Create(
ContentLayerPainter::Create(&client).PassAs<LayerPainter>(),
&stats_instrumentation);

gfx::Rect resulting_opaque_rect;
updater->PrepareToUpdate(content_rect,
gfx::Size(256, 256),
contents_scale,
contents_scale,
&resulting_opaque_rect,
NULL);
&resulting_opaque_rect);

EXPECT_RECT_EQ(gfx::ToEnclosingRect(opaque_rect_in_content_space),
resulting_opaque_rect);
Expand Down
3 changes: 1 addition & 2 deletions cc/layers/contents_scaling_layer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ void ContentsScalingLayer::CalculateContentsScale(

void ContentsScalingLayer::Update(
ResourceUpdateQueue* queue,
const OcclusionTracker* occlusion,
RenderingStats* stats) {
const OcclusionTracker* occlusion) {
if (draw_properties().contents_scale_x == last_update_contents_scale_x_ &&
draw_properties().contents_scale_y == last_update_contents_scale_y_)
return;
Expand Down
3 changes: 1 addition & 2 deletions cc/layers/contents_scaling_layer.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ class CC_EXPORT ContentsScalingLayer : public Layer {

virtual void Update(
ResourceUpdateQueue* queue,
const OcclusionTracker* occlusion,
RenderingStats* stats) OVERRIDE;
const OcclusionTracker* occlusion) OVERRIDE;

protected:
ContentsScalingLayer();
Expand Down
3 changes: 1 addition & 2 deletions cc/layers/heads_up_display_layer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ HeadsUpDisplayLayer::HeadsUpDisplayLayer() : Layer() {
HeadsUpDisplayLayer::~HeadsUpDisplayLayer() {}

void HeadsUpDisplayLayer::Update(ResourceUpdateQueue*,
const OcclusionTracker*,
RenderingStats*) {
const OcclusionTracker*) {
const LayerTreeDebugState& debug_state = layer_tree_host()->debug_state();
int max_texture_size =
layer_tree_host()->GetRendererCapabilities().max_texture_size;
Expand Down
3 changes: 1 addition & 2 deletions cc/layers/heads_up_display_layer.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ class CC_EXPORT HeadsUpDisplayLayer : public Layer {
static scoped_refptr<HeadsUpDisplayLayer> Create();

virtual void Update(ResourceUpdateQueue* queue,
const OcclusionTracker* tracker,
RenderingStats* stats) OVERRIDE;
const OcclusionTracker* tracker) OVERRIDE;
virtual bool DrawsContent() const OVERRIDE;

virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl)
Expand Down
5 changes: 2 additions & 3 deletions cc/layers/image_layer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,15 @@ void ImageLayer::SetTexturePriorities(const PriorityCalculator& priority_calc) {
}

void ImageLayer::Update(ResourceUpdateQueue* queue,
const OcclusionTracker* occlusion,
RenderingStats* stats) {
const OcclusionTracker* occlusion) {
CreateUpdaterIfNeeded();
if (needs_display_) {
updater_->set_bitmap(bitmap_);
UpdateTileSizeAndTilingOption();
InvalidateContentRect(gfx::Rect(content_bounds()));
needs_display_ = false;
}
TiledLayer::Update(queue, occlusion, stats);
TiledLayer::Update(queue, occlusion);
}

void ImageLayer::CreateUpdaterIfNeeded() {
Expand Down
3 changes: 1 addition & 2 deletions cc/layers/image_layer.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ class CC_EXPORT ImageLayer : public TiledLayer {
virtual void SetTexturePriorities(const PriorityCalculator& priority_calc)
OVERRIDE;
virtual void Update(ResourceUpdateQueue* queue,
const OcclusionTracker* occlusion,
RenderingStats* stats) OVERRIDE;
const OcclusionTracker* occlusion) OVERRIDE;
virtual void CalculateContentsScale(float ideal_contents_scale,
bool animating_transform_to_screen,
float* contents_scale_x,
Expand Down
4 changes: 4 additions & 0 deletions cc/layers/layer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -818,4 +818,8 @@ ScrollbarLayer* Layer::ToScrollbarLayer() {
return NULL;
}

RenderingStatsInstrumentation* Layer::rendering_stats_instrumentation() const {
return layer_tree_host_->rendering_stats_instrumentation();
}

} // namespace cc
7 changes: 4 additions & 3 deletions cc/layers/layer.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class PriorityCalculator;
class ResourceUpdateQueue;
class ScrollbarLayer;
struct AnimationEvent;
struct RenderingStats;
class RenderingStatsInstrumentation;

// Base class for composited layers. Special layer types are derived from
// this class.
Expand Down Expand Up @@ -267,8 +267,7 @@ class CC_EXPORT Layer : public base::RefCounted<Layer>,
// These methods typically need to be overwritten by derived classes.
virtual bool DrawsContent() const;
virtual void Update(ResourceUpdateQueue* queue,
const OcclusionTracker* occlusion,
RenderingStats* stats) {}
const OcclusionTracker* occlusion) {}
virtual bool NeedMoreUpdates();
virtual void SetIsMask(bool is_mask) {}

Expand Down Expand Up @@ -370,6 +369,8 @@ class CC_EXPORT Layer : public base::RefCounted<Layer>,
bool NeedsDisplayForTesting() const { return needs_display_; }
void ResetNeedsDisplayForTesting() { needs_display_ = false; }

RenderingStatsInstrumentation* rendering_stats_instrumentation() const;

protected:
friend class LayerImpl;
friend class TreeSynchronizer;
Expand Down
3 changes: 1 addition & 2 deletions cc/layers/nine_patch_layer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ void NinePatchLayer::SetBitmap(const SkBitmap& bitmap, gfx::Rect aperture) {
}

void NinePatchLayer::Update(ResourceUpdateQueue* queue,
const OcclusionTracker* occlusion,
RenderingStats* stats) {
const OcclusionTracker* occlusion) {
CreateUpdaterIfNeeded();

if (resource_ &&
Expand Down
3 changes: 1 addition & 2 deletions cc/layers/nine_patch_layer.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ class CC_EXPORT NinePatchLayer : public Layer {
virtual void SetTexturePriorities(const PriorityCalculator& priority_calc)
OVERRIDE;
virtual void Update(ResourceUpdateQueue* queue,
const OcclusionTracker* occlusion,
RenderingStats* stats) OVERRIDE;
const OcclusionTracker* occlusion) OVERRIDE;
virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE;

// aperture is in the pixel space of the bitmap resource and refers to
Expand Down
10 changes: 5 additions & 5 deletions cc/layers/nine_patch_layer_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ TEST_F(NinePatchLayerTest, TriggerFullUploadOnceWhenChangingBitmap) {

// No bitmap set should not trigger any uploads.
test_layer->SetTexturePriorities(calculator);
test_layer->Update(&queue, &occlusion_tracker, NULL);
test_layer->Update(&queue, &occlusion_tracker);
EXPECT_EQ(queue.FullUploadSize(), 0);
EXPECT_EQ(queue.PartialUploadSize(), 0);

Expand All @@ -83,7 +83,7 @@ TEST_F(NinePatchLayerTest, TriggerFullUploadOnceWhenChangingBitmap) {
bitmap.allocPixels();
test_layer->SetBitmap(bitmap, gfx::Rect(5, 5, 1, 1));
test_layer->SetTexturePriorities(calculator);
test_layer->Update(&queue, &occlusion_tracker, NULL);
test_layer->Update(&queue, &occlusion_tracker);
EXPECT_EQ(queue.FullUploadSize(), 1);
EXPECT_EQ(queue.PartialUploadSize(), 0);
ResourceUpdate params = queue.TakeFirstFullUpload();
Expand All @@ -107,7 +107,7 @@ TEST_F(NinePatchLayerTest, TriggerFullUploadOnceWhenChangingBitmap) {

// Nothing changed, so no repeated upload.
test_layer->SetTexturePriorities(calculator);
test_layer->Update(&queue, &occlusion_tracker, NULL);
test_layer->Update(&queue, &occlusion_tracker);
EXPECT_EQ(queue.FullUploadSize(), 0);
EXPECT_EQ(queue.PartialUploadSize(), 0);
{
Expand All @@ -119,7 +119,7 @@ TEST_F(NinePatchLayerTest, TriggerFullUploadOnceWhenChangingBitmap) {

// Reupload after eviction
test_layer->SetTexturePriorities(calculator);
test_layer->Update(&queue, &occlusion_tracker, NULL);
test_layer->Update(&queue, &occlusion_tracker);
EXPECT_EQ(queue.FullUploadSize(), 1);
EXPECT_EQ(queue.PartialUploadSize(), 0);

Expand All @@ -129,7 +129,7 @@ TEST_F(NinePatchLayerTest, TriggerFullUploadOnceWhenChangingBitmap) {
EXPECT_EQ(NULL, params.texture->resource_manager());
test_layer->SetTexturePriorities(calculator);
ResourceUpdateQueue queue2;
test_layer->Update(&queue2, &occlusion_tracker, NULL);
test_layer->Update(&queue2, &occlusion_tracker);
EXPECT_EQ(queue2.FullUploadSize(), 1);
EXPECT_EQ(queue2.PartialUploadSize(), 0);
params = queue2.TakeFirstFullUpload();
Expand Down
5 changes: 2 additions & 3 deletions cc/layers/picture_layer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ void PictureLayer::SetNeedsDisplayRect(const gfx::RectF& layer_rect) {
}

void PictureLayer::Update(ResourceUpdateQueue*,
const OcclusionTracker*,
RenderingStats* stats) {
const OcclusionTracker*) {
// Do not early-out of this function so that PicturePile::Update has a chance
// to record pictures due to changing visibility of this layer.

Expand All @@ -87,7 +86,7 @@ void PictureLayer::Update(ResourceUpdateQueue*,
background_color(),
pile_invalidation_,
visible_layer_rect,
stats);
rendering_stats_instrumentation());
}

void PictureLayer::SetIsMask(bool is_mask) {
Expand Down
4 changes: 1 addition & 3 deletions cc/layers/picture_layer.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ namespace cc {

class ContentLayerClient;
class ResourceUpdateQueue;
struct RenderingStats;

class CC_EXPORT PictureLayer : public ContentsScalingLayer {
public:
Expand All @@ -32,8 +31,7 @@ class CC_EXPORT PictureLayer : public ContentsScalingLayer {
virtual void SetNeedsDisplayRect(const gfx::RectF& layer_rect) OVERRIDE;
virtual void Update(
ResourceUpdateQueue* queue,
const OcclusionTracker* occlusion,
RenderingStats* stats) OVERRIDE;
const OcclusionTracker* occlusion) OVERRIDE;
virtual void SetIsMask(bool is_mask) OVERRIDE;

protected:
Expand Down
4 changes: 3 additions & 1 deletion cc/layers/picture_layer_impl_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "cc/test/fake_impl_proxy.h"
#include "cc/test/fake_layer_tree_host_impl.h"
#include "cc/test/fake_output_surface.h"
#include "cc/test/fake_rendering_stats_instrumentation.h"
#include "cc/test/impl_side_painting_settings.h"
#include "cc/trees/layer_tree_impl.h"
#include "testing/gtest/include/gtest/gtest.h"
Expand Down Expand Up @@ -95,7 +96,8 @@ class TestablePicturePileImpl : public PicturePileImpl {
return;
gfx::Rect bounds(tiling().TileBounds(x, y));
scoped_refptr<Picture> picture(Picture::Create(bounds));
picture->Record(&client_, NULL, tile_grid_info_);
FakeRenderingStatsInstrumentation stats_instrumentation;
picture->Record(&client_, &stats_instrumentation, tile_grid_info_);
picture_list_map_[std::pair<int, int>(x, y)].push_back(picture);
EXPECT_TRUE(HasRecordingAt(x, y));

Expand Down
Loading

0 comments on commit 9d4f41f

Please sign in to comment.