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

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: review fixes. 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 7e43aed6296592fe1f20e024c30f328f3f8d601e..3f4ce6b1fc4add1b87eca6a65e00223d192850a8 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"
@@ -2250,5 +2252,73 @@ TEST(LayerTreeHostTest, PartialUpdatesWithDelegatingRendererAndSoftwareContent)
EXPECT_EQ(0u, host->settings().maxPartialTextureUpdates);
}
+class LayerTreeHostTestCapturePicturePile : public LayerTreeHostTest {
enne (OOO) 2013/01/03 23:55:30 Great! Thanks for the test. :)
Leandro Graciá Gil 2013/01/04 00:41:23 Np, thanks for your help to create and fix it.
+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();
+ 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;
+};
+
+TEST_F(LayerTreeHostTestCapturePicturePile, runMultiThread)
enne (OOO) 2013/01/03 23:55:30 This whole block can just be MULTI_THREAD_TEST_F(
Leandro Graciá Gil 2013/01/04 00:41:23 Done.
+{
+ runTest(true);
+}
+
} // namespace
} // namespace cc

Powered by Google App Engine
This is Rietveld 408576698