| 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/SkDevice.h" | 10 #include "third_party/skia/include/core/SkDevice.h" |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 | 145 |
| 146 // Clear the background to black. | 146 // Clear the background to black. |
| 147 canvas->drawColor(SK_ColorBLACK); | 147 canvas->drawColor(SK_ColorBLACK); |
| 148 | 148 |
| 149 cc::SoftwareFrameData frame; | 149 cc::SoftwareFrameData frame; |
| 150 output_device_->EndPaint(&frame); | 150 output_device_->EndPaint(&frame); |
| 151 | 151 |
| 152 // Draw a white rectangle. | 152 // Draw a white rectangle. |
| 153 gfx::Rect damage(area.width() / 2, area.height() / 2); | 153 gfx::Rect damage(area.width() / 2, area.height() / 2); |
| 154 canvas = output_device_->BeginPaint(damage); | 154 canvas = output_device_->BeginPaint(damage); |
| 155 canvas->clipRect(gfx::RectToSkRect(damage), SkRegion::kReplace_Op); | 155 canvas->legacyClipRect(gfx::RectToSkRect(damage), SkRegion::kReplace_Op); |
| 156 | 156 |
| 157 canvas->drawColor(SK_ColorWHITE); | 157 canvas->drawColor(SK_ColorWHITE); |
| 158 | 158 |
| 159 output_device_->EndPaint(&frame); | 159 output_device_->EndPaint(&frame); |
| 160 | 160 |
| 161 SkPMColor pixels[width * height]; | 161 SkPMColor pixels[width * height]; |
| 162 output_device_->CopyToPixels(area, pixels); | 162 output_device_->CopyToPixels(area, pixels); |
| 163 | 163 |
| 164 // Check that the copied bitmap contains the same pixel values as what we | 164 // Check that the copied bitmap contains the same pixel values as what we |
| 165 // painted. | 165 // painted. |
| 166 const SkPMColor white = SkPreMultiplyColor(SK_ColorWHITE); | 166 const SkPMColor white = SkPreMultiplyColor(SK_ColorWHITE); |
| 167 const SkPMColor black = SkPreMultiplyColor(SK_ColorBLACK); | 167 const SkPMColor black = SkPreMultiplyColor(SK_ColorBLACK); |
| 168 for (int i = 0; i < area.height(); ++i) { | 168 for (int i = 0; i < area.height(); ++i) { |
| 169 for (int j = 0; j < area.width(); ++j) { | 169 for (int j = 0; j < area.width(); ++j) { |
| 170 if (j < damage.width() && i < damage.height()) | 170 if (j < damage.width() && i < damage.height()) |
| 171 EXPECT_EQ(white, pixels[i * area.width() + j]); | 171 EXPECT_EQ(white, pixels[i * area.width() + j]); |
| 172 else | 172 else |
| 173 EXPECT_EQ(black, pixels[i * area.width() + j]); | 173 EXPECT_EQ(black, pixels[i * area.width() + j]); |
| 174 } | 174 } |
| 175 } | 175 } |
| 176 } | 176 } |
| OLD | NEW |