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

Side by Side Diff: chrome/browser/chromeos/accessibility/accessibility_highlight_manager_interactive_uitest.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
OLDNEW
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2016 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 "chrome/browser/chromeos/accessibility/accessibility_highlight_manager. h" 5 #include "chrome/browser/chromeos/accessibility/accessibility_highlight_manager. h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 } 85 }
86 86
87 void CaptureAfterImage(const gfx::Rect& bounds) { 87 void CaptureAfterImage(const gfx::Rect& bounds) {
88 Capture(bounds); 88 Capture(bounds);
89 image_.AsBitmap().deepCopyTo(&after_bmp_); 89 image_.AsBitmap().deepCopyTo(&after_bmp_);
90 } 90 }
91 91
92 void ComputeImageStats() { 92 void ComputeImageStats() {
93 diff_count_ = 0; 93 diff_count_ = 0;
94 double accum[4] = {0, 0, 0, 0}; 94 double accum[4] = {0, 0, 0, 0};
95 SkAutoLockPixels lock_before(before_bmp_);
96 SkAutoLockPixels lock_after(after_bmp_);
97 for (int x = 0; x < before_bmp_.width(); ++x) { 95 for (int x = 0; x < before_bmp_.width(); ++x) {
98 for (int y = 0; y < before_bmp_.height(); ++y) { 96 for (int y = 0; y < before_bmp_.height(); ++y) {
99 SkColor before_color = before_bmp_.getColor(x, y); 97 SkColor before_color = before_bmp_.getColor(x, y);
100 SkColor after_color = after_bmp_.getColor(x, y); 98 SkColor after_color = after_bmp_.getColor(x, y);
101 if (before_color != after_color) { 99 if (before_color != after_color) {
102 diff_count_++; 100 diff_count_++;
103 accum[0] += SkColorGetB(after_color); 101 accum[0] += SkColorGetB(after_color);
104 accum[1] += SkColorGetG(after_color); 102 accum[1] += SkColorGetG(after_color);
105 accum[2] += SkColorGetR(after_color); 103 accum[2] += SkColorGetR(after_color);
106 accum[3] += SkColorGetA(after_color); 104 accum[3] += SkColorGetA(after_color);
(...skipping 25 matching lines...) Expand all
132 aura::Window* window = ash::Shell::GetPrimaryRootWindow(); 130 aura::Window* window = ash::Shell::GetPrimaryRootWindow();
133 ui::GrabWindowSnapshotAndScaleAsync( 131 ui::GrabWindowSnapshotAndScaleAsync(
134 window, bounds, bounds.size(), 132 window, bounds, bounds.size(),
135 content::BrowserThread::GetBlockingPool(), 133 content::BrowserThread::GetBlockingPool(),
136 base::Bind(&AccessibilityHighlightManagerTest::GotSnapshot, 134 base::Bind(&AccessibilityHighlightManagerTest::GotSnapshot,
137 base::Unretained(this))); 135 base::Unretained(this)));
138 base::RunLoop run_loop; 136 base::RunLoop run_loop;
139 run_loop_quitter_ = run_loop.QuitClosure(); 137 run_loop_quitter_ = run_loop.QuitClosure();
140 run_loop.Run(); 138 run_loop.Run();
141 SkBitmap bitmap = image_.AsBitmap(); 139 SkBitmap bitmap = image_.AsBitmap();
142 SkAutoLockPixels lock(bitmap);
143 if (bitmap.width() != bounds.width() || 140 if (bitmap.width() != bounds.width() ||
144 bitmap.height() != bounds.height()) { 141 bitmap.height() != bounds.height()) {
145 LOG(INFO) << "Bitmap not correct size, trying to capture again"; 142 LOG(INFO) << "Bitmap not correct size, trying to capture again";
146 continue; 143 continue;
147 } 144 }
148 if (255 == SkColorGetA(bitmap.getColor(0, 0))) { 145 if (255 == SkColorGetA(bitmap.getColor(0, 0))) {
149 LOG(INFO) << "Bitmap is transparent, trying to capture again"; 146 LOG(INFO) << "Bitmap is transparent, trying to capture again";
150 break; 147 break;
151 } 148 }
152 } 149 }
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 // This is a smoke test to assert that something is drawn in the right 227 // This is a smoke test to assert that something is drawn in the right
231 // part of the screen of approximately the right size and color. 228 // part of the screen of approximately the right size and color.
232 // There's deliberately some tolerance for tiny errors. 229 // There's deliberately some tolerance for tiny errors.
233 EXPECT_NEAR(1608, diff_count(), 50); 230 EXPECT_NEAR(1608, diff_count(), 50);
234 EXPECT_NEAR(255, SkColorGetR(average_diff_color()), 5); 231 EXPECT_NEAR(255, SkColorGetR(average_diff_color()), 5);
235 EXPECT_NEAR(201, SkColorGetG(average_diff_color()), 5); 232 EXPECT_NEAR(201, SkColorGetG(average_diff_color()), 5);
236 EXPECT_NEAR(152, SkColorGetB(average_diff_color()), 5); 233 EXPECT_NEAR(152, SkColorGetB(average_diff_color()), 5);
237 } 234 }
238 235
239 } // namespace chromeos 236 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698