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

Side by Side Diff: tests/SkImageTest.cpp

Issue 1204433002: Begin kLegacyFontHost_InitType cleanup (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add dox Created 5 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
« no previous file with comments | « tests/ReadPixelsTest.cpp ('k') | tests/WritePixelsTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkBitmapDevice.h" 8 #include "SkCanvas.h"
9 #include "SkImagePriv.h" 9 #include "SkImagePriv.h"
10 #include "Test.h" 10 #include "Test.h"
11 11
12 static const int gWidth = 20; 12 static const int gWidth = 20;
13 static const int gHeight = 20; 13 static const int gHeight = 20;
14 14
15 // Tests that SkNewImageFromBitmap obeys pixelref origin. 15 // Tests that SkNewImageFromBitmap obeys pixelref origin.
16 DEF_TEST(SkImageFromBitmap_extractSubset, reporter) { 16 DEF_TEST(SkImageFromBitmap_extractSubset, reporter) {
17 SkAutoTUnref<SkImage> image; 17 SkAutoTUnref<SkImage> image;
18 { 18 {
19 SkBitmap srcBitmap; 19 SkBitmap srcBitmap;
20 srcBitmap.allocN32Pixels(gWidth, gHeight); 20 srcBitmap.allocN32Pixels(gWidth, gHeight);
21 srcBitmap.eraseColor(SK_ColorRED); 21 srcBitmap.eraseColor(SK_ColorRED);
22 SkBitmapDevice dev(srcBitmap); 22 SkCanvas canvas(srcBitmap);
23 SkCanvas canvas(&dev);
24 SkIRect r = SkIRect::MakeXYWH(5, 5, gWidth - 5, gWidth - 5); 23 SkIRect r = SkIRect::MakeXYWH(5, 5, gWidth - 5, gWidth - 5);
25 SkPaint p; 24 SkPaint p;
26 p.setColor(SK_ColorGREEN); 25 p.setColor(SK_ColorGREEN);
27 canvas.drawIRect(r, p); 26 canvas.drawIRect(r, p);
28 SkBitmap dstBitmap; 27 SkBitmap dstBitmap;
29 srcBitmap.extractSubset(&dstBitmap, r); 28 srcBitmap.extractSubset(&dstBitmap, r);
30 image.reset(SkNewImageFromBitmap(dstBitmap, true, NULL)); 29 image.reset(SkNewImageFromBitmap(dstBitmap, true, NULL));
31 } 30 }
32 31
33 SkBitmap tgt; 32 SkBitmap tgt;
34 tgt.allocN32Pixels(gWidth, gHeight); 33 tgt.allocN32Pixels(gWidth, gHeight);
35 SkBitmapDevice dev(tgt); 34 SkCanvas canvas(tgt);
36 SkCanvas canvas(&dev);
37 canvas.clear(SK_ColorTRANSPARENT); 35 canvas.clear(SK_ColorTRANSPARENT);
38 canvas.drawImage(image, 0, 0, NULL); 36 canvas.drawImage(image, 0, 0, NULL);
39 37
40 uint32_t pixel = 0; 38 uint32_t pixel = 0;
41 SkImageInfo info = SkImageInfo::Make(1, 1, kBGRA_8888_SkColorType, kUnpremul _SkAlphaType); 39 SkImageInfo info = SkImageInfo::Make(1, 1, kBGRA_8888_SkColorType, kUnpremul _SkAlphaType);
42 canvas.readPixels(info, &pixel, 4, 0, 0); 40 canvas.readPixels(info, &pixel, 4, 0, 0);
43 REPORTER_ASSERT(reporter, pixel == SK_ColorGREEN); 41 REPORTER_ASSERT(reporter, pixel == SK_ColorGREEN);
44 canvas.readPixels(info, &pixel, 4, gWidth - 6, gWidth - 6); 42 canvas.readPixels(info, &pixel, 4, gWidth - 6, gWidth - 6);
45 REPORTER_ASSERT(reporter, pixel == SK_ColorGREEN); 43 REPORTER_ASSERT(reporter, pixel == SK_ColorGREEN);
46 44
47 canvas.readPixels(info, &pixel, 4, gWidth - 5, gWidth - 5); 45 canvas.readPixels(info, &pixel, 4, gWidth - 5, gWidth - 5);
48 REPORTER_ASSERT(reporter, pixel == SK_ColorTRANSPARENT); 46 REPORTER_ASSERT(reporter, pixel == SK_ColorTRANSPARENT);
49 } 47 }
OLDNEW
« no previous file with comments | « tests/ReadPixelsTest.cpp ('k') | tests/WritePixelsTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698