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

Side by Side Diff: gm/resizeimagefilter.cpp

Issue 182983003: Factory methods for heap-allocated SkImageFilter objects. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rebase Created 6 years, 9 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/pictureimagefilter.cpp ('k') | gm/spritebitmap.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 "SkColor.h" 9 #include "SkColor.h"
10 #include "SkResizeImageFilter.h" 10 #include "SkResizeImageFilter.h"
(...skipping 17 matching lines...) Expand all
28 SkPaint::FilterLevel filterLevel) { 28 SkPaint::FilterLevel filterLevel) {
29 SkRect dstRect; 29 SkRect dstRect;
30 canvas->getTotalMatrix().mapRect(&dstRect, rect); 30 canvas->getTotalMatrix().mapRect(&dstRect, rect);
31 canvas->save(); 31 canvas->save();
32 SkScalar deviceScaleX = SkScalarDiv(deviceSize.width(), dstRect.width()) ; 32 SkScalar deviceScaleX = SkScalarDiv(deviceSize.width(), dstRect.width()) ;
33 SkScalar deviceScaleY = SkScalarDiv(deviceSize.height(), dstRect.height( )); 33 SkScalar deviceScaleY = SkScalarDiv(deviceSize.height(), dstRect.height( ));
34 canvas->translate(rect.x(), rect.y()); 34 canvas->translate(rect.x(), rect.y());
35 canvas->scale(deviceScaleX, deviceScaleY); 35 canvas->scale(deviceScaleX, deviceScaleY);
36 canvas->translate(-rect.x(), -rect.y()); 36 canvas->translate(-rect.x(), -rect.y());
37 SkAutoTUnref<SkImageFilter> imageFilter( 37 SkAutoTUnref<SkImageFilter> imageFilter(
38 new SkResizeImageFilter(SkScalarInvert(deviceScaleX), 38 SkResizeImageFilter::Create(SkScalarInvert(deviceScaleX),
39 SkScalarInvert(deviceScaleY), 39 SkScalarInvert(deviceScaleY),
40 filterLevel)); 40 filterLevel));
41 SkPaint filteredPaint; 41 SkPaint filteredPaint;
42 filteredPaint.setImageFilter(imageFilter.get()); 42 filteredPaint.setImageFilter(imageFilter.get());
43 canvas->saveLayer(&rect, &filteredPaint); 43 canvas->saveLayer(&rect, &filteredPaint);
44 SkPaint paint; 44 SkPaint paint;
45 paint.setColor(0xFF00FF00); 45 paint.setColor(0xFF00FF00);
46 SkRect ovalRect = rect; 46 SkRect ovalRect = rect;
47 ovalRect.inset(SkIntToScalar(4), SkIntToScalar(4)); 47 ovalRect.inset(SkIntToScalar(4), SkIntToScalar(4));
48 canvas->drawOval(ovalRect, paint); 48 canvas->drawOval(ovalRect, paint);
49 canvas->restore(); // for saveLayer 49 canvas->restore(); // for saveLayer
50 canvas->restore(); 50 canvas->restore();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 private: 87 private:
88 typedef GM INHERITED; 88 typedef GM INHERITED;
89 }; 89 };
90 90
91 ////////////////////////////////////////////////////////////////////////////// 91 //////////////////////////////////////////////////////////////////////////////
92 92
93 static GM* MyFactory(void*) { return new ResizeGM; } 93 static GM* MyFactory(void*) { return new ResizeGM; }
94 static GMRegistry reg(MyFactory); 94 static GMRegistry reg(MyFactory);
95 95
96 } 96 }
OLDNEW
« no previous file with comments | « gm/pictureimagefilter.cpp ('k') | gm/spritebitmap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698