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

Side by Side Diff: skia/ext/skia_utils_mac_unittest.mm

Issue 331283002: stop calling deprecated setConfig (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase + android typo Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « skia/ext/skia_utils_mac.mm ('k') | skia/ext/vector_platform_device_emf_win.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) 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 #include "skia/ext/skia_utils_mac.mm" 5 #include "skia/ext/skia_utils_mac.mm"
6 6
7 #include "base/mac/mac_util.h" 7 #include "base/mac/mac_util.h"
8 #include "base/mac/scoped_nsobject.h" 8 #include "base/mac/scoped_nsobject.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
(...skipping 25 matching lines...) Expand all
36 }; 36 };
37 void RunBitLockerTest(BitLockerTest test); 37 void RunBitLockerTest(BitLockerTest test);
38 38
39 // If not red, is blue. 39 // If not red, is blue.
40 // If not tfbit (twenty-four-bit), is 444. 40 // If not tfbit (twenty-four-bit), is 444.
41 void ShapeHelper(int width, int height, bool isred, bool tfbit); 41 void ShapeHelper(int width, int height, bool isred, bool tfbit);
42 }; 42 };
43 43
44 SkBitmap SkiaUtilsMacTest::CreateSkBitmap(int width, int height, 44 SkBitmap SkiaUtilsMacTest::CreateSkBitmap(int width, int height,
45 bool isred, bool tfbit) { 45 bool isred, bool tfbit) {
46 SkColorType ct = tfbit ? kN32_SkColorType : kARGB_4444_SkColorType;
47 SkImageInfo info = SkImageInfo::Make(width, height, ct, kPremul_SkAlphaType);
48
46 SkBitmap bitmap; 49 SkBitmap bitmap;
47 50 bitmap.allocPixels(info);
48 if (tfbit)
49 bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height);
50 else
51 bitmap.setConfig(SkBitmap::kARGB_4444_Config, width, height);
52 bitmap.allocPixels();
53 51
54 if (isred) 52 if (isred)
55 bitmap.eraseARGB(0xff, 0xff, 0, 0); 53 bitmap.eraseARGB(0xff, 0xff, 0, 0);
56 else 54 else
57 bitmap.eraseARGB(0xff, 0, 0, 0xff); 55 bitmap.eraseARGB(0xff, 0, 0, 0xff);
58 56
59 return bitmap; 57 return bitmap;
60 } 58 }
61 59
62 NSImage* SkiaUtilsMacTest::CreateNSImage(int width, int height, bool isred) { 60 NSImage* SkiaUtilsMacTest::CreateNSImage(int width, int height, bool isred) {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 114
117 // setBitmapDevice has been deprecated/removed. Is this test still useful? 115 // setBitmapDevice has been deprecated/removed. Is this test still useful?
118 void SkiaUtilsMacTest::RunBitLockerTest(BitLockerTest test) { 116 void SkiaUtilsMacTest::RunBitLockerTest(BitLockerTest test) {
119 const unsigned width = 2; 117 const unsigned width = 2;
120 const unsigned height = 2; 118 const unsigned height = 2;
121 const unsigned storageSize = width * height; 119 const unsigned storageSize = width * height;
122 const unsigned original[] = {0xFF333333, 0xFF666666, 0xFF999999, 0xFFCCCCCC}; 120 const unsigned original[] = {0xFF333333, 0xFF666666, 0xFF999999, 0xFFCCCCCC};
123 EXPECT_EQ(storageSize, sizeof(original) / sizeof(original[0])); 121 EXPECT_EQ(storageSize, sizeof(original) / sizeof(original[0]));
124 unsigned bits[storageSize]; 122 unsigned bits[storageSize];
125 memcpy(bits, original, sizeof(original)); 123 memcpy(bits, original, sizeof(original));
124 SkImageInfo info = SkImageInfo::MakeN32Premul(width, height);
126 SkBitmap bitmap; 125 SkBitmap bitmap;
127 bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height); 126 bitmap.installPixels(info, bits, info.minRowBytes());
128 bitmap.setPixels(bits);
129 127
130 SkCanvas canvas(bitmap); 128 SkCanvas canvas(bitmap);
131 if (test & TestTranslate) 129 if (test & TestTranslate)
132 canvas.translate(width / 2, 0); 130 canvas.translate(width / 2, 0);
133 if (test & TestClip) { 131 if (test & TestClip) {
134 SkRect clipRect = {0, height / 2, width, height}; 132 SkRect clipRect = {0, height / 2, width, height};
135 canvas.clipRect(clipRect); 133 canvas.clipRect(clipRect);
136 } 134 }
137 { 135 {
138 gfx::SkiaBitLocker bitLocker(&canvas); 136 gfx::SkiaBitLocker bitLocker(&canvas);
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 TEST_F(SkiaUtilsMacTest, BitLocker_ClipNoBits) { 236 TEST_F(SkiaUtilsMacTest, BitLocker_ClipNoBits) {
239 RunBitLockerTest(SkiaUtilsMacTest::TestClipNoBits); 237 RunBitLockerTest(SkiaUtilsMacTest::TestClipNoBits);
240 } 238 }
241 239
242 TEST_F(SkiaUtilsMacTest, BitLocker_XClipNoBits) { 240 TEST_F(SkiaUtilsMacTest, BitLocker_XClipNoBits) {
243 RunBitLockerTest(SkiaUtilsMacTest::TestXClipNoBits); 241 RunBitLockerTest(SkiaUtilsMacTest::TestXClipNoBits);
244 } 242 }
245 243
246 } // namespace 244 } // namespace
247 245
OLDNEW
« no previous file with comments | « skia/ext/skia_utils_mac.mm ('k') | skia/ext/vector_platform_device_emf_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698