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

Side by Side Diff: gm/xfermodes.cpp

Issue 45953005: Fix int/SkScalar mismatch in gm. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 SkScalar x, SkScalar y) { 75 SkScalar x, SkScalar y) {
76 SkPaint p; 76 SkPaint p;
77 SkMatrix m; 77 SkMatrix m;
78 bool restoreNeeded = false; 78 bool restoreNeeded = false;
79 m.setTranslate(x, y); 79 m.setTranslate(x, y);
80 80
81 canvas->drawBitmapMatrix(fSrcB, m, &p); 81 canvas->drawBitmapMatrix(fSrcB, m, &p);
82 p.setXfermode(mode); 82 p.setXfermode(mode);
83 switch (srcType) { 83 switch (srcType) {
84 case kQuarterClearInLayer_SrcType: { 84 case kQuarterClearInLayer_SrcType: {
85 SkRect bounds = SkRect::MakeXYWH(x, y, W, H); 85 SkRect bounds = SkRect::MakeXYWH(x, y, SkIntToScalar(W),
86 SkIntToScalar(H));
86 canvas->saveLayer(&bounds, &p); 87 canvas->saveLayer(&bounds, &p);
87 restoreNeeded = true; 88 restoreNeeded = true;
88 p.setXfermodeMode(SkXfermode::kSrcOver_Mode); 89 p.setXfermodeMode(SkXfermode::kSrcOver_Mode);
89 // Fall through. 90 // Fall through.
90 } 91 }
91 case kQuarterClear_SrcType: { 92 case kQuarterClear_SrcType: {
92 SkScalar halfW = SkIntToScalar(W) / 2; 93 SkScalar halfW = SkIntToScalar(W) / 2;
93 SkScalar halfH = SkIntToScalar(H) / 2; 94 SkScalar halfH = SkIntToScalar(H) / 2;
94 p.setColor(0xFF66AAFF); 95 p.setColor(0xFF66AAFF);
95 SkRect r = SkRect::MakeXYWH(x + halfW, y, halfW, H); 96 SkRect r = SkRect::MakeXYWH(x + halfW, y, halfW,
97 SkIntToScalar(H));
96 canvas->drawRect(r, p); 98 canvas->drawRect(r, p);
97 p.setColor(0xFFAA66FF); 99 p.setColor(0xFFAA66FF);
98 r = SkRect::MakeXYWH(x, y + halfH, W, halfH); 100 r = SkRect::MakeXYWH(x, y + halfH, SkIntToScalar(W), halfH);
99 canvas->drawRect(r, p); 101 canvas->drawRect(r, p);
100 break; 102 break;
101 } 103 }
102 case kRectangle_SrcType: { 104 case kRectangle_SrcType: {
103 SkScalar w = SkIntToScalar(W); 105 SkScalar w = SkIntToScalar(W);
104 SkScalar h = SkIntToScalar(H); 106 SkScalar h = SkIntToScalar(H);
105 SkRect r = SkRect::MakeXYWH(x + w / 3, y + h / 3, 107 SkRect r = SkRect::MakeXYWH(x + w / 3, y + h / 3,
106 w * 37 / 60, h * 37 / 60); 108 w * 37 / 60, h * 37 / 60);
107 p.setColor(0xFF66AAFF); 109 p.setColor(0xFF66AAFF);
108 canvas->drawRect(r, p); 110 canvas->drawRect(r, p);
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 private: 263 private:
262 typedef GM INHERITED; 264 typedef GM INHERITED;
263 }; 265 };
264 266
265 ////////////////////////////////////////////////////////////////////////////// 267 //////////////////////////////////////////////////////////////////////////////
266 268
267 static GM* MyFactory(void*) { return new XfermodesGM; } 269 static GM* MyFactory(void*) { return new XfermodesGM; }
268 static GMRegistry reg(MyFactory); 270 static GMRegistry reg(MyFactory);
269 271
270 } 272 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698