OLD | NEW |
---|---|
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 2219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2243 FakeLayerImplTreeHostClient client(useSoftwareRendering, useDelegatingRender er); | 2245 FakeLayerImplTreeHostClient client(useSoftwareRendering, useDelegatingRender er); |
2244 | 2246 |
2245 LayerTreeSettings settings; | 2247 LayerTreeSettings settings; |
2246 settings.maxPartialTextureUpdates = 4; | 2248 settings.maxPartialTextureUpdates = 4; |
2247 | 2249 |
2248 scoped_ptr<LayerTreeHost> host = LayerTreeHost::create(&client, settings, sc oped_ptr<Thread>()); | 2250 scoped_ptr<LayerTreeHost> host = LayerTreeHost::create(&client, settings, sc oped_ptr<Thread>()); |
2249 EXPECT_TRUE(host->initializeRendererIfNeeded()); | 2251 EXPECT_TRUE(host->initializeRendererIfNeeded()); |
2250 EXPECT_EQ(0u, host->settings().maxPartialTextureUpdates); | 2252 EXPECT_EQ(0u, host->settings().maxPartialTextureUpdates); |
2251 } | 2253 } |
2252 | 2254 |
2255 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.
| |
2256 public: | |
2257 LayerTreeHostTestCapturePicturePile() | |
2258 : m_bounds(gfx::Size(100, 100)) | |
2259 , m_layer(PictureLayer::create(&m_contentClient)) | |
2260 { | |
2261 m_settings.implSidePainting = true; | |
2262 } | |
2263 | |
2264 class FillRectContentLayerClient : public ContentLayerClient { | |
2265 public: | |
2266 virtual void paintContents(SkCanvas* canvas, const gfx::Rect& clip, gfx: :RectF& opaque) OVERRIDE | |
2267 { | |
2268 SkPaint paint; | |
2269 paint.setColor(SK_ColorGREEN); | |
2270 | |
2271 SkRect rect = SkRect::MakeWH(canvas->getDeviceSize().width(), canvas ->getDeviceSize().height()); | |
2272 opaque = gfx::RectF(rect.width(), rect.height()); | |
2273 canvas->drawRect(rect, paint); | |
2274 } | |
2275 }; | |
2276 | |
2277 virtual void beginTest() OVERRIDE | |
2278 { | |
2279 m_layer->setIsDrawable(true); | |
2280 m_layer->setBounds(m_bounds); | |
2281 m_layerTreeHost->setViewportSize(m_bounds, m_bounds); | |
2282 m_layerTreeHost->setRootLayer(m_layer); | |
2283 | |
2284 EXPECT_TRUE(m_layerTreeHost->initializeRendererIfNeeded()); | |
2285 postSetNeedsCommitToMainThread(); | |
2286 } | |
2287 | |
2288 virtual void didCommitAndDrawFrame() OVERRIDE | |
2289 { | |
2290 m_picturePile = m_layerTreeHost->capturePicturePile(); | |
2291 endTest(); | |
2292 } | |
2293 | |
2294 virtual void afterTest() OVERRIDE | |
2295 { | |
2296 SkBitmap bitmap; | |
2297 bitmap.setConfig(SkBitmap::kARGB_8888_Config, m_bounds.width(), m_bounds .height()); | |
2298 bitmap.allocPixels(); | |
2299 bitmap.eraseARGB(0, 0, 0, 0); | |
2300 SkCanvas canvas(bitmap); | |
2301 | |
2302 RenderingStats stats; | |
2303 m_picturePile->Raster(&canvas, gfx::Rect(m_bounds), 1.0, &stats); | |
2304 | |
2305 bitmap.lockPixels(); | |
2306 SkColor* pixels = reinterpret_cast<SkColor*>(bitmap.getPixels()); | |
2307 EXPECT_EQ(SK_ColorGREEN, pixels[0]); | |
2308 bitmap.unlockPixels(); | |
2309 } | |
2310 | |
2311 private: | |
2312 gfx::Size m_bounds; | |
2313 FillRectContentLayerClient m_contentClient; | |
2314 scoped_refptr<PictureLayer> m_layer; | |
2315 scoped_refptr<PicturePileImpl> m_picturePile; | |
2316 }; | |
2317 | |
2318 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.
| |
2319 { | |
2320 runTest(true); | |
2321 } | |
2322 | |
2253 } // namespace | 2323 } // namespace |
2254 } // namespace cc | 2324 } // namespace cc |
OLD | NEW |