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

Side by Side Diff: gm/resizeimagefilter.cpp

Issue 1343123002: Convert unit tests, GMs from SkBitmapSource to SkImagesource (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: review comments Created 5 years, 3 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 | « gm/offsetimagefilter.cpp ('k') | gm/tileimagefilter.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 2013 Google Inc. 2 * Copyright 2013 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 "gm.h" 8 #include "gm.h"
9 #include "SkBitmapSource.h"
10 #include "SkColor.h" 9 #include "SkColor.h"
10 #include "SkImageSource.h"
11 #include "SkRefCnt.h" 11 #include "SkRefCnt.h"
12 #include "SkSurface.h"
12 13
13 namespace skiagm { 14 namespace skiagm {
14 15
15 class ResizeGM : public GM { 16 class ResizeGM : public GM {
16 public: 17 public:
17 ResizeGM() { 18 ResizeGM() {
18 this->setBGColor(0x00000000); 19 this->setBGColor(0x00000000);
19 } 20 }
20 21
21 protected: 22 protected:
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 srcRect, 80 srcRect,
80 deviceSize, 81 deviceSize,
81 kMedium_SkFilterQuality); 82 kMedium_SkFilterQuality);
82 83
83 canvas->translate(srcRect.width() + SkIntToScalar(10), 0); 84 canvas->translate(srcRect.width() + SkIntToScalar(10), 0);
84 draw(canvas, 85 draw(canvas,
85 srcRect, 86 srcRect,
86 deviceSize, 87 deviceSize,
87 kHigh_SkFilterQuality); 88 kHigh_SkFilterQuality);
88 89
89 SkBitmap bitmap; 90 SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(16, 16));
90 bitmap.allocN32Pixels(16, 16); 91 SkCanvas* surfaceCanvas = surface->getCanvas();
91 bitmap.eraseARGB(0x00, 0x00, 0x00, 0x00); 92 surfaceCanvas->clear(0x000000);
92 { 93 {
93 SkCanvas bitmapCanvas(bitmap);
94 SkPaint paint; 94 SkPaint paint;
95 paint.setColor(0xFF00FF00); 95 paint.setColor(0xFF00FF00);
96 SkRect ovalRect = SkRect::MakeWH(16, 16); 96 SkRect ovalRect = SkRect::MakeWH(16, 16);
97 ovalRect.inset(SkIntToScalar(2)/3, SkIntToScalar(2)/3); 97 ovalRect.inset(SkIntToScalar(2)/3, SkIntToScalar(2)/3);
98 bitmapCanvas.drawOval(ovalRect, paint); 98 surfaceCanvas->drawOval(ovalRect, paint);
99 } 99 }
100 SkAutoTUnref<SkImage> image(surface->newImageSnapshot());
100 SkRect inRect = SkRect::MakeXYWH(-4, -4, 20, 20); 101 SkRect inRect = SkRect::MakeXYWH(-4, -4, 20, 20);
101 SkRect outRect = SkRect::MakeXYWH(-24, -24, 120, 120); 102 SkRect outRect = SkRect::MakeXYWH(-24, -24, 120, 120);
102 SkAutoTUnref<SkBitmapSource> source(SkBitmapSource::Create(bitmap, inRec t, outRect)); 103 SkAutoTUnref<SkImageFilter> source(
104 SkImageSource::Create(image, inRect, outRect, kHigh_SkFilterQuality) );
103 canvas->translate(srcRect.width() + SkIntToScalar(10), 0); 105 canvas->translate(srcRect.width() + SkIntToScalar(10), 0);
104 draw(canvas, 106 draw(canvas,
105 srcRect, 107 srcRect,
106 deviceSize, 108 deviceSize,
107 kHigh_SkFilterQuality, 109 kHigh_SkFilterQuality,
108 source.get()); 110 source.get());
109 } 111 }
110 112
111 private: 113 private:
112 typedef GM INHERITED; 114 typedef GM INHERITED;
113 }; 115 };
114 116
115 ////////////////////////////////////////////////////////////////////////////// 117 //////////////////////////////////////////////////////////////////////////////
116 118
117 static GM* MyFactory(void*) { return new ResizeGM; } 119 static GM* MyFactory(void*) { return new ResizeGM; }
118 static GMRegistry reg(MyFactory); 120 static GMRegistry reg(MyFactory);
119 121
120 } 122 }
OLDNEW
« no previous file with comments | « gm/offsetimagefilter.cpp ('k') | gm/tileimagefilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698