OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/delegated_renderer_layer_impl.h" | 5 #include "cc/delegated_renderer_layer_impl.h" |
6 | 6 |
7 #include "cc/append_quads_data.h" | 7 #include "cc/append_quads_data.h" |
8 #include "cc/layer_tree_host_impl.h" | 8 #include "cc/layer_tree_host_impl.h" |
9 #include "cc/quad_sink.h" | 9 #include "cc/quad_sink.h" |
10 #include "cc/render_pass_draw_quad.h" | 10 #include "cc/render_pass_draw_quad.h" |
11 #include "cc/scoped_ptr_vector.h" | 11 #include "cc/scoped_ptr_vector.h" |
12 #include "cc/single_thread_proxy.h" | 12 #include "cc/single_thread_proxy.h" |
13 #include "cc/solid_color_draw_quad.h" | 13 #include "cc/solid_color_draw_quad.h" |
14 #include "cc/solid_color_layer_impl.h" | 14 #include "cc/solid_color_layer_impl.h" |
| 15 #include "cc/test/fake_output_surface.h" |
15 #include "cc/test/fake_proxy.h" | 16 #include "cc/test/fake_proxy.h" |
16 #include "cc/test/fake_web_compositor_output_surface.h" | 17 #include "cc/test/fake_web_compositor_output_surface.h" |
17 #include "cc/test/fake_web_graphics_context_3d.h" | 18 #include "cc/test/fake_web_graphics_context_3d.h" |
18 #include "cc/test/geometry_test_utils.h" | 19 #include "cc/test/geometry_test_utils.h" |
19 #include "cc/test/mock_quad_culler.h" | 20 #include "cc/test/mock_quad_culler.h" |
20 #include "cc/test/render_pass_test_common.h" | 21 #include "cc/test/render_pass_test_common.h" |
21 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
22 #include "ui/gfx/transform.h" | 23 #include "ui/gfx/transform.h" |
23 | 24 |
24 using WebKit::FakeWebCompositorOutputSurface; | 25 using WebKit::FakeWebCompositorOutputSurface; |
25 using WebKit::FakeWebGraphicsContext3D; | 26 using WebKit::FakeWebGraphicsContext3D; |
26 | 27 |
27 using namespace WebKitTests; | 28 using namespace WebKitTests; |
28 | 29 |
29 namespace cc { | 30 namespace cc { |
30 namespace { | 31 namespace { |
31 | 32 |
32 class DelegatedRendererLayerImplTest : public testing::Test, public LayerTreeHos
tImplClient { | 33 class DelegatedRendererLayerImplTest : public testing::Test, public LayerTreeHos
tImplClient { |
33 public: | 34 public: |
34 DelegatedRendererLayerImplTest() | 35 DelegatedRendererLayerImplTest() |
35 : m_proxy(scoped_ptr<Thread>(NULL)) | 36 : m_proxy(scoped_ptr<Thread>(NULL)) |
36 , m_alwaysImplThreadAndMainThreadBlocked(&m_proxy) | 37 , m_alwaysImplThreadAndMainThreadBlocked(&m_proxy) |
37 { | 38 { |
38 LayerTreeSettings settings; | 39 LayerTreeSettings settings; |
39 settings.minimumOcclusionTrackingSize = gfx::Size(); | 40 settings.minimumOcclusionTrackingSize = gfx::Size(); |
40 | 41 |
41 m_hostImpl = LayerTreeHostImpl::create(settings, this, &m_proxy); | 42 m_hostImpl = LayerTreeHostImpl::create(settings, this, &m_proxy); |
42 m_hostImpl->initializeRenderer(createContext()); | 43 m_hostImpl->initializeRenderer(createFakeOutputSurface()); |
43 m_hostImpl->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); | 44 m_hostImpl->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); |
44 } | 45 } |
45 | 46 |
46 // LayerTreeHostImplClient implementation. | 47 // LayerTreeHostImplClient implementation. |
47 virtual void didLoseContextOnImplThread() OVERRIDE { } | 48 virtual void didLoseOutputSurfaceOnImplThread() OVERRIDE { } |
48 virtual void onSwapBuffersCompleteOnImplThread() OVERRIDE { } | 49 virtual void onSwapBuffersCompleteOnImplThread() OVERRIDE { } |
49 virtual void onVSyncParametersChanged(base::TimeTicks, base::TimeDelta) OVER
RIDE { } | 50 virtual void onVSyncParametersChanged(base::TimeTicks, base::TimeDelta) OVER
RIDE { } |
50 virtual void onCanDrawStateChanged(bool) OVERRIDE { } | 51 virtual void onCanDrawStateChanged(bool) OVERRIDE { } |
51 virtual void setNeedsRedrawOnImplThread() OVERRIDE { } | 52 virtual void setNeedsRedrawOnImplThread() OVERRIDE { } |
52 virtual void setNeedsCommitOnImplThread() OVERRIDE { } | 53 virtual void setNeedsCommitOnImplThread() OVERRIDE { } |
53 virtual void setNeedsManageTilesOnImplThread() OVERRIDE { } | 54 virtual void setNeedsManageTilesOnImplThread() OVERRIDE { } |
54 virtual void postAnimationEventsToMainThreadOnImplThread(scoped_ptr<Animatio
nEventsVector>, base::Time wallClockTime) OVERRIDE { } | 55 virtual void postAnimationEventsToMainThreadOnImplThread(scoped_ptr<Animatio
nEventsVector>, base::Time wallClockTime) OVERRIDE { } |
55 virtual bool reduceContentsTextureMemoryOnImplThread(size_t limitBytes, int
priorityCutoff) OVERRIDE { return true; } | 56 virtual bool reduceContentsTextureMemoryOnImplThread(size_t limitBytes, int
priorityCutoff) OVERRIDE { return true; } |
56 virtual void sendManagedMemoryStats() OVERRIDE { } | 57 virtual void sendManagedMemoryStats() OVERRIDE { } |
57 | 58 |
58 protected: | 59 protected: |
59 scoped_ptr<GraphicsContext> createContext() | |
60 { | |
61 return FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGrap
hicsContext3D>(new FakeWebGraphicsContext3D)).PassAs<GraphicsContext>(); | |
62 } | |
63 | |
64 FakeProxy m_proxy; | 60 FakeProxy m_proxy; |
65 DebugScopedSetImplThreadAndMainThreadBlocked m_alwaysImplThreadAndMainThread
Blocked; | 61 DebugScopedSetImplThreadAndMainThreadBlocked m_alwaysImplThreadAndMainThread
Blocked; |
66 scoped_ptr<LayerTreeHostImpl> m_hostImpl; | 62 scoped_ptr<LayerTreeHostImpl> m_hostImpl; |
67 }; | 63 }; |
68 | 64 |
69 static TestRenderPass* addRenderPass(ScopedPtrVector<RenderPass>& passList, Rend
erPass::Id id, gfx::Rect outputRect, gfx::Transform rootTransform) | 65 static TestRenderPass* addRenderPass(ScopedPtrVector<RenderPass>& passList, Rend
erPass::Id id, gfx::Rect outputRect, gfx::Transform rootTransform) |
70 { | 66 { |
71 scoped_ptr<TestRenderPass> pass(TestRenderPass::Create()); | 67 scoped_ptr<TestRenderPass> pass(TestRenderPass::Create()); |
72 pass->SetNew(id, outputRect, outputRect, rootTransform); | 68 pass->SetNew(id, outputRect, outputRect, rootTransform); |
73 TestRenderPass* saved = pass.get(); | 69 TestRenderPass* saved = pass.get(); |
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 gfx::Transform expected; | 501 gfx::Transform expected; |
506 expected.Translate(30, 30); | 502 expected.Translate(30, 30); |
507 EXPECT_TRANSFORMATION_MATRIX_EQ(expected, sharedState->content_to_target_tra
nsform); | 503 EXPECT_TRANSFORMATION_MATRIX_EQ(expected, sharedState->content_to_target_tra
nsform); |
508 | 504 |
509 m_hostImpl->drawLayers(frame); | 505 m_hostImpl->drawLayers(frame); |
510 m_hostImpl->didDrawAllLayers(frame); | 506 m_hostImpl->didDrawAllLayers(frame); |
511 } | 507 } |
512 | 508 |
513 } // namespace | 509 } // namespace |
514 } // namespace cc | 510 } // namespace cc |
OLD | NEW |