Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Side by Side Diff: cc/gl_renderer_unittest.cc

Issue 11232051: Remove static thread pointers from CC (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Apply code review comments Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/gl_renderer.cc ('k') | cc/layer_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_resource_manager.h" 9 #include "cc/prioritized_resource_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 14 matching lines...) Expand all
37 { 36 {
38 if (name == GL_EXTENSIONS) 37 if (name == GL_EXTENSIONS)
39 return WebString("GL_CHROMIUM_set_visibility GL_CHROMIUM_gpu_memory_ manager GL_CHROMIUM_discard_framebuffer"); 38 return WebString("GL_CHROMIUM_set_visibility GL_CHROMIUM_gpu_memory_ manager GL_CHROMIUM_discard_framebuffer");
40 return WebString(); 39 return WebString();
41 } 40 }
42 41
43 // Methods added for test. 42 // Methods added for test.
44 int frameCount() { return m_frame; } 43 int frameCount() { return m_frame; }
45 void setMemoryAllocation(WebGraphicsMemoryAllocation allocation) 44 void setMemoryAllocation(WebGraphicsMemoryAllocation allocation)
46 { 45 {
47 DCHECK(Proxy::isImplThread());
48 // In single threaded mode we expect this callback on main thread.
49 DebugScopedSetMainThread main;
50 m_memoryAllocationChangedCallback->onMemoryAllocationChanged(allocation) ; 46 m_memoryAllocationChangedCallback->onMemoryAllocationChanged(allocation) ;
51 } 47 }
52 48
53 private: 49 private:
54 int m_frame; 50 int m_frame;
55 WebGraphicsMemoryAllocationChangedCallbackCHROMIUM* m_memoryAllocationChange dCallback; 51 WebGraphicsMemoryAllocationChangedCallbackCHROMIUM* m_memoryAllocationChange dCallback;
56 }; 52 };
57 53
58 class FakeRendererClient : public RendererClient { 54 class FakeRendererClient : public RendererClient {
59 public: 55 public:
(...skipping 11 matching lines...) Expand all
71 } 67 }
72 68
73 // RendererClient methods. 69 // RendererClient methods.
74 virtual const gfx::Size& deviceViewportSize() const OVERRIDE { static gfx::S ize fakeSize(1, 1); return fakeSize; } 70 virtual const gfx::Size& deviceViewportSize() const OVERRIDE { static gfx::S ize fakeSize(1, 1); return fakeSize; }
75 virtual const LayerTreeSettings& settings() const OVERRIDE { static LayerTre eSettings fakeSettings; return fakeSettings; } 71 virtual const LayerTreeSettings& settings() const OVERRIDE { static LayerTre eSettings fakeSettings; return fakeSettings; }
76 virtual void didLoseContext() OVERRIDE { } 72 virtual void didLoseContext() OVERRIDE { }
77 virtual void onSwapBuffersComplete() OVERRIDE { } 73 virtual void onSwapBuffersComplete() OVERRIDE { }
78 virtual void setFullRootLayerDamage() OVERRIDE { m_setFullRootLayerDamageCou nt++; } 74 virtual void setFullRootLayerDamage() OVERRIDE { m_setFullRootLayerDamageCou nt++; }
79 virtual void setManagedMemoryPolicy(const ManagedMemoryPolicy& policy) OVERR IDE { m_memoryAllocationLimitBytes = policy.bytesLimitWhenVisible; } 75 virtual void setManagedMemoryPolicy(const ManagedMemoryPolicy& policy) OVERR IDE { m_memoryAllocationLimitBytes = policy.bytesLimitWhenVisible; }
80 virtual void enforceManagedMemoryPolicy(const ManagedMemoryPolicy& policy) O VERRIDE { if (m_lastCallWasSetVisibility) *m_lastCallWasSetVisibility = false; } 76 virtual void enforceManagedMemoryPolicy(const ManagedMemoryPolicy& policy) O VERRIDE { if (m_lastCallWasSetVisibility) *m_lastCallWasSetVisibility = false; }
77 virtual bool hasImplThread() const OVERRIDE { return false; }
81 78
82 // Methods added for test. 79 // Methods added for test.
83 int setFullRootLayerDamageCount() const { return m_setFullRootLayerDamageCou nt; } 80 int setFullRootLayerDamageCount() const { return m_setFullRootLayerDamageCou nt; }
84 void setLastCallWasSetVisibilityPointer(bool* lastCallWasSetVisibility) { m_ lastCallWasSetVisibility = lastCallWasSetVisibility; } 81 void setLastCallWasSetVisibilityPointer(bool* lastCallWasSetVisibility) { m_ lastCallWasSetVisibility = lastCallWasSetVisibility; }
85 82
86 RenderPass* rootRenderPass() { return m_renderPassesInDrawOrder.back(); } 83 RenderPass* rootRenderPass() { return m_renderPassesInDrawOrder.back(); }
87 const RenderPassList& renderPassesInDrawOrder() const { return m_renderPasse sInDrawOrder; } 84 const RenderPassList& renderPassesInDrawOrder() const { return m_renderPasse sInDrawOrder; }
88 const RenderPassIdHashMap& renderPasses() const { return m_renderPasses; } 85 const RenderPassIdHashMap& renderPasses() const { return m_renderPasses; }
89 86
90 size_t memoryAllocationLimitBytes() const { return m_memoryAllocationLimitBy tes; } 87 size_t memoryAllocationLimitBytes() const { return m_memoryAllocationLimitBy tes; }
91 88
92 private: 89 private:
93 int m_setFullRootLayerDamageCount; 90 int m_setFullRootLayerDamageCount;
94 bool* m_lastCallWasSetVisibility; 91 bool* m_lastCallWasSetVisibility;
95 DebugScopedSetImplThread m_implThread;
96 scoped_ptr<LayerImpl> m_rootLayer; 92 scoped_ptr<LayerImpl> m_rootLayer;
97 RenderPassList m_renderPassesInDrawOrder; 93 RenderPassList m_renderPassesInDrawOrder;
98 RenderPassIdHashMap m_renderPasses; 94 RenderPassIdHashMap m_renderPasses;
99 size_t m_memoryAllocationLimitBytes; 95 size_t m_memoryAllocationLimitBytes;
100 }; 96 };
101 97
102 class FakeRendererGL : public GLRenderer { 98 class FakeRendererGL : public GLRenderer {
103 public: 99 public:
104 FakeRendererGL(RendererClient* client, ResourceProvider* resourceProvider) : GLRenderer(client, resourceProvider) { } 100 FakeRendererGL(RendererClient* client, ResourceProvider* resourceProvider) : GLRenderer(client, resourceProvider) { }
105 101
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 // them both a pointer to a variable on the stack. 476 // them both a pointer to a variable on the stack.
481 context->setLastCallWasSetVisibilityPointer(&lastCallWasSetVisiblity); 477 context->setLastCallWasSetVisibilityPointer(&lastCallWasSetVisiblity);
482 mockClient.setLastCallWasSetVisibilityPointer(&lastCallWasSetVisiblity); 478 mockClient.setLastCallWasSetVisibilityPointer(&lastCallWasSetVisiblity);
483 renderer.setVisible(true); 479 renderer.setVisible(true);
484 renderer.drawFrame(mockClient.renderPassesInDrawOrder(), mockClient.renderPa sses()); 480 renderer.drawFrame(mockClient.renderPassesInDrawOrder(), mockClient.renderPa sses());
485 renderer.setVisible(false); 481 renderer.setVisible(false);
486 EXPECT_TRUE(lastCallWasSetVisiblity); 482 EXPECT_TRUE(lastCallWasSetVisiblity);
487 } 483 }
488 484
489 } // anonymous namespace 485 } // anonymous namespace
OLDNEW
« no previous file with comments | « cc/gl_renderer.cc ('k') | cc/layer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698