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

Side by Side Diff: gm/drawbitmaprect.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, 2 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 | « no previous file | gm/image.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 2011 Google Inc. 2 * Copyright 2011 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 "SkBlurMask.h" 9 #include "SkBlurMask.h"
10 #include "SkBlurMaskFilter.h" 10 #include "SkBlurMaskFilter.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 static void canvasproc(SkCanvas* canvas, SkImage*, const SkBitmap& bm, const SkI Rect& srcR, 82 static void canvasproc(SkCanvas* canvas, SkImage*, const SkBitmap& bm, const SkI Rect& srcR,
83 const SkRect& dstR) { 83 const SkRect& dstR) {
84 canvas->drawBitmapRect(bm, srcR, dstR, nullptr); 84 canvas->drawBitmapRect(bm, srcR, dstR, nullptr);
85 } 85 }
86 86
87 static void imageproc(SkCanvas* canvas, SkImage* image, const SkBitmap&, const S kIRect& srcR, 87 static void imageproc(SkCanvas* canvas, SkImage* image, const SkBitmap&, const S kIRect& srcR,
88 const SkRect& dstR) { 88 const SkRect& dstR) {
89 canvas->drawImageRect(image, srcR, dstR, nullptr); 89 canvas->drawImageRect(image, srcR, dstR, nullptr);
90 } 90 }
91 91
92 static void imagescaleproc(SkCanvas* canvas, SkImage* image, const SkBitmap&, co nst SkIRect& srcIR,
93 const SkRect& dstR) {
94 const int newW = SkScalarRoundToInt(dstR.width());
95 const int newH = SkScalarRoundToInt(dstR.height());
96 SkAutoTUnref<SkImage> newImage(image->newImage(newW, newH, &srcIR));
97
98 #ifdef SK_DEBUG
99 const SkIRect baseR = SkIRect::MakeWH(image->width(), image->height());
100 const bool containsSubset = baseR.contains(srcIR);
101 #endif
102
103 if (newImage) {
104 SkASSERT(containsSubset);
105 canvas->drawImage(newImage, dstR.x(), dstR.y());
106 } else {
107 // newImage() does not support subsets that are not contained by the ori ginal
108 // but drawImageRect does, so we just draw an X in its place to indicate that we are
109 // deliberately not drawing here.
110 SkASSERT(!containsSubset);
111 SkPaint paint;
112 paint.setStyle(SkPaint::kStroke_Style);
113 paint.setStrokeWidth(4);
114 canvas->drawLine(4, 4, newW - 4.0f, newH - 4.0f, paint);
115 canvas->drawLine(4, newH - 4.0f, newW - 4.0f, 4, paint);
116 }
117 }
118
119 typedef void DrawRectRectProc(SkCanvas*, SkImage*, const SkBitmap&, const SkIRec t&, const SkRect&); 92 typedef void DrawRectRectProc(SkCanvas*, SkImage*, const SkBitmap&, const SkIRec t&, const SkRect&);
120 93
121 static const int gSize = 1024; 94 static const int gSize = 1024;
122 static const int gBmpSize = 2048; 95 static const int gBmpSize = 2048;
123 96
124 class DrawBitmapRectGM : public skiagm::GM { 97 class DrawBitmapRectGM : public skiagm::GM {
125 public: 98 public:
126 DrawBitmapRectGM(DrawRectRectProc proc, const char suffix[]) : fProc(proc) { 99 DrawBitmapRectGM(DrawRectRectProc proc, const char suffix[]) : fProc(proc) {
127 fName.set("drawbitmaprect"); 100 fName.set("drawbitmaprect");
128 if (suffix) { 101 if (suffix) {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 canvas->drawBitmapRect(bm, srcRect, dstRect, &paint); 194 canvas->drawBitmapRect(bm, srcRect, dstRect, &paint);
222 } 195 }
223 } 196 }
224 197
225 private: 198 private:
226 typedef skiagm::GM INHERITED; 199 typedef skiagm::GM INHERITED;
227 }; 200 };
228 201
229 DEF_GM( return new DrawBitmapRectGM(canvasproc, nullptr); ) 202 DEF_GM( return new DrawBitmapRectGM(canvasproc, nullptr); )
230 DEF_GM( return new DrawBitmapRectGM(imageproc, "-imagerect"); ) 203 DEF_GM( return new DrawBitmapRectGM(imageproc, "-imagerect"); )
231 DEF_GM( return new DrawBitmapRectGM(imagescaleproc, "-imagescale"); )
OLDNEW
« no previous file with comments | « no previous file | gm/image.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698