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 |