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

Side by Side Diff: samplecode/SampleFilterQuality.cpp

Issue 1364443002: remove unused (by the outside) SkImage::newSurface, and simplify newImage -> newSubset (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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 | « include/core/SkImage.h ('k') | src/image/SkImage.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 "gm.h" 8 #include "gm.h"
9 9
10 #include "Resources.h" 10 #include "Resources.h"
(...skipping 28 matching lines...) Expand all
39 path.setFillType(SkPath::kEvenOdd_FillType); 39 path.setFillType(SkPath::kEvenOdd_FillType);
40 40
41 path.addRect(SkRect::MakeWH(N/2, N)); 41 path.addRect(SkRect::MakeWH(N/2, N));
42 path.addRect(SkRect::MakeWH(N, N/2)); 42 path.addRect(SkRect::MakeWH(N, N/2));
43 path.moveTo(0, 0); path.lineTo(N, 0); path.lineTo(0, N); path.close(); 43 path.moveTo(0, 0); path.lineTo(N, 0); path.lineTo(0, N); path.close();
44 44
45 canvas->drawPath(path, SkPaint()); 45 canvas->drawPath(path, SkPaint());
46 return surface->newImageSnapshot(); 46 return surface->newImageSnapshot();
47 } 47 }
48 48
49 static SkImage* zoom_up(SkImage* orig) { 49 static SkImage* zoom_up(SkSurface* origSurf, SkImage* orig) {
50 const SkScalar S = 8; // amount to scale up 50 const SkScalar S = 8; // amount to scale up
51 const int D = 2; // dimension scaling for the offscreen 51 const int D = 2; // dimension scaling for the offscreen
52 // since we only view the center, don't need to produce the entire thing 52 // since we only view the center, don't need to produce the entire thing
53 53
54 SkImageInfo info = SkImageInfo::MakeN32(orig->width() * D, orig->height() * D, 54 SkImageInfo info = SkImageInfo::MakeN32(orig->width() * D, orig->height() * D,
55 kOpaque_SkAlphaType); 55 kOpaque_SkAlphaType);
56 SkAutoTUnref<SkSurface> surface(orig->newSurface(info)); 56 SkAutoTUnref<SkSurface> surface(origSurf->newSurface(info));
57 SkCanvas* canvas = surface->getCanvas(); 57 SkCanvas* canvas = surface->getCanvas();
58 canvas->drawColor(SK_ColorWHITE); 58 canvas->drawColor(SK_ColorWHITE);
59 canvas->scale(S, S); 59 canvas->scale(S, S);
60 canvas->translate(-SkScalarHalf(orig->width()) * (S - D) / S, 60 canvas->translate(-SkScalarHalf(orig->width()) * (S - D) / S,
61 -SkScalarHalf(orig->height()) * (S - D) / S); 61 -SkScalarHalf(orig->height()) * (S - D) / S);
62 canvas->drawImage(orig, 0, 0, nullptr); 62 canvas->drawImage(orig, 0, 0, nullptr);
63 63
64 if (S > 3) { 64 if (S > 3) {
65 SkPaint paint; 65 SkPaint paint;
66 paint.setColor(SK_ColorWHITE); 66 paint.setColor(SK_ColorWHITE);
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 canvas->drawColor(SK_ColorWHITE); 214 canvas->drawColor(SK_ColorWHITE);
215 size.set(info.width(), info.height()); 215 size.set(info.width(), info.height());
216 } else { 216 } else {
217 canvas->translate(SkScalarHalf(fCell.width() - fImage->width()), 217 canvas->translate(SkScalarHalf(fCell.width() - fImage->width()),
218 SkScalarHalf(fCell.height() - fImage->height())); 218 SkScalarHalf(fCell.height() - fImage->height()));
219 } 219 }
220 this->drawTheImage(canvas, size, filter, dx, dy); 220 this->drawTheImage(canvas, size, filter, dx, dy);
221 221
222 if (surface) { 222 if (surface) {
223 SkAutoTUnref<SkImage> orig(surface->newImageSnapshot()); 223 SkAutoTUnref<SkImage> orig(surface->newImageSnapshot());
224 SkAutoTUnref<SkImage> zoomed(zoom_up(orig)); 224 SkAutoTUnref<SkImage> zoomed(zoom_up(surface, orig));
225 origCanvas->drawImage(zoomed, 225 origCanvas->drawImage(zoomed,
226 SkScalarHalf(fCell.width() - zoomed->width()), 226 SkScalarHalf(fCell.width() - zoomed->width()),
227 SkScalarHalf(fCell.height() - zoomed->height() )); 227 SkScalarHalf(fCell.height() - zoomed->height() ));
228 } 228 }
229 } 229 }
230 230
231 void drawBorders(SkCanvas* canvas) { 231 void drawBorders(SkCanvas* canvas) {
232 SkPaint p; 232 SkPaint p;
233 p.setStyle(SkPaint::kStroke_Style); 233 p.setStyle(SkPaint::kStroke_Style);
234 p.setColor(SK_ColorBLUE); 234 p.setColor(SK_ColorBLUE);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 } 288 }
289 289
290 private: 290 private:
291 typedef SampleView INHERITED; 291 typedef SampleView INHERITED;
292 }; 292 };
293 293
294 ////////////////////////////////////////////////////////////////////////////// 294 //////////////////////////////////////////////////////////////////////////////
295 295
296 static SkView* MyFactory() { return new FilterQualityView; } 296 static SkView* MyFactory() { return new FilterQualityView; }
297 static SkViewRegister reg(MyFactory); 297 static SkViewRegister reg(MyFactory);
OLDNEW
« no previous file with comments | « include/core/SkImage.h ('k') | src/image/SkImage.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698