| 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/macros.h" | 5 #include "base/macros.h" |
| 6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "base/thread_task_runner_handle.h" | 8 #include "base/thread_task_runner_handle.h" |
| 9 #include "content/browser/compositor/software_output_device_ozone.h" | 9 #include "content/browser/compositor/software_output_device_ozone.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 ui::InitializeContextFactoryForTests(enable_pixel_output_); | 88 ui::InitializeContextFactoryForTests(enable_pixel_output_); |
| 89 | 89 |
| 90 const gfx::Size size(500, 400); | 90 const gfx::Size size(500, 400); |
| 91 window_ = ui::OzonePlatform::GetInstance()->CreatePlatformWindow( | 91 window_ = ui::OzonePlatform::GetInstance()->CreatePlatformWindow( |
| 92 &window_delegate_, gfx::Rect(size)); | 92 &window_delegate_, gfx::Rect(size)); |
| 93 compositor_.reset( | 93 compositor_.reset( |
| 94 new ui::Compositor(context_factory, base::ThreadTaskRunnerHandle::Get())); | 94 new ui::Compositor(context_factory, base::ThreadTaskRunnerHandle::Get())); |
| 95 compositor_->SetAcceleratedWidget(window_delegate_.GetAcceleratedWidget()); | 95 compositor_->SetAcceleratedWidget(window_delegate_.GetAcceleratedWidget()); |
| 96 compositor_->SetScaleAndSize(1.0f, size); | 96 compositor_->SetScaleAndSize(1.0f, size); |
| 97 | 97 |
| 98 output_device_.reset(new content::SoftwareOutputDeviceOzone( | 98 output_device_ = |
| 99 compositor_.get())); | 99 content::SoftwareOutputDeviceOzone::Create(compositor_.get()); |
| 100 output_device_->Resize(size, 1.f); | 100 if (output_device_) |
| 101 output_device_->Resize(size, 1.f); |
| 101 } | 102 } |
| 102 | 103 |
| 103 void SoftwareOutputDeviceOzoneTest::TearDown() { | 104 void SoftwareOutputDeviceOzoneTest::TearDown() { |
| 104 output_device_.reset(); | 105 output_device_.reset(); |
| 105 compositor_.reset(); | 106 compositor_.reset(); |
| 106 window_.reset(); | 107 window_.reset(); |
| 107 ui::TerminateContextFactoryForTests(); | 108 ui::TerminateContextFactoryForTests(); |
| 108 } | 109 } |
| 109 | 110 |
| 110 class SoftwareOutputDeviceOzonePixelTest | 111 class SoftwareOutputDeviceOzonePixelTest |
| 111 : public SoftwareOutputDeviceOzoneTest { | 112 : public SoftwareOutputDeviceOzoneTest { |
| 112 protected: | 113 protected: |
| 113 void SetUp() override; | 114 void SetUp() override; |
| 114 }; | 115 }; |
| 115 | 116 |
| 116 void SoftwareOutputDeviceOzonePixelTest::SetUp() { | 117 void SoftwareOutputDeviceOzonePixelTest::SetUp() { |
| 117 enable_pixel_output_ = true; | 118 enable_pixel_output_ = true; |
| 118 SoftwareOutputDeviceOzoneTest::SetUp(); | 119 SoftwareOutputDeviceOzoneTest::SetUp(); |
| 119 } | 120 } |
| 120 | 121 |
| 121 TEST_F(SoftwareOutputDeviceOzoneTest, CheckCorrectResizeBehavior) { | 122 TEST_F(SoftwareOutputDeviceOzoneTest, CheckCorrectResizeBehavior) { |
| 123 // Check if software rendering mode is not supported. |
| 124 if (!output_device_) |
| 125 return; |
| 126 |
| 122 gfx::Rect damage(0, 0, 100, 100); | 127 gfx::Rect damage(0, 0, 100, 100); |
| 123 gfx::Size size(200, 100); | 128 gfx::Size size(200, 100); |
| 124 // Reduce size. | 129 // Reduce size. |
| 125 output_device_->Resize(size, 1.f); | 130 output_device_->Resize(size, 1.f); |
| 126 | 131 |
| 127 SkCanvas* canvas = output_device_->BeginPaint(damage); | 132 SkCanvas* canvas = output_device_->BeginPaint(damage); |
| 128 gfx::Size canvas_size(canvas->getBaseLayerSize().width(), | 133 gfx::Size canvas_size(canvas->getBaseLayerSize().width(), |
| 129 canvas->getBaseLayerSize().height()); | 134 canvas->getBaseLayerSize().height()); |
| 130 EXPECT_EQ(size.ToString(), canvas_size.ToString()); | 135 EXPECT_EQ(size.ToString(), canvas_size.ToString()); |
| 131 | 136 |
| 132 size.SetSize(1000, 500); | 137 size.SetSize(1000, 500); |
| 133 // Increase size. | 138 // Increase size. |
| 134 output_device_->Resize(size, 1.f); | 139 output_device_->Resize(size, 1.f); |
| 135 | 140 |
| 136 canvas = output_device_->BeginPaint(damage); | 141 canvas = output_device_->BeginPaint(damage); |
| 137 canvas_size.SetSize(canvas->getBaseLayerSize().width(), | 142 canvas_size.SetSize(canvas->getBaseLayerSize().width(), |
| 138 canvas->getBaseLayerSize().height()); | 143 canvas->getBaseLayerSize().height()); |
| 139 EXPECT_EQ(size.ToString(), canvas_size.ToString()); | 144 EXPECT_EQ(size.ToString(), canvas_size.ToString()); |
| 140 | 145 |
| 141 } | 146 } |
| 142 | 147 |
| OLD | NEW |