Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Side by Side Diff: skia/ext/platform_canvas_unittest.cc

Issue 22796028: Updating Chromium to Skia SkBaseDevice/SkBitmapDevice split (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added TODOs Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « skia/ext/platform_canvas.cc ('k') | skia/ext/platform_device.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 #if defined(OS_MACOSX) 9 #if defined(OS_MACOSX)
10 #import <ApplicationServices/ApplicationServices.h> 10 #import <ApplicationServices/ApplicationServices.h>
(...skipping 15 matching lines...) Expand all
26 26
27 namespace { 27 namespace {
28 28
29 // Return true if the canvas is filled to canvas_color, and contains a single 29 // Return true if the canvas is filled to canvas_color, and contains a single
30 // rectangle filled to rect_color. This function ignores the alpha channel, 30 // rectangle filled to rect_color. This function ignores the alpha channel,
31 // since Windows will sometimes clear the alpha channel when drawing, and we 31 // since Windows will sometimes clear the alpha channel when drawing, and we
32 // will fix that up later in cases it's necessary. 32 // will fix that up later in cases it's necessary.
33 bool VerifyRect(const PlatformCanvas& canvas, 33 bool VerifyRect(const PlatformCanvas& canvas,
34 uint32_t canvas_color, uint32_t rect_color, 34 uint32_t canvas_color, uint32_t rect_color,
35 int x, int y, int w, int h) { 35 int x, int y, int w, int h) {
36 SkDevice* device = skia::GetTopDevice(canvas); 36 SkBaseDevice* device = skia::GetTopDevice(canvas);
37 const SkBitmap& bitmap = device->accessBitmap(false); 37 const SkBitmap& bitmap = device->accessBitmap(false);
38 SkAutoLockPixels lock(bitmap); 38 SkAutoLockPixels lock(bitmap);
39 39
40 // For masking out the alpha values. 40 // For masking out the alpha values.
41 uint32_t alpha_mask = 0xFF << SK_A32_SHIFT; 41 uint32_t alpha_mask = 0xFF << SK_A32_SHIFT;
42 42
43 for (int cur_y = 0; cur_y < bitmap.height(); cur_y++) { 43 for (int cur_y = 0; cur_y < bitmap.height(); cur_y++) {
44 for (int cur_x = 0; cur_x < bitmap.width(); cur_x++) { 44 for (int cur_x = 0; cur_x < bitmap.width(); cur_x++) {
45 if (cur_x >= x && cur_x < x + w && 45 if (cur_x >= x && cur_x < x + w &&
46 cur_y >= y && cur_y < y + h) { 46 cur_y >= y && cur_y < y + h) {
(...skipping 18 matching lines...) Expand all
65 static uint32_t alpha_mask = 0xFF << SK_A32_SHIFT; 65 static uint32_t alpha_mask = 0xFF << SK_A32_SHIFT;
66 return (*bitmap.getAddr32(x, y) | alpha_mask) == (color | alpha_mask); 66 return (*bitmap.getAddr32(x, y) | alpha_mask) == (color | alpha_mask);
67 } 67 }
68 68
69 // Return true if canvas has something that passes for a rounded-corner 69 // Return true if canvas has something that passes for a rounded-corner
70 // rectangle. Basically, we're just checking to make sure that the pixels in the 70 // rectangle. Basically, we're just checking to make sure that the pixels in the
71 // middle are of rect_color and pixels in the corners are of canvas_color. 71 // middle are of rect_color and pixels in the corners are of canvas_color.
72 bool VerifyRoundedRect(const PlatformCanvas& canvas, 72 bool VerifyRoundedRect(const PlatformCanvas& canvas,
73 uint32_t canvas_color, uint32_t rect_color, 73 uint32_t canvas_color, uint32_t rect_color,
74 int x, int y, int w, int h) { 74 int x, int y, int w, int h) {
75 SkDevice* device = skia::GetTopDevice(canvas); 75 SkBaseDevice* device = skia::GetTopDevice(canvas);
76 const SkBitmap& bitmap = device->accessBitmap(false); 76 const SkBitmap& bitmap = device->accessBitmap(false);
77 SkAutoLockPixels lock(bitmap); 77 SkAutoLockPixels lock(bitmap);
78 78
79 // Check corner points first. They should be of canvas_color. 79 // Check corner points first. They should be of canvas_color.
80 if (!IsOfColor(bitmap, x, y, canvas_color)) return false; 80 if (!IsOfColor(bitmap, x, y, canvas_color)) return false;
81 if (!IsOfColor(bitmap, x + w, y, canvas_color)) return false; 81 if (!IsOfColor(bitmap, x + w, y, canvas_color)) return false;
82 if (!IsOfColor(bitmap, x, y + h, canvas_color)) return false; 82 if (!IsOfColor(bitmap, x, y + h, canvas_color)) return false;
83 if (!IsOfColor(bitmap, x + w, y, canvas_color)) return false; 83 if (!IsOfColor(bitmap, x + w, y, canvas_color)) return false;
84 84
85 // Check middle points. They should be of rect_color. 85 // Check middle points. They should be of rect_color.
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 450
451 sk_bitmap.lockPixels(); 451 sk_bitmap.lockPixels();
452 EXPECT_EQ(0xDEED1020, *sk_bitmap.getAddr32(10, 20)); 452 EXPECT_EQ(0xDEED1020, *sk_bitmap.getAddr32(10, 20));
453 EXPECT_EQ(0xDEED2030, *sk_bitmap.getAddr32(20, 30)); 453 EXPECT_EQ(0xDEED2030, *sk_bitmap.getAddr32(20, 30));
454 EXPECT_EQ(0xDEED3040, *sk_bitmap.getAddr32(30, 40)); 454 EXPECT_EQ(0xDEED3040, *sk_bitmap.getAddr32(30, 40));
455 sk_bitmap.unlockPixels(); 455 sk_bitmap.unlockPixels();
456 } 456 }
457 457
458 458
459 } // namespace skia 459 } // namespace skia
OLDNEW
« no previous file with comments | « skia/ext/platform_canvas.cc ('k') | skia/ext/platform_device.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698