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

Side by Side Diff: skia/ext/platform_canvas_unittest.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) 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 } 51 }
52 52
53 // Return true if the canvas is filled to canvas_color, and contains a single 53 // Return true if the canvas is filled to canvas_color, and contains a single
54 // rectangle filled to rect_color. This function ignores the alpha channel, 54 // rectangle filled to rect_color. This function ignores the alpha channel,
55 // since Windows will sometimes clear the alpha channel when drawing, and we 55 // since Windows will sometimes clear the alpha channel when drawing, and we
56 // will fix that up later in cases it's necessary. 56 // will fix that up later in cases it's necessary.
57 bool VerifyRect(const SkCanvas& canvas, 57 bool VerifyRect(const SkCanvas& canvas,
58 uint32_t canvas_color, uint32_t rect_color, 58 uint32_t canvas_color, uint32_t rect_color,
59 int x, int y, int w, int h) { 59 int x, int y, int w, int h) {
60 const SkBitmap bitmap = skia::ReadPixels(const_cast<SkCanvas*>(&canvas)); 60 const SkBitmap bitmap = skia::ReadPixels(const_cast<SkCanvas*>(&canvas));
61 SkAutoLockPixels lock(bitmap);
62 61
63 for (int cur_y = 0; cur_y < bitmap.height(); cur_y++) { 62 for (int cur_y = 0; cur_y < bitmap.height(); cur_y++) {
64 for (int cur_x = 0; cur_x < bitmap.width(); cur_x++) { 63 for (int cur_x = 0; cur_x < bitmap.width(); cur_x++) {
65 if (cur_x >= x && cur_x < x + w && 64 if (cur_x >= x && cur_x < x + w &&
66 cur_y >= y && cur_y < y + h) { 65 cur_y >= y && cur_y < y + h) {
67 // Inside the square should be rect_color 66 // Inside the square should be rect_color
68 if (!IsOfColor(bitmap, cur_x, cur_y, rect_color)) 67 if (!IsOfColor(bitmap, cur_x, cur_y, rect_color))
69 return false; 68 return false;
70 } else { 69 } else {
71 // Outside the square should be canvas_color 70 // Outside the square should be canvas_color
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 } 362 }
364 canvas->restore(); 363 canvas->restore();
365 EXPECT_TRUE(VerifyRoundedRect(*canvas, SK_ColorWHITE, SK_ColorBLACK, 364 EXPECT_TRUE(VerifyRoundedRect(*canvas, SK_ColorWHITE, SK_ColorBLACK,
366 kInnerX + 1, kInnerY + 1, kInnerW, kInnerH)); 365 kInnerX + 1, kInnerY + 1, kInnerW, kInnerH));
367 #endif 366 #endif
368 } 367 }
369 368
370 } // namespace skia 369 } // namespace skia
371 370
372 #endif // defined(OS_WIN) 371 #endif // defined(OS_WIN)
OLDNEW
« no previous file with comments | « skia/ext/image_operations_unittest.cc ('k') | skia/public/interfaces/bitmap_skbitmap_struct_traits.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698