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

Side by Side Diff: gm/xfermodes.cpp

Issue 789033002: Remove SkCanvas::drawBitmapMatrix() (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: non-const canvas ptr Created 6 years 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/filterindiabox.cpp ('k') | gyp/gmslides.gypi » ('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 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 #include "gm.h" 8 #include "gm.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkShader.h" 10 #include "SkShader.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 * uses the implied shape of the drawing command and these modes 77 * uses the implied shape of the drawing command and these modes
78 * demonstrate that. 78 * demonstrate that.
79 */ 79 */
80 void draw_mode(SkCanvas* canvas, SkXfermode* mode, SrcType srcType, 80 void draw_mode(SkCanvas* canvas, SkXfermode* mode, SrcType srcType,
81 SkScalar x, SkScalar y) { 81 SkScalar x, SkScalar y) {
82 SkPaint p; 82 SkPaint p;
83 SkMatrix m; 83 SkMatrix m;
84 bool restoreNeeded = false; 84 bool restoreNeeded = false;
85 m.setTranslate(x, y); 85 m.setTranslate(x, y);
86 86
87 canvas->drawBitmapMatrix(fSrcB, m, &p); 87 canvas->drawBitmap(fSrcB, x, y, &p);
88 p.setXfermode(mode); 88 p.setXfermode(mode);
89 switch (srcType) { 89 switch (srcType) {
90 case kSmallTransparentImage_SrcType: 90 case kSmallTransparentImage_SrcType: {
91 m.postScale(SK_ScalarHalf, SK_ScalarHalf, x, y); 91 m.postScale(SK_ScalarHalf, SK_ScalarHalf, x, y);
92 canvas->drawBitmapMatrix(fTransparent, m, &p); 92
93 SkAutoCanvasRestore acr(canvas, true);
94 canvas->concat(m);
95 canvas->drawBitmap(fTransparent, 0, 0, &p);
93 break; 96 break;
97 }
94 case kQuarterClearInLayer_SrcType: { 98 case kQuarterClearInLayer_SrcType: {
95 SkRect bounds = SkRect::MakeXYWH(x, y, SkIntToScalar(W), 99 SkRect bounds = SkRect::MakeXYWH(x, y, SkIntToScalar(W),
96 SkIntToScalar(H)); 100 SkIntToScalar(H));
97 canvas->saveLayer(&bounds, &p); 101 canvas->saveLayer(&bounds, &p);
98 restoreNeeded = true; 102 restoreNeeded = true;
99 p.setXfermodeMode(SkXfermode::kSrcOver_Mode); 103 p.setXfermodeMode(SkXfermode::kSrcOver_Mode);
100 // Fall through. 104 // Fall through.
101 } 105 }
102 case kQuarterClear_SrcType: { 106 case kQuarterClear_SrcType: {
103 SkScalar halfW = SkIntToScalar(W) / 2; 107 SkScalar halfW = SkIntToScalar(W) / 2;
(...skipping 24 matching lines...) Expand all
128 p.setColor(0xFF66AAFF); 132 p.setColor(0xFF66AAFF);
129 canvas->drawRect(r, p); 133 canvas->drawRect(r, p);
130 break; 134 break;
131 } 135 }
132 case kSmallRectangleImageWithAlpha_SrcType: 136 case kSmallRectangleImageWithAlpha_SrcType:
133 m.postScale(SK_ScalarHalf, SK_ScalarHalf, x, y); 137 m.postScale(SK_ScalarHalf, SK_ScalarHalf, x, y);
134 // Fall through. 138 // Fall through.
135 case kRectangleImageWithAlpha_SrcType: 139 case kRectangleImageWithAlpha_SrcType:
136 p.setAlpha(0x88); 140 p.setAlpha(0x88);
137 // Fall through. 141 // Fall through.
138 case kRectangleImage_SrcType: 142 case kRectangleImage_SrcType: {
139 canvas->drawBitmapMatrix(fDstB, m, &p); 143 SkAutoCanvasRestore acr(canvas, true);
144 canvas->concat(m);
145 canvas->drawBitmap(fDstB, 0, 0, &p);
140 break; 146 break;
147 }
141 default: 148 default:
142 break; 149 break;
143 } 150 }
144 151
145 if (restoreNeeded) { 152 if (restoreNeeded) {
146 canvas->restore(); 153 canvas->restore();
147 } 154 }
148 } 155 }
149 156
150 virtual void onOnceBeforeDraw() SK_OVERRIDE { 157 virtual void onOnceBeforeDraw() SK_OVERRIDE {
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 private: 291 private:
285 typedef GM INHERITED; 292 typedef GM INHERITED;
286 }; 293 };
287 294
288 ////////////////////////////////////////////////////////////////////////////// 295 //////////////////////////////////////////////////////////////////////////////
289 296
290 static GM* MyFactory(void*) { return new XfermodesGM; } 297 static GM* MyFactory(void*) { return new XfermodesGM; }
291 static GMRegistry reg(MyFactory); 298 static GMRegistry reg(MyFactory);
292 299
293 } 300 }
OLDNEW
« no previous file with comments | « gm/filterindiabox.cpp ('k') | gyp/gmslides.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698