Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Unified Diff: cc/layer_tree_host_unittest.cc

Issue 11731002: Implement a method to access the non-composited content root layer picture pile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix windows bots. Created 7 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: cc/layer_tree_host_unittest.cc
diff --git a/cc/layer_tree_host_unittest.cc b/cc/layer_tree_host_unittest.cc
index dd7bb1d973b80058eaef6a6a0dcb2e6d6e012e27..1e5e76e44b11781010aac5ebe02ef23ed69152e0 100644
--- a/cc/layer_tree_host_unittest.cc
+++ b/cc/layer_tree_host_unittest.cc
@@ -11,6 +11,8 @@
#include "cc/layer_tree_host_impl.h"
#include "cc/layer_tree_impl.h"
#include "cc/output_surface.h"
+#include "cc/picture_layer.h"
+#include "cc/picture_pile_impl.h"
#include "cc/single_thread_proxy.h"
#include "cc/test/fake_content_layer.h"
#include "cc/test/fake_content_layer_client.h"
@@ -2018,5 +2020,71 @@ TEST(LayerTreeHostTest, PartialUpdatesWithDelegatingRendererAndSoftwareContent)
EXPECT_EQ(0u, host->settings().maxPartialTextureUpdates);
}
+class LayerTreeHostTestCapturePicturePile : public LayerTreeHostTest {
+public:
+ LayerTreeHostTestCapturePicturePile()
+ : m_bounds(gfx::Size(100, 100))
+ , m_layer(PictureLayer::create(&m_contentClient))
+ {
+ m_settings.implSidePainting = true;
+ }
+
+ class FillRectContentLayerClient : public ContentLayerClient {
+ public:
+ virtual void paintContents(SkCanvas* canvas, const gfx::Rect& clip, gfx::RectF& opaque) OVERRIDE
+ {
+ SkPaint paint;
+ paint.setColor(SK_ColorGREEN);
+
+ SkRect rect = SkRect::MakeWH(canvas->getDeviceSize().width(), canvas->getDeviceSize().height());
+ opaque = gfx::RectF(rect.width(), rect.height());
+ canvas->drawRect(rect, paint);
+ }
+ };
+
+ virtual void beginTest() OVERRIDE
+ {
+ m_layer->setIsDrawable(true);
+ m_layer->setBounds(m_bounds);
+ m_layerTreeHost->setViewportSize(m_bounds, m_bounds);
+ m_layerTreeHost->setRootLayer(m_layer);
+
+ EXPECT_TRUE(m_layerTreeHost->initializeRendererIfNeeded());
+ postSetNeedsCommitToMainThread();
+ }
+
+ virtual void didCommitAndDrawFrame() OVERRIDE
+ {
+ m_picturePile = m_layerTreeHost->capturePicturePile();
+ EXPECT_EQ(gfx::Rect(m_bounds), m_picturePile->LayerRect());
+ endTest();
+ }
+
+ virtual void afterTest() OVERRIDE
+ {
+ SkBitmap bitmap;
+ bitmap.setConfig(SkBitmap::kARGB_8888_Config, m_bounds.width(), m_bounds.height());
+ bitmap.allocPixels();
+ bitmap.eraseARGB(0, 0, 0, 0);
+ SkCanvas canvas(bitmap);
+
+ RenderingStats stats;
+ m_picturePile->Raster(&canvas, gfx::Rect(m_bounds), 1.0, &stats);
+
+ bitmap.lockPixels();
+ SkColor* pixels = reinterpret_cast<SkColor*>(bitmap.getPixels());
+ EXPECT_EQ(SK_ColorGREEN, pixels[0]);
+ bitmap.unlockPixels();
+ }
+
+private:
+ gfx::Size m_bounds;
+ FillRectContentLayerClient m_contentClient;
+ scoped_refptr<PictureLayer> m_layer;
+ scoped_refptr<PicturePileImpl> m_picturePile;
+};
+
+MULTI_THREAD_TEST_F(LayerTreeHostTestCapturePicturePile);
+
} // namespace
} // namespace cc
« cc/layer_tree_host_impl.cc ('K') | « cc/layer_tree_host_impl.cc ('k') | cc/picture.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698