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 "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "cc/delegated_renderer_layer_impl.h" | 7 #include "cc/delegated_renderer_layer_impl.h" |
8 | 8 |
9 #include "cc/append_quads_data.h" | 9 #include "cc/append_quads_data.h" |
10 #include "cc/layer_tree_host_impl.h" | 10 #include "cc/layer_tree_host_impl.h" |
11 #include "cc/quad_sink.h" | 11 #include "cc/quad_sink.h" |
12 #include "cc/render_pass_draw_quad.h" | 12 #include "cc/render_pass_draw_quad.h" |
13 #include "cc/scoped_ptr_vector.h" | 13 #include "cc/scoped_ptr_vector.h" |
14 #include "cc/single_thread_proxy.h" | 14 #include "cc/single_thread_proxy.h" |
15 #include "cc/solid_color_draw_quad.h" | 15 #include "cc/solid_color_draw_quad.h" |
16 #include "cc/solid_color_layer_impl.h" | 16 #include "cc/solid_color_layer_impl.h" |
17 #include "cc/test/fake_proxy.h" | |
18 #include "cc/test/fake_web_compositor_output_surface.h" | 17 #include "cc/test/fake_web_compositor_output_surface.h" |
19 #include "cc/test/fake_web_graphics_context_3d.h" | 18 #include "cc/test/fake_web_graphics_context_3d.h" |
20 #include "cc/test/geometry_test_utils.h" | 19 #include "cc/test/geometry_test_utils.h" |
21 #include "cc/test/mock_quad_culler.h" | 20 #include "cc/test/mock_quad_culler.h" |
22 #include "cc/test/render_pass_test_common.h" | 21 #include "cc/test/render_pass_test_common.h" |
23 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
24 #include <public/WebTransformationMatrix.h> | 23 #include <public/WebTransformationMatrix.h> |
25 | 24 |
26 using WebKit::FakeWebCompositorOutputSurface; | 25 using WebKit::FakeWebCompositorOutputSurface; |
27 using WebKit::FakeWebGraphicsContext3D; | 26 using WebKit::FakeWebGraphicsContext3D; |
28 using WebKit::WebTransformationMatrix; | 27 using WebKit::WebTransformationMatrix; |
29 | 28 |
30 using namespace cc; | 29 using namespace cc; |
31 using namespace WebKitTests; | 30 using namespace WebKitTests; |
32 | 31 |
33 namespace { | 32 namespace { |
34 | 33 |
35 class DelegatedRendererLayerImplTest : public testing::Test, public LayerTreeHos
tImplClient { | 34 class DelegatedRendererLayerImplTest : public testing::Test, public LayerTreeHos
tImplClient { |
36 public: | 35 public: |
37 DelegatedRendererLayerImplTest() | 36 DelegatedRendererLayerImplTest() |
38 : m_proxy(scoped_ptr<Thread>(NULL)) | |
39 , m_alwaysImplThreadAndMainThreadBlocked(&m_proxy) | |
40 { | 37 { |
41 LayerTreeSettings settings; | 38 LayerTreeSettings settings; |
42 settings.minimumOcclusionTrackingSize = gfx::Size(); | 39 settings.minimumOcclusionTrackingSize = gfx::Size(); |
43 | 40 |
44 m_hostImpl = LayerTreeHostImpl::create(settings, this, &m_proxy); | 41 m_hostImpl = LayerTreeHostImpl::create(settings, this); |
45 m_hostImpl->initializeRenderer(createContext()); | 42 m_hostImpl->initializeRenderer(createContext()); |
46 m_hostImpl->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); | 43 m_hostImpl->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); |
47 } | 44 } |
48 | 45 |
49 // LayerTreeHostImplClient implementation. | 46 // LayerTreeHostImplClient implementation. |
50 virtual void didLoseContextOnImplThread() OVERRIDE { } | 47 virtual void didLoseContextOnImplThread() OVERRIDE { } |
51 virtual void onSwapBuffersCompleteOnImplThread() OVERRIDE { } | 48 virtual void onSwapBuffersCompleteOnImplThread() OVERRIDE { } |
52 virtual void onVSyncParametersChanged(base::TimeTicks, base::TimeDelta) OVER
RIDE { } | 49 virtual void onVSyncParametersChanged(base::TimeTicks, base::TimeDelta) OVER
RIDE { } |
53 virtual void onCanDrawStateChanged(bool) OVERRIDE { } | 50 virtual void onCanDrawStateChanged(bool) OVERRIDE { } |
54 virtual void setNeedsRedrawOnImplThread() OVERRIDE { } | 51 virtual void setNeedsRedrawOnImplThread() OVERRIDE { } |
55 virtual void setNeedsCommitOnImplThread() OVERRIDE { } | 52 virtual void setNeedsCommitOnImplThread() OVERRIDE { } |
56 virtual void postAnimationEventsToMainThreadOnImplThread(scoped_ptr<Animatio
nEventsVector>, base::Time wallClockTime) OVERRIDE { } | 53 virtual void postAnimationEventsToMainThreadOnImplThread(scoped_ptr<Animatio
nEventsVector>, base::Time wallClockTime) OVERRIDE { } |
57 virtual bool reduceContentsTextureMemoryOnImplThread(size_t limitBytes, int
priorityCutoff) OVERRIDE { return true; } | 54 virtual bool reduceContentsTextureMemoryOnImplThread(size_t limitBytes, int
priorityCutoff) OVERRIDE { return true; } |
58 virtual void sendManagedMemoryStats() OVERRIDE { } | 55 virtual void sendManagedMemoryStats() OVERRIDE { } |
59 | 56 |
60 protected: | 57 protected: |
61 scoped_ptr<GraphicsContext> createContext() | 58 scoped_ptr<GraphicsContext> createContext() |
62 { | 59 { |
63 return FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGrap
hicsContext3D>(new FakeWebGraphicsContext3D)).PassAs<GraphicsContext>(); | 60 return FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGrap
hicsContext3D>(new FakeWebGraphicsContext3D)).PassAs<GraphicsContext>(); |
64 } | 61 } |
65 | 62 |
66 FakeProxy m_proxy; | 63 DebugScopedSetImplThread m_alwaysImplThread; |
67 DebugScopedSetImplThreadAndMainThreadBlocked m_alwaysImplThreadAndMainThread
Blocked; | 64 DebugScopedSetMainThreadBlocked m_alwaysMainThreadBlocked; |
| 65 |
68 scoped_ptr<LayerTreeHostImpl> m_hostImpl; | 66 scoped_ptr<LayerTreeHostImpl> m_hostImpl; |
69 }; | 67 }; |
70 | 68 |
71 static TestRenderPass* addRenderPass(ScopedPtrVector<RenderPass>& passList, Rend
erPass::Id id, gfx::Rect outputRect, WebTransformationMatrix rootTransform) | 69 static TestRenderPass* addRenderPass(ScopedPtrVector<RenderPass>& passList, Rend
erPass::Id id, gfx::Rect outputRect, WebTransformationMatrix rootTransform) |
72 { | 70 { |
73 scoped_ptr<TestRenderPass> pass(TestRenderPass::create(id, outputRect, rootT
ransform)); | 71 scoped_ptr<TestRenderPass> pass(TestRenderPass::create(id, outputRect, rootT
ransform)); |
74 TestRenderPass* saved = pass.get(); | 72 TestRenderPass* saved = pass.get(); |
75 passList.append(pass.PassAs<RenderPass>()); | 73 passList.append(pass.PassAs<RenderPass>()); |
76 return saved; | 74 return saved; |
77 } | 75 } |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 EXPECT_EQ(sharedState, quadList[3]->sharedQuadState()); | 446 EXPECT_EQ(sharedState, quadList[3]->sharedQuadState()); |
449 | 447 |
450 // The state should be transformed only once. | 448 // The state should be transformed only once. |
451 EXPECT_RECT_EQ(gfx::Rect(30, 30, 50, 50), sharedState->clippedRectInTarget); | 449 EXPECT_RECT_EQ(gfx::Rect(30, 30, 50, 50), sharedState->clippedRectInTarget); |
452 WebTransformationMatrix expected; | 450 WebTransformationMatrix expected; |
453 expected.translate(30, 30); | 451 expected.translate(30, 30); |
454 EXPECT_TRANSFORMATION_MATRIX_EQ(expected, sharedState->quadTransform); | 452 EXPECT_TRANSFORMATION_MATRIX_EQ(expected, sharedState->quadTransform); |
455 } | 453 } |
456 | 454 |
457 } // namespace | 455 } // namespace |
OLD | NEW |