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

Side by Side Diff: cc/software_renderer_unittest.cc

Issue 11232051: Remove static thread pointers from CC (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Address code review comments and fix all cc_unittests 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
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 6
7 #include "cc/software_renderer.h" 7 #include "cc/software_renderer.h"
8 8
9 #include "cc/quad_sink.h" 9 #include "cc/quad_sink.h"
10 #include "cc/render_pass.h" 10 #include "cc/render_pass.h"
11 #include "cc/render_pass_draw_quad.h" 11 #include "cc/render_pass_draw_quad.h"
12 #include "cc/settings.h" 12 #include "cc/settings.h"
13 #include "cc/single_thread_proxy.h" // For DebugScopedSetImplThread
14 #include "cc/solid_color_draw_quad.h" 13 #include "cc/solid_color_draw_quad.h"
15 #include "cc/test/animation_test_common.h" 14 #include "cc/test/animation_test_common.h"
16 #include "cc/test/fake_web_compositor_output_surface.h" 15 #include "cc/test/fake_web_compositor_output_surface.h"
17 #include "cc/test/fake_web_compositor_software_output_device.h" 16 #include "cc/test/fake_web_compositor_software_output_device.h"
18 #include "cc/test/geometry_test_utils.h" 17 #include "cc/test/geometry_test_utils.h"
19 #include "cc/test/render_pass_test_common.h" 18 #include "cc/test/render_pass_test_common.h"
20 #include "cc/test/test_common.h" 19 #include "cc/test/test_common.h"
21 #include "cc/tile_draw_quad.h" 20 #include "cc/tile_draw_quad.h"
22 #include "testing/gmock/include/gmock/gmock.h" 21 #include "testing/gmock/include/gmock/gmock.h"
23 #include "testing/gtest/include/gtest/gtest.h" 22 #include "testing/gtest/include/gtest/gtest.h"
24 23
25 using namespace cc; 24 using namespace cc;
26 using namespace WebKit; 25 using namespace WebKit;
27 using namespace WebKitTests; 26 using namespace WebKitTests;
28 27
29 namespace { 28 namespace {
30 29
31 class SoftwareRendererTest : public testing::Test, public RendererClient { 30 class SoftwareRendererTest : public testing::Test, public RendererClient {
32 public: 31 public:
33 void initializeRenderer() { 32 void initializeRenderer() {
34 m_outputSurface = FakeWebCompositorOutputSurface::createSoftware(scoped_ ptr<WebKit::WebCompositorSoftwareOutputDevice>(new FakeWebCompositorSoftwareOutp utDevice)); 33 m_outputSurface = FakeWebCompositorOutputSurface::createSoftware(scoped_ ptr<WebKit::WebCompositorSoftwareOutputDevice>(new FakeWebCompositorSoftwareOutp utDevice));
35 m_resourceProvider = ResourceProvider::create(m_outputSurface.get()); 34 m_resourceProvider = ResourceProvider::create(m_outputSurface.get());
36 m_renderer = SoftwareRenderer::create(this, resourceProvider(), software Device()); 35 m_renderer = SoftwareRenderer::create(this, resourceProvider(), software Device(), false);
37 } 36 }
38 37
39 WebCompositorSoftwareOutputDevice* softwareDevice() const { return m_outputS urface->softwareDevice(); } 38 WebCompositorSoftwareOutputDevice* softwareDevice() const { return m_outputS urface->softwareDevice(); }
40 FakeWebCompositorOutputSurface* outputSurface() const { return m_outputSurfa ce.get(); } 39 FakeWebCompositorOutputSurface* outputSurface() const { return m_outputSurfa ce.get(); }
41 ResourceProvider* resourceProvider() const { return m_resourceProvider.get() ; } 40 ResourceProvider* resourceProvider() const { return m_resourceProvider.get() ; }
42 SoftwareRenderer* renderer() const { return m_renderer.get(); } 41 SoftwareRenderer* renderer() const { return m_renderer.get(); }
43 void setViewportSize(IntSize viewportSize) { m_viewportSize = viewportSize; } 42 void setViewportSize(IntSize viewportSize) { m_viewportSize = viewportSize; }
44 43
45 // RendererClient implementation. 44 // RendererClient implementation.
46 virtual const IntSize& deviceViewportSize() const OVERRIDE { return m_viewpo rtSize; } 45 virtual const IntSize& deviceViewportSize() const OVERRIDE { return m_viewpo rtSize; }
47 virtual const LayerTreeSettings& settings() const OVERRIDE { return m_settin gs; } 46 virtual const LayerTreeSettings& settings() const OVERRIDE { return m_settin gs; }
48 virtual void didLoseContext() OVERRIDE { } 47 virtual void didLoseContext() OVERRIDE { }
49 virtual void onSwapBuffersComplete() OVERRIDE { } 48 virtual void onSwapBuffersComplete() OVERRIDE { }
50 virtual void setFullRootLayerDamage() OVERRIDE { } 49 virtual void setFullRootLayerDamage() OVERRIDE { }
51 virtual void setManagedMemoryPolicy(const ManagedMemoryPolicy& policy) OVERR IDE { }; 50 virtual void setManagedMemoryPolicy(const ManagedMemoryPolicy& policy) OVERR IDE { };
52 virtual void enforceManagedMemoryPolicy(const ManagedMemoryPolicy& policy) O VERRIDE { }; 51 virtual void enforceManagedMemoryPolicy(const ManagedMemoryPolicy& policy) O VERRIDE { };
53 52
54 protected: 53 protected:
55 DebugScopedSetImplThread m_alwaysImplThread;
56
57 scoped_ptr<FakeWebCompositorOutputSurface> m_outputSurface; 54 scoped_ptr<FakeWebCompositorOutputSurface> m_outputSurface;
58 scoped_ptr<ResourceProvider> m_resourceProvider; 55 scoped_ptr<ResourceProvider> m_resourceProvider;
59 scoped_ptr<SoftwareRenderer> m_renderer; 56 scoped_ptr<SoftwareRenderer> m_renderer;
60 IntSize m_viewportSize; 57 IntSize m_viewportSize;
61 LayerTreeSettings m_settings; 58 LayerTreeSettings m_settings;
62 }; 59 };
63 60
64 TEST_F(SoftwareRendererTest, solidColorQuad) 61 TEST_F(SoftwareRendererTest, solidColorQuad)
65 { 62 {
66 IntSize outerSize(100, 100); 63 IntSize outerSize(100, 100);
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 scoped_array<SkColor> pixels(new SkColor[deviceViewportSize().width() * devi ceViewportSize().height()]); 143 scoped_array<SkColor> pixels(new SkColor[deviceViewportSize().width() * devi ceViewportSize().height()]);
147 renderer()->getFramebufferPixels(pixels.get(), outerRect); 144 renderer()->getFramebufferPixels(pixels.get(), outerRect);
148 145
149 EXPECT_EQ(SK_ColorYELLOW, pixels[0]); 146 EXPECT_EQ(SK_ColorYELLOW, pixels[0]);
150 EXPECT_EQ(SK_ColorYELLOW, pixels[outerPixels - 1]); 147 EXPECT_EQ(SK_ColorYELLOW, pixels[outerPixels - 1]);
151 EXPECT_EQ(SK_ColorCYAN, pixels[outerSize.width() + 1]); 148 EXPECT_EQ(SK_ColorCYAN, pixels[outerSize.width() + 1]);
152 EXPECT_EQ(SK_ColorCYAN, pixels[outerPixels - outerSize.width() - 2]); 149 EXPECT_EQ(SK_ColorCYAN, pixels[outerPixels - outerSize.width() - 2]);
153 } 150 }
154 151
155 } // namespace 152 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698