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

Side by Side Diff: cc/gl_renderer_unittest.cc

Issue 11369071: A speculative Revert for r165872 - Remove static thread pointers from CC, attempt 2 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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 | Annotate | Revision Log
« 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_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
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
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
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 }
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