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