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

Side by Side 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, 11 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/layer_tree_host.h" 5 #include "cc/layer_tree_host.h"
6 6
7 #include "base/synchronization/lock.h" 7 #include "base/synchronization/lock.h"
8 #include "cc/content_layer.h" 8 #include "cc/content_layer.h"
9 #include "cc/content_layer_client.h" 9 #include "cc/content_layer_client.h"
10 #include "cc/layer_impl.h" 10 #include "cc/layer_impl.h"
11 #include "cc/layer_tree_host_impl.h" 11 #include "cc/layer_tree_host_impl.h"
12 #include "cc/layer_tree_impl.h" 12 #include "cc/layer_tree_impl.h"
13 #include "cc/output_surface.h" 13 #include "cc/output_surface.h"
14 #include "cc/picture_layer.h"
15 #include "cc/picture_pile_impl.h"
14 #include "cc/single_thread_proxy.h" 16 #include "cc/single_thread_proxy.h"
15 #include "cc/test/fake_content_layer.h" 17 #include "cc/test/fake_content_layer.h"
16 #include "cc/test/fake_content_layer_client.h" 18 #include "cc/test/fake_content_layer_client.h"
17 #include "cc/test/fake_layer_tree_host_client.h" 19 #include "cc/test/fake_layer_tree_host_client.h"
18 #include "cc/test/fake_output_surface.h" 20 #include "cc/test/fake_output_surface.h"
19 #include "cc/test/fake_proxy.h" 21 #include "cc/test/fake_proxy.h"
20 #include "cc/test/fake_scrollbar_layer.h" 22 #include "cc/test/fake_scrollbar_layer.h"
21 #include "cc/test/geometry_test_utils.h" 23 #include "cc/test/geometry_test_utils.h"
22 #include "cc/test/layer_tree_test_common.h" 24 #include "cc/test/layer_tree_test_common.h"
23 #include "cc/resource_update_queue.h" 25 #include "cc/resource_update_queue.h"
(...skipping 1987 matching lines...) Expand 10 before | Expand all | Expand 10 after
2011 FakeLayerImplTreeHostClient client(useSoftwareRendering, useDelegatingRender er); 2013 FakeLayerImplTreeHostClient client(useSoftwareRendering, useDelegatingRender er);
2012 2014
2013 LayerTreeSettings settings; 2015 LayerTreeSettings settings;
2014 settings.maxPartialTextureUpdates = 4; 2016 settings.maxPartialTextureUpdates = 4;
2015 2017
2016 scoped_ptr<LayerTreeHost> host = LayerTreeHost::create(&client, settings, sc oped_ptr<Thread>()); 2018 scoped_ptr<LayerTreeHost> host = LayerTreeHost::create(&client, settings, sc oped_ptr<Thread>());
2017 EXPECT_TRUE(host->initializeRendererIfNeeded()); 2019 EXPECT_TRUE(host->initializeRendererIfNeeded());
2018 EXPECT_EQ(0u, host->settings().maxPartialTextureUpdates); 2020 EXPECT_EQ(0u, host->settings().maxPartialTextureUpdates);
2019 } 2021 }
2020 2022
2023 class LayerTreeHostTestCapturePicturePile : public LayerTreeHostTest {
2024 public:
2025 LayerTreeHostTestCapturePicturePile()
2026 : m_bounds(gfx::Size(100, 100))
2027 , m_layer(PictureLayer::create(&m_contentClient))
2028 {
2029 m_settings.implSidePainting = true;
2030 }
2031
2032 class FillRectContentLayerClient : public ContentLayerClient {
2033 public:
2034 virtual void paintContents(SkCanvas* canvas, const gfx::Rect& clip, gfx: :RectF& opaque) OVERRIDE
2035 {
2036 SkPaint paint;
2037 paint.setColor(SK_ColorGREEN);
2038
2039 SkRect rect = SkRect::MakeWH(canvas->getDeviceSize().width(), canvas ->getDeviceSize().height());
2040 opaque = gfx::RectF(rect.width(), rect.height());
2041 canvas->drawRect(rect, paint);
2042 }
2043 };
2044
2045 virtual void beginTest() OVERRIDE
2046 {
2047 m_layer->setIsDrawable(true);
2048 m_layer->setBounds(m_bounds);
2049 m_layerTreeHost->setViewportSize(m_bounds, m_bounds);
2050 m_layerTreeHost->setRootLayer(m_layer);
2051
2052 EXPECT_TRUE(m_layerTreeHost->initializeRendererIfNeeded());
2053 postSetNeedsCommitToMainThread();
2054 }
2055
2056 virtual void didCommitAndDrawFrame() OVERRIDE
2057 {
2058 m_picturePile = m_layerTreeHost->capturePicturePile();
2059 EXPECT_EQ(gfx::Rect(m_bounds), m_picturePile->LayerRect());
2060 endTest();
2061 }
2062
2063 virtual void afterTest() OVERRIDE
2064 {
2065 SkBitmap bitmap;
2066 bitmap.setConfig(SkBitmap::kARGB_8888_Config, m_bounds.width(), m_bounds .height());
2067 bitmap.allocPixels();
2068 bitmap.eraseARGB(0, 0, 0, 0);
2069 SkCanvas canvas(bitmap);
2070
2071 RenderingStats stats;
2072 m_picturePile->Raster(&canvas, gfx::Rect(m_bounds), 1.0, &stats);
2073
2074 bitmap.lockPixels();
2075 SkColor* pixels = reinterpret_cast<SkColor*>(bitmap.getPixels());
2076 EXPECT_EQ(SK_ColorGREEN, pixels[0]);
2077 bitmap.unlockPixels();
2078 }
2079
2080 private:
2081 gfx::Size m_bounds;
2082 FillRectContentLayerClient m_contentClient;
2083 scoped_refptr<PictureLayer> m_layer;
2084 scoped_refptr<PicturePileImpl> m_picturePile;
2085 };
2086
2087 MULTI_THREAD_TEST_F(LayerTreeHostTestCapturePicturePile);
2088
2021 } // namespace 2089 } // namespace
2022 } // namespace cc 2090 } // namespace cc
OLDNEW
« 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