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 #include "cc/gl_renderer.h" | 6 #include "cc/gl_renderer.h" |
7 | 7 |
8 #include "cc/draw_quad.h" | 8 #include "cc/draw_quad.h" |
9 #include "cc/prioritized_texture_manager.h" | 9 #include "cc/prioritized_texture_manager.h" |
10 #include "cc/resource_provider.h" | 10 #include "cc/resource_provider.h" |
11 #include "cc/settings.h" | 11 #include "cc/settings.h" |
| 12 #include "cc/single_thread_proxy.h" |
12 #include "cc/test/fake_web_compositor_output_surface.h" | 13 #include "cc/test/fake_web_compositor_output_surface.h" |
13 #include "cc/test/fake_web_graphics_context_3d.h" | 14 #include "cc/test/fake_web_graphics_context_3d.h" |
14 #include "cc/test/test_common.h" | 15 #include "cc/test/test_common.h" |
15 #include "testing/gmock/include/gmock/gmock.h" | 16 #include "testing/gmock/include/gmock/gmock.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
17 #include "third_party/khronos/GLES2/gl2.h" | 18 #include "third_party/khronos/GLES2/gl2.h" |
18 #include <public/WebTransformationMatrix.h> | 19 #include <public/WebTransformationMatrix.h> |
19 | 20 |
20 using namespace cc; | 21 using namespace cc; |
21 using namespace WebKit; | 22 using namespace WebKit; |
(...skipping 12 matching lines...) Expand all Loading... |
34 { | 35 { |
35 if (name == GL_EXTENSIONS) | 36 if (name == GL_EXTENSIONS) |
36 return WebString("GL_CHROMIUM_set_visibility GL_CHROMIUM_gpu_memory_
manager GL_CHROMIUM_discard_framebuffer"); | 37 return WebString("GL_CHROMIUM_set_visibility GL_CHROMIUM_gpu_memory_
manager GL_CHROMIUM_discard_framebuffer"); |
37 return WebString(); | 38 return WebString(); |
38 } | 39 } |
39 | 40 |
40 // Methods added for test. | 41 // Methods added for test. |
41 int frameCount() { return m_frame; } | 42 int frameCount() { return m_frame; } |
42 void setMemoryAllocation(WebGraphicsMemoryAllocation allocation) | 43 void setMemoryAllocation(WebGraphicsMemoryAllocation allocation) |
43 { | 44 { |
| 45 DCHECK(Proxy::isImplThread()); |
| 46 // In single threaded mode we expect this callback on main thread. |
| 47 DebugScopedSetMainThread main; |
44 m_memoryAllocationChangedCallback->onMemoryAllocationChanged(allocation)
; | 48 m_memoryAllocationChangedCallback->onMemoryAllocationChanged(allocation)
; |
45 } | 49 } |
46 | 50 |
47 private: | 51 private: |
48 int m_frame; | 52 int m_frame; |
49 WebGraphicsMemoryAllocationChangedCallbackCHROMIUM* m_memoryAllocationChange
dCallback; | 53 WebGraphicsMemoryAllocationChangedCallbackCHROMIUM* m_memoryAllocationChange
dCallback; |
50 }; | 54 }; |
51 | 55 |
52 class FakeRendererClient : public RendererClient { | 56 class FakeRendererClient : public RendererClient { |
53 public: | 57 public: |
(...skipping 11 matching lines...) Expand all Loading... |
65 } | 69 } |
66 | 70 |
67 // RendererClient methods. | 71 // RendererClient methods. |
68 virtual const gfx::Size& deviceViewportSize() const OVERRIDE { static gfx::S
ize fakeSize(1, 1); return fakeSize; } | 72 virtual const gfx::Size& deviceViewportSize() const OVERRIDE { static gfx::S
ize fakeSize(1, 1); return fakeSize; } |
69 virtual const LayerTreeSettings& settings() const OVERRIDE { static LayerTre
eSettings fakeSettings; return fakeSettings; } | 73 virtual const LayerTreeSettings& settings() const OVERRIDE { static LayerTre
eSettings fakeSettings; return fakeSettings; } |
70 virtual void didLoseContext() OVERRIDE { } | 74 virtual void didLoseContext() OVERRIDE { } |
71 virtual void onSwapBuffersComplete() OVERRIDE { } | 75 virtual void onSwapBuffersComplete() OVERRIDE { } |
72 virtual void setFullRootLayerDamage() OVERRIDE { m_setFullRootLayerDamageCou
nt++; } | 76 virtual void setFullRootLayerDamage() OVERRIDE { m_setFullRootLayerDamageCou
nt++; } |
73 virtual void setManagedMemoryPolicy(const ManagedMemoryPolicy& policy) OVERR
IDE { m_memoryAllocationLimitBytes = policy.bytesLimitWhenVisible; } | 77 virtual void setManagedMemoryPolicy(const ManagedMemoryPolicy& policy) OVERR
IDE { m_memoryAllocationLimitBytes = policy.bytesLimitWhenVisible; } |
74 virtual void enforceManagedMemoryPolicy(const ManagedMemoryPolicy& policy) O
VERRIDE { if (m_lastCallWasSetVisibility) *m_lastCallWasSetVisibility = false; } | 78 virtual void enforceManagedMemoryPolicy(const ManagedMemoryPolicy& policy) O
VERRIDE { if (m_lastCallWasSetVisibility) *m_lastCallWasSetVisibility = false; } |
75 virtual bool hasImplThread() const OVERRIDE { return false; } | |
76 | 79 |
77 // Methods added for test. | 80 // Methods added for test. |
78 int setFullRootLayerDamageCount() const { return m_setFullRootLayerDamageCou
nt; } | 81 int setFullRootLayerDamageCount() const { return m_setFullRootLayerDamageCou
nt; } |
79 void setLastCallWasSetVisibilityPointer(bool* lastCallWasSetVisibility) { m_
lastCallWasSetVisibility = lastCallWasSetVisibility; } | 82 void setLastCallWasSetVisibilityPointer(bool* lastCallWasSetVisibility) { m_
lastCallWasSetVisibility = lastCallWasSetVisibility; } |
80 | 83 |
81 RenderPass* rootRenderPass() { return m_renderPassesInDrawOrder.back(); } | 84 RenderPass* rootRenderPass() { return m_renderPassesInDrawOrder.back(); } |
82 const RenderPassList& renderPassesInDrawOrder() const { return m_renderPasse
sInDrawOrder; } | 85 const RenderPassList& renderPassesInDrawOrder() const { return m_renderPasse
sInDrawOrder; } |
83 const RenderPassIdHashMap& renderPasses() const { return m_renderPasses; } | 86 const RenderPassIdHashMap& renderPasses() const { return m_renderPasses; } |
84 | 87 |
85 size_t memoryAllocationLimitBytes() const { return m_memoryAllocationLimitBy
tes; } | 88 size_t memoryAllocationLimitBytes() const { return m_memoryAllocationLimitBy
tes; } |
86 | 89 |
87 private: | 90 private: |
88 int m_setFullRootLayerDamageCount; | 91 int m_setFullRootLayerDamageCount; |
89 bool* m_lastCallWasSetVisibility; | 92 bool* m_lastCallWasSetVisibility; |
| 93 DebugScopedSetImplThread m_implThread; |
90 scoped_ptr<LayerImpl> m_rootLayer; | 94 scoped_ptr<LayerImpl> m_rootLayer; |
91 RenderPassList m_renderPassesInDrawOrder; | 95 RenderPassList m_renderPassesInDrawOrder; |
92 RenderPassIdHashMap m_renderPasses; | 96 RenderPassIdHashMap m_renderPasses; |
93 size_t m_memoryAllocationLimitBytes; | 97 size_t m_memoryAllocationLimitBytes; |
94 }; | 98 }; |
95 | 99 |
96 class FakeRendererGL : public GLRenderer { | 100 class FakeRendererGL : public GLRenderer { |
97 public: | 101 public: |
98 FakeRendererGL(RendererClient* client, ResourceProvider* resourceProvider) :
GLRenderer(client, resourceProvider) { } | 102 FakeRendererGL(RendererClient* client, ResourceProvider* resourceProvider) :
GLRenderer(client, resourceProvider) { } |
99 | 103 |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 // process, after glFlush is called, and after the RendererClient's enforceM
anagedMemoryPolicy | 476 // process, after glFlush is called, and after the RendererClient's enforceM
anagedMemoryPolicy |
473 // is called. Plumb this tracking between both the RenderClient and the Cont
ext by giving | 477 // is called. Plumb this tracking between both the RenderClient and the Cont
ext by giving |
474 // them both a pointer to a variable on the stack. | 478 // them both a pointer to a variable on the stack. |
475 context->setLastCallWasSetVisibilityPointer(&lastCallWasSetVisiblity); | 479 context->setLastCallWasSetVisibilityPointer(&lastCallWasSetVisiblity); |
476 mockClient.setLastCallWasSetVisibilityPointer(&lastCallWasSetVisiblity); | 480 mockClient.setLastCallWasSetVisibilityPointer(&lastCallWasSetVisiblity); |
477 renderer.setVisible(true); | 481 renderer.setVisible(true); |
478 renderer.drawFrame(mockClient.renderPassesInDrawOrder(), mockClient.renderPa
sses()); | 482 renderer.drawFrame(mockClient.renderPassesInDrawOrder(), mockClient.renderPa
sses()); |
479 renderer.setVisible(false); | 483 renderer.setVisible(false); |
480 EXPECT_TRUE(lastCallWasSetVisiblity); | 484 EXPECT_TRUE(lastCallWasSetVisiblity); |
481 } | 485 } |
OLD | NEW |