summaryrefslogtreecommitdiffstats
path: root/cc/test
diff options
context:
space:
mode:
authorvmpstr@chromium.org <vmpstr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-19 08:38:57 +0000
committervmpstr@chromium.org <vmpstr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-19 08:38:57 +0000
commitc410a989feffdd7b1825b0600e9f32a3c01b4610 (patch)
tree34088f3608126326211b9f2039bfb549a539c5da /cc/test
parentd5f4177dd7237b252c6083b18fb62e3990f85452 (diff)
downloadchromium_src-c410a989feffdd7b1825b0600e9f32a3c01b4610.zip
chromium_src-c410a989feffdd7b1825b0600e9f32a3c01b4610.tar.gz
chromium_src-c410a989feffdd7b1825b0600e9f32a3c01b4610.tar.bz2
cc: Only consider layer clipped content rect for analysis
This fixes a problem in which tiles that are on the right and bottom edges of the viewport are not considered solid, even when the visible part of them is solid. BUG=230875 Review URL: https://chromiumcodereview.appspot.com/14205005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@195103 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/test')
-rw-r--r--cc/test/fake_content_layer_client.cc14
-rw-r--r--cc/test/fake_content_layer_client.h10
-rw-r--r--cc/test/fake_picture_pile_impl.cc76
-rw-r--r--cc/test/fake_picture_pile_impl.h52
4 files changed, 144 insertions, 8 deletions
diff --git a/cc/test/fake_content_layer_client.cc b/cc/test/fake_content_layer_client.cc
index cf82de6..7153766 100644
--- a/cc/test/fake_content_layer_client.cc
+++ b/cc/test/fake_content_layer_client.cc
@@ -20,11 +20,15 @@ void FakeContentLayerClient::PaintContents(SkCanvas* canvas,
if (paint_all_opaque_)
*opaque_rect = rect;
- SkPaint paint;
- for (RectVector::const_iterator rect_it = draw_rects_.begin();
- rect_it < draw_rects_.end(); rect_it++) {
- SkRect draw_rect = SkRect::MakeXYWH(rect_it->x(), rect_it->y(),
- rect_it->width(), rect_it->height());
+ for (RectPaintVector::const_iterator it = draw_rects_.begin();
+ it < draw_rects_.end(); ++it) {
+ gfx::Rect rect = it->first;
+ SkPaint paint = it->second;
+ SkRect draw_rect = SkRect::MakeXYWH(
+ rect.x(),
+ rect.y(),
+ rect.width(),
+ rect.height());
canvas->drawRect(draw_rect, paint);
}
}
diff --git a/cc/test/fake_content_layer_client.h b/cc/test/fake_content_layer_client.h
index 462fa47..e987b11 100644
--- a/cc/test/fake_content_layer_client.h
+++ b/cc/test/fake_content_layer_client.h
@@ -5,10 +5,12 @@
#ifndef CC_TEST_FAKE_CONTENT_LAYER_CLIENT_H_
#define CC_TEST_FAKE_CONTENT_LAYER_CLIENT_H_
+#include <utility>
#include <vector>
#include "base/compiler_specific.h"
#include "cc/layers/content_layer_client.h"
+#include "third_party/skia/include/core/SkPaint.h"
#include "ui/gfx/rect.h"
namespace cc {
@@ -25,13 +27,15 @@ class FakeContentLayerClient : public cc::ContentLayerClient {
void set_paint_all_opaque(bool opaque) { paint_all_opaque_ = opaque; }
- void add_draw_rect(const gfx::Rect& rect) { draw_rects_.push_back(rect); }
+ void add_draw_rect(const gfx::Rect& rect, const SkPaint& paint) {
+ draw_rects_.push_back(std::make_pair(rect, paint));
+ }
private:
- typedef std::vector<gfx::Rect> RectVector;
+ typedef std::vector<std::pair<gfx::Rect, SkPaint> > RectPaintVector;
bool paint_all_opaque_;
- RectVector draw_rects_;
+ RectPaintVector draw_rects_;
};
} // namespace cc
diff --git a/cc/test/fake_picture_pile_impl.cc b/cc/test/fake_picture_pile_impl.cc
new file mode 100644
index 0000000..70d0a8d
--- /dev/null
+++ b/cc/test/fake_picture_pile_impl.cc
@@ -0,0 +1,76 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "cc/test/fake_picture_pile_impl.h"
+
+#include <utility>
+
+#include "cc/test/impl_side_painting_settings.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace cc {
+
+FakePicturePileImpl::FakePicturePileImpl()
+ : PicturePileImpl(false) {}
+
+FakePicturePileImpl::~FakePicturePileImpl() {}
+
+scoped_refptr<FakePicturePileImpl> FakePicturePileImpl::CreateFilledPile(
+ gfx::Size tile_size,
+ gfx::Size layer_bounds) {
+ scoped_refptr<FakePicturePileImpl> pile(new FakePicturePileImpl());
+ pile->tiling().SetTotalSize(layer_bounds);
+ pile->tiling().SetMaxTextureSize(tile_size);
+ pile->SetTileGridSize(ImplSidePaintingSettings().default_tile_size);
+ for (int x = 0; x < pile->tiling().num_tiles_x(); ++x) {
+ for (int y = 0; y < pile->tiling().num_tiles_y(); ++y)
+ pile->AddRecordingAt(x, y);
+ }
+ pile->UpdateRecordedRegion();
+ return pile;
+}
+
+scoped_refptr<FakePicturePileImpl> FakePicturePileImpl::CreateEmptyPile(
+ gfx::Size tile_size,
+ gfx::Size layer_bounds) {
+ scoped_refptr<FakePicturePileImpl> pile(new FakePicturePileImpl());
+ pile->tiling().SetTotalSize(layer_bounds);
+ pile->tiling().SetMaxTextureSize(tile_size);
+ pile->SetTileGridSize(ImplSidePaintingSettings().default_tile_size);
+ pile->UpdateRecordedRegion();
+ return pile;
+}
+
+void FakePicturePileImpl::AddRecordingAt(int x, int y) {
+ EXPECT_GE(x, 0);
+ EXPECT_GE(y, 0);
+ EXPECT_LT(x, tiling_.num_tiles_x());
+ EXPECT_LT(y, tiling_.num_tiles_y());
+
+ if (HasRecordingAt(x, y))
+ return;
+ gfx::Rect bounds(tiling().TileBounds(x, y));
+ scoped_refptr<Picture> picture(Picture::Create(bounds));
+ picture->Record(&client_, NULL, tile_grid_info_);
+ picture_list_map_[std::pair<int, int>(x, y)].push_back(picture);
+ EXPECT_TRUE(HasRecordingAt(x, y));
+
+ UpdateRecordedRegion();
+}
+
+void FakePicturePileImpl::RemoveRecordingAt(int x, int y) {
+ EXPECT_GE(x, 0);
+ EXPECT_GE(y, 0);
+ EXPECT_LT(x, tiling_.num_tiles_x());
+ EXPECT_LT(y, tiling_.num_tiles_y());
+
+ if (!HasRecordingAt(x, y))
+ return;
+ picture_list_map_.erase(std::pair<int, int>(x, y));
+ EXPECT_FALSE(HasRecordingAt(x, y));
+
+ UpdateRecordedRegion();
+}
+
+} // namespace cc
diff --git a/cc/test/fake_picture_pile_impl.h b/cc/test/fake_picture_pile_impl.h
new file mode 100644
index 0000000..f3bde7b
--- /dev/null
+++ b/cc/test/fake_picture_pile_impl.h
@@ -0,0 +1,52 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CC_TEST_FAKE_PICTURE_PILE_IMPL_H_
+#define CC_TEST_FAKE_PICTURE_PILE_IMPL_H_
+
+#include "base/memory/ref_counted.h"
+#include "cc/resources/picture_pile_impl.h"
+#include "cc/test/fake_content_layer_client.h"
+
+namespace cc {
+
+class FakePicturePileImpl : public PicturePileImpl {
+ public:
+ static scoped_refptr<FakePicturePileImpl> CreateFilledPile(
+ gfx::Size tile_size,
+ gfx::Size layer_bounds);
+
+ static scoped_refptr<FakePicturePileImpl> CreateEmptyPile(
+ gfx::Size tile_size,
+ gfx::Size layer_bounds);
+
+ TilingData& tiling() { return tiling_; }
+
+ void AddRecordingAt(int x, int y);
+
+ void RemoveRecordingAt(int x, int y);
+
+ void add_draw_rect(const gfx::Rect& rect) {
+ client_.add_draw_rect(rect, default_paint_);
+ }
+
+ void add_draw_rect_with_paint(gfx::Rect rect, const SkPaint& paint) {
+ client_.add_draw_rect(rect, paint);
+ }
+
+ void set_default_paint(const SkPaint& paint) {
+ default_paint_ = paint;
+ }
+
+ protected:
+ FakePicturePileImpl();
+ virtual ~FakePicturePileImpl();
+
+ FakeContentLayerClient client_;
+ SkPaint default_paint_;
+};
+
+} // namespace cc
+
+#endif // CC_TEST_FAKE_PICTURE_PILE_IMPL_H_