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

Side by Side Diff: cc/test/pixel_comparator.cc

Issue 2823003002: SkBitmap and SkPixelRef no longer need lock/unlock (Closed)
Patch Set: win fix after rebase Created 3 years, 8 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 | « cc/resources/ui_resource_bitmap.cc ('k') | cc/trees/layer_tree_host_impl.cc » ('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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "cc/test/pixel_comparator.h" 5 #include "cc/test/pixel_comparator.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 10 matching lines...) Expand all
21 const SkBitmap& expected_bmp) const { 21 const SkBitmap& expected_bmp) const {
22 // Number of pixels with an error 22 // Number of pixels with an error
23 int error_pixels_count = 0; 23 int error_pixels_count = 0;
24 24
25 gfx::Rect error_bounding_rect = gfx::Rect(); 25 gfx::Rect error_bounding_rect = gfx::Rect();
26 26
27 // Check that bitmaps have identical dimensions. 27 // Check that bitmaps have identical dimensions.
28 DCHECK(actual_bmp.width() == expected_bmp.width() && 28 DCHECK(actual_bmp.width() == expected_bmp.width() &&
29 actual_bmp.height() == expected_bmp.height()); 29 actual_bmp.height() == expected_bmp.height());
30 30
31 SkAutoLockPixels lock_actual_bmp(actual_bmp);
32 SkAutoLockPixels lock_expected_bmp(expected_bmp);
33
34 for (int x = 0; x < actual_bmp.width(); ++x) { 31 for (int x = 0; x < actual_bmp.width(); ++x) {
35 for (int y = 0; y < actual_bmp.height(); ++y) { 32 for (int y = 0; y < actual_bmp.height(); ++y) {
36 SkColor actual_color = actual_bmp.getColor(x, y); 33 SkColor actual_color = actual_bmp.getColor(x, y);
37 SkColor expected_color = expected_bmp.getColor(x, y); 34 SkColor expected_color = expected_bmp.getColor(x, y);
38 if (discard_alpha_) { 35 if (discard_alpha_) {
39 actual_color = SkColorSetA(actual_color, 0); 36 actual_color = SkColorSetA(actual_color, 0);
40 expected_color = SkColorSetA(expected_color, 0); 37 expected_color = SkColorSetA(expected_color, 0);
41 } 38 }
42 if (actual_color != expected_color) { 39 if (actual_color != expected_color) {
43 ++error_pixels_count; 40 ++error_pixels_count;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 86
90 gfx::Rect error_bounding_rect = gfx::Rect(); 87 gfx::Rect error_bounding_rect = gfx::Rect();
91 88
92 // Check that bitmaps have identical dimensions. 89 // Check that bitmaps have identical dimensions.
93 DCHECK(actual_bmp.width() == expected_bmp.width() && 90 DCHECK(actual_bmp.width() == expected_bmp.width() &&
94 actual_bmp.height() == expected_bmp.height()); 91 actual_bmp.height() == expected_bmp.height());
95 92
96 // Check that bitmaps are not empty. 93 // Check that bitmaps are not empty.
97 DCHECK(actual_bmp.width() > 0 && actual_bmp.height() > 0); 94 DCHECK(actual_bmp.width() > 0 && actual_bmp.height() > 0);
98 95
99 SkAutoLockPixels lock_actual_bmp(actual_bmp);
100 SkAutoLockPixels lock_expected_bmp(expected_bmp);
101
102 for (int x = 0; x < actual_bmp.width(); ++x) { 96 for (int x = 0; x < actual_bmp.width(); ++x) {
103 for (int y = 0; y < actual_bmp.height(); ++y) { 97 for (int y = 0; y < actual_bmp.height(); ++y) {
104 SkColor actual_color = actual_bmp.getColor(x, y); 98 SkColor actual_color = actual_bmp.getColor(x, y);
105 SkColor expected_color = expected_bmp.getColor(x, y); 99 SkColor expected_color = expected_bmp.getColor(x, y);
106 if (discard_alpha_) { 100 if (discard_alpha_) {
107 actual_color = SkColorSetA(actual_color, 0); 101 actual_color = SkColorSetA(actual_color, 0);
108 expected_color = SkColorSetA(expected_color, 0); 102 expected_color = SkColorSetA(expected_color, 0);
109 } 103 }
110 104
111 if (actual_color != expected_color) { 105 if (actual_color != expected_color) {
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 } 197 }
204 } 198 }
205 LOG(ERROR) << "Error Bounding Box : " << error_bounding_rect.ToString(); 199 LOG(ERROR) << "Error Bounding Box : " << error_bounding_rect.ToString();
206 return false; 200 return false;
207 } else { 201 } else {
208 return true; 202 return true;
209 } 203 }
210 } 204 }
211 205
212 } // namespace cc 206 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/ui_resource_bitmap.cc ('k') | cc/trees/layer_tree_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698