OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 // TODO(awalker): clean up the const/non-const reference handling in this test | 5 // TODO(awalker): clean up the const/non-const reference handling in this test |
6 | 6 |
7 #include "skia/ext/platform_canvas.h" | 7 #include "skia/ext/platform_canvas.h" |
8 | 8 |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 // Return true if canvas has something that passes for a rounded-corner | 83 // Return true if canvas has something that passes for a rounded-corner |
84 // rectangle. Basically, we're just checking to make sure that the pixels in the | 84 // rectangle. Basically, we're just checking to make sure that the pixels in the |
85 // middle are of rect_color and pixels in the corners are of canvas_color. | 85 // middle are of rect_color and pixels in the corners are of canvas_color. |
86 bool VerifyRoundedRect(const SkCanvas& canvas, | 86 bool VerifyRoundedRect(const SkCanvas& canvas, |
87 uint32_t canvas_color, | 87 uint32_t canvas_color, |
88 uint32_t rect_color, | 88 uint32_t rect_color, |
89 int x, | 89 int x, |
90 int y, | 90 int y, |
91 int w, | 91 int w, |
92 int h) { | 92 int h) { |
93 SkBaseDevice* device = skia::GetTopDevice(canvas); | 93 SkBaseDevice* device = canvas.getTopDevice(true); |
94 const SkBitmap& bitmap = device->accessBitmap(false); | 94 const SkBitmap& bitmap = device->accessBitmap(false); |
95 SkAutoLockPixels lock(bitmap); | 95 SkAutoLockPixels lock(bitmap); |
96 | 96 |
97 // Check corner points first. They should be of canvas_color. | 97 // Check corner points first. They should be of canvas_color. |
98 if (!IsOfColor(bitmap, x, y, canvas_color)) return false; | 98 if (!IsOfColor(bitmap, x, y, canvas_color)) return false; |
99 if (!IsOfColor(bitmap, x + w, y, canvas_color)) return false; | 99 if (!IsOfColor(bitmap, x + w, y, canvas_color)) return false; |
100 if (!IsOfColor(bitmap, x, y + h, canvas_color)) return false; | 100 if (!IsOfColor(bitmap, x, y + h, canvas_color)) return false; |
101 if (!IsOfColor(bitmap, x + w, y, canvas_color)) return false; | 101 if (!IsOfColor(bitmap, x + w, y, canvas_color)) return false; |
102 | 102 |
103 // Check middle points. They should be of rect_color. | 103 // Check middle points. They should be of rect_color. |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 } | 407 } |
408 canvas->restore(); | 408 canvas->restore(); |
409 EXPECT_TRUE(VerifyRoundedRect(*canvas, SK_ColorWHITE, SK_ColorBLACK, | 409 EXPECT_TRUE(VerifyRoundedRect(*canvas, SK_ColorWHITE, SK_ColorBLACK, |
410 kInnerX + 1, kInnerY + 1, kInnerW, kInnerH)); | 410 kInnerX + 1, kInnerY + 1, kInnerW, kInnerH)); |
411 #endif | 411 #endif |
412 } | 412 } |
413 | 413 |
414 #endif // #if !defined(USE_AURA) | 414 #endif // #if !defined(USE_AURA) |
415 | 415 |
416 } // namespace skia | 416 } // namespace skia |
OLD | NEW |