OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
6 #include "base/message_loop/message_loop.h" | 6 #include "base/message_loop/message_loop.h" |
7 #include "cc/output/software_frame_data.h" | 7 #include "cc/output/software_frame_data.h" |
8 #include "content/browser/compositor/software_output_device_ozone.h" | 8 #include "content/browser/compositor/software_output_device_ozone.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 #include "third_party/skia/include/core/SkSurface.h" | 10 #include "third_party/skia/include/core/SkSurface.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 class MockSurfaceFactoryOzone : public ui::SurfaceFactoryOzone { | 46 class MockSurfaceFactoryOzone : public ui::SurfaceFactoryOzone { |
47 public: | 47 public: |
48 MockSurfaceFactoryOzone() {} | 48 MockSurfaceFactoryOzone() {} |
49 virtual ~MockSurfaceFactoryOzone() {} | 49 virtual ~MockSurfaceFactoryOzone() {} |
50 | 50 |
51 virtual HardwareState InitializeHardware() OVERRIDE { | 51 virtual HardwareState InitializeHardware() OVERRIDE { |
52 return SurfaceFactoryOzone::INITIALIZED; | 52 return SurfaceFactoryOzone::INITIALIZED; |
53 } | 53 } |
54 | 54 |
55 virtual void ShutdownHardware() OVERRIDE {} | 55 virtual void ShutdownHardware() OVERRIDE {} |
56 virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE { return 1; } | |
57 virtual bool LoadEGLGLES2Bindings( | 56 virtual bool LoadEGLGLES2Bindings( |
58 AddGLLibraryCallback add_gl_library, | 57 AddGLLibraryCallback add_gl_library, |
59 SetGLGetProcAddressProcCallback set_gl_get_proc_address) OVERRIDE { | 58 SetGLGetProcAddressProcCallback set_gl_get_proc_address) OVERRIDE { |
60 return false; | 59 return false; |
61 } | 60 } |
62 virtual scoped_ptr<ui::SurfaceOzoneCanvas> CreateCanvasForWidget( | 61 virtual scoped_ptr<ui::SurfaceOzoneCanvas> CreateCanvasForWidget( |
63 gfx::AcceleratedWidget widget) OVERRIDE { | 62 gfx::AcceleratedWidget widget) OVERRIDE { |
64 return make_scoped_ptr<ui::SurfaceOzoneCanvas>(new MockSurfaceOzone()); | 63 return make_scoped_ptr<ui::SurfaceOzoneCanvas>(new MockSurfaceOzone()); |
65 } | 64 } |
66 | 65 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 SoftwareOutputDeviceOzoneTest::~SoftwareOutputDeviceOzoneTest() { | 97 SoftwareOutputDeviceOzoneTest::~SoftwareOutputDeviceOzoneTest() { |
99 } | 98 } |
100 | 99 |
101 void SoftwareOutputDeviceOzoneTest::SetUp() { | 100 void SoftwareOutputDeviceOzoneTest::SetUp() { |
102 ui::ContextFactory* context_factory = | 101 ui::ContextFactory* context_factory = |
103 ui::InitializeContextFactoryForTests(enable_pixel_output_); | 102 ui::InitializeContextFactoryForTests(enable_pixel_output_); |
104 | 103 |
105 surface_factory_.reset(new MockSurfaceFactoryOzone()); | 104 surface_factory_.reset(new MockSurfaceFactoryOzone()); |
106 | 105 |
107 const gfx::Size size(500, 400); | 106 const gfx::Size size(500, 400); |
108 compositor_.reset(new ui::Compositor( | 107 const gfx::AcceleratedWidget kTestAcceleratedWidget = 1; |
109 ui::SurfaceFactoryOzone::GetInstance()->GetAcceleratedWidget(), | 108 compositor_.reset( |
110 context_factory)); | 109 new ui::Compositor(kTestAcceleratedWidget, context_factory)); |
111 compositor_->SetScaleAndSize(1.0f, size); | 110 compositor_->SetScaleAndSize(1.0f, size); |
112 | 111 |
113 output_device_.reset(new content::SoftwareOutputDeviceOzone( | 112 output_device_.reset(new content::SoftwareOutputDeviceOzone( |
114 compositor_.get())); | 113 compositor_.get())); |
115 output_device_->Resize(size, 1.f); | 114 output_device_->Resize(size, 1.f); |
116 } | 115 } |
117 | 116 |
118 void SoftwareOutputDeviceOzoneTest::TearDown() { | 117 void SoftwareOutputDeviceOzoneTest::TearDown() { |
119 output_device_.reset(); | 118 output_device_.reset(); |
120 compositor_.reset(); | 119 compositor_.reset(); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 const SkPMColor black = SkPreMultiplyColor(SK_ColorBLACK); | 185 const SkPMColor black = SkPreMultiplyColor(SK_ColorBLACK); |
187 for (int i = 0; i < area.height(); ++i) { | 186 for (int i = 0; i < area.height(); ++i) { |
188 for (int j = 0; j < area.width(); ++j) { | 187 for (int j = 0; j < area.width(); ++j) { |
189 if (j < damage.width() && i < damage.height()) | 188 if (j < damage.width() && i < damage.height()) |
190 EXPECT_EQ(white, pixels[i * area.width() + j]); | 189 EXPECT_EQ(white, pixels[i * area.width() + j]); |
191 else | 190 else |
192 EXPECT_EQ(black, pixels[i * area.width() + j]); | 191 EXPECT_EQ(black, pixels[i * area.width() + j]); |
193 } | 192 } |
194 } | 193 } |
195 } | 194 } |
OLD | NEW |