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/SkBitmapDevice.h" | 10 #include "third_party/skia/include/core/SkBitmapDevice.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 class MockSurfaceFactoryOzone : public gfx::SurfaceFactoryOzone { | 21 class MockSurfaceFactoryOzone : public gfx::SurfaceFactoryOzone { |
22 public: | 22 public: |
23 MockSurfaceFactoryOzone() {} | 23 MockSurfaceFactoryOzone() {} |
24 virtual ~MockSurfaceFactoryOzone() {} | 24 virtual ~MockSurfaceFactoryOzone() {} |
25 | 25 |
26 virtual HardwareState InitializeHardware() OVERRIDE { | 26 virtual HardwareState InitializeHardware() OVERRIDE { |
27 return SurfaceFactoryOzone::INITIALIZED; | 27 return SurfaceFactoryOzone::INITIALIZED; |
28 } | 28 } |
29 | 29 |
30 virtual void ShutdownHardware() OVERRIDE {} | 30 virtual void ShutdownHardware() OVERRIDE {} |
31 virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE { return 1; } | |
32 virtual gfx::AcceleratedWidget RealizeAcceleratedWidget( | 31 virtual gfx::AcceleratedWidget RealizeAcceleratedWidget( |
33 gfx::AcceleratedWidget w) OVERRIDE { return w; } | 32 gfx::AcceleratedWidget w) OVERRIDE { return w; } |
34 virtual bool LoadEGLGLES2Bindings( | 33 virtual bool LoadEGLGLES2Bindings( |
35 AddGLLibraryCallback add_gl_library, | 34 AddGLLibraryCallback add_gl_library, |
36 SetGLGetProcAddressProcCallback set_gl_get_proc_address) OVERRIDE { | 35 SetGLGetProcAddressProcCallback set_gl_get_proc_address) OVERRIDE { |
37 return false; | 36 return false; |
38 } | 37 } |
39 virtual bool AttemptToResizeAcceleratedWidget( | 38 virtual bool AttemptToResizeAcceleratedWidget( |
40 gfx::AcceleratedWidget w, const gfx::Rect& bounds) OVERRIDE { | 39 gfx::AcceleratedWidget w, const gfx::Rect& bounds) OVERRIDE { |
41 device_ = skia::AdoptRef(new SkBitmapDevice(SkBitmap::kARGB_8888_Config, | 40 device_ = skia::AdoptRef(new SkBitmapDevice(SkBitmap::kARGB_8888_Config, |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 } | 89 } |
91 | 90 |
92 void SoftwareOutputDeviceOzoneTest::SetUp() { | 91 void SoftwareOutputDeviceOzoneTest::SetUp() { |
93 ui::InitializeContextFactoryForTests(enable_pixel_output_); | 92 ui::InitializeContextFactoryForTests(enable_pixel_output_); |
94 ui::Compositor::Initialize(); | 93 ui::Compositor::Initialize(); |
95 | 94 |
96 surface_factory_.reset(new MockSurfaceFactoryOzone()); | 95 surface_factory_.reset(new MockSurfaceFactoryOzone()); |
97 gfx::SurfaceFactoryOzone::SetInstance(surface_factory_.get()); | 96 gfx::SurfaceFactoryOzone::SetInstance(surface_factory_.get()); |
98 | 97 |
99 const gfx::Size size(500, 400); | 98 const gfx::Size size(500, 400); |
100 compositor_.reset(new ui::Compositor( | 99 compositor_.reset( |
101 gfx::SurfaceFactoryOzone::GetInstance()->GetAcceleratedWidget())); | 100 new ui::Compositor(gfx::kDefaultAcceleratedWidgetForSingleWindow)); |
102 compositor_->SetScaleAndSize(1.0f, size); | 101 compositor_->SetScaleAndSize(1.0f, size); |
103 | 102 |
104 output_device_.reset(new content::SoftwareOutputDeviceOzone( | 103 output_device_.reset(new content::SoftwareOutputDeviceOzone( |
105 compositor_.get())); | 104 compositor_.get())); |
106 output_device_->Resize(size); | 105 output_device_->Resize(size); |
107 } | 106 } |
108 | 107 |
109 void SoftwareOutputDeviceOzoneTest::TearDown() { | 108 void SoftwareOutputDeviceOzoneTest::TearDown() { |
110 output_device_.reset(); | 109 output_device_.reset(); |
111 compositor_.reset(); | 110 compositor_.reset(); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 // painted. | 198 // painted. |
200 for (int i = 0; i < area.height(); ++i) { | 199 for (int i = 0; i < area.height(); ++i) { |
201 for (int j = 0; j < area.width(); ++j) { | 200 for (int j = 0; j < area.width(); ++j) { |
202 if (j < damage.width() && i < damage.height()) | 201 if (j < damage.width() && i < damage.height()) |
203 EXPECT_EQ(SK_ColorWHITE, bitmap.getColor(j, i)); | 202 EXPECT_EQ(SK_ColorWHITE, bitmap.getColor(j, i)); |
204 else | 203 else |
205 EXPECT_EQ(SK_ColorBLACK, bitmap.getColor(j, i)); | 204 EXPECT_EQ(SK_ColorBLACK, bitmap.getColor(j, i)); |
206 } | 205 } |
207 } | 206 } |
208 } | 207 } |
OLD | NEW |