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

Side by Side Diff: ui/gfx/blit_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
« no previous file with comments | « ui/gfx/android/java_bitmap.cc ('k') | ui/gfx/canvas.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include "base/memory/shared_memory.h" 7 #include "base/memory/shared_memory.h"
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 #include "skia/ext/platform_canvas.h" 9 #include "skia/ext/platform_canvas.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 28 matching lines...) Expand all
39 SkImageInfo info = SkImageInfo::MakeN32Premul(w, h); 39 SkImageInfo info = SkImageInfo::MakeN32Premul(w, h);
40 canvas->writePixels(info, extendedValues, w*4, 0, 0); 40 canvas->writePixels(info, extendedValues, w*4, 0, 0);
41 } 41 }
42 42
43 // Checks each pixel in the given canvas and see if it is made up of the given 43 // Checks each pixel in the given canvas and see if it is made up of the given
44 // values, where each value has been duplicated into each channel of the given 44 // values, where each value has been duplicated into each channel of the given
45 // bitmap (see SetToCanvas above). 45 // bitmap (see SetToCanvas above).
46 template <int w, int h> 46 template <int w, int h>
47 void VerifyCanvasValues(SkCanvas* canvas, uint8_t values[h][w]) { 47 void VerifyCanvasValues(SkCanvas* canvas, uint8_t values[h][w]) {
48 SkBitmap bitmap = skia::ReadPixels(canvas); 48 SkBitmap bitmap = skia::ReadPixels(canvas);
49 SkAutoLockPixels lock(bitmap);
50 ASSERT_EQ(w, bitmap.width()); 49 ASSERT_EQ(w, bitmap.width());
51 ASSERT_EQ(h, bitmap.height()); 50 ASSERT_EQ(h, bitmap.height());
52 51
53 for (int y = 0; y < h; y++) { 52 for (int y = 0; y < h; y++) {
54 for (int x = 0; x < w; x++) { 53 for (int x = 0; x < w; x++) {
55 uint8_t value = values[y][x]; 54 uint8_t value = values[y][x];
56 uint32_t expected = (value << 24) | (value << 16) | (value << 8) | value; 55 uint32_t expected = (value << 24) | (value << 16) | (value << 8) | value;
57 ASSERT_EQ(expected, *bitmap.getAddr32(x, y)); 56 ASSERT_EQ(expected, *bitmap.getAddr32(x, y));
58 } 57 }
59 } 58 }
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 {0x30, 0x31, 0x32, 0x33, 0x34}, 165 {0x30, 0x31, 0x32, 0x33, 0x34},
167 {0x40, 0x41, 0x42, 0x43, 0x44}}; 166 {0x40, 0x41, 0x42, 0x43, 0x44}};
168 SetToCanvas<5, 5>(canvas.get(), initial_values); 167 SetToCanvas<5, 5>(canvas.get(), initial_values);
169 168
170 // Sanity check on input. 169 // Sanity check on input.
171 VerifyCanvasValues<5, 5>(canvas.get(), initial_values); 170 VerifyCanvasValues<5, 5>(canvas.get(), initial_values);
172 } 171 }
173 172
174 #endif 173 #endif
175 174
OLDNEW
« no previous file with comments | « ui/gfx/android/java_bitmap.cc ('k') | ui/gfx/canvas.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698