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

Unified Diff: gm/aaxfermodes.cpp

Issue 2396953002: Revert[8] "replace SkXfermode obj with SkBlendMode enum in paints" (Closed)
Patch Set: add tmp virtual to unroll legacy arithmodes Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gm/aarectmodes.cpp ('k') | gm/bitmaprect.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/aaxfermodes.cpp
diff --git a/gm/aaxfermodes.cpp b/gm/aaxfermodes.cpp
index 678a8379e39a33b3669645439ceb3ae2eb2e33a7..7106ce817409afe06e21d7e8a9aa97b8517932a1 100644
--- a/gm/aaxfermodes.cpp
+++ b/gm/aaxfermodes.cpp
@@ -121,7 +121,7 @@ protected:
if (firstMode + m > SkXfermode::kLastMode) {
break;
}
- SkXfermode::Mode mode = static_cast<SkXfermode::Mode>(firstMode + m);
+ SkBlendMode mode = static_cast<SkBlendMode>(firstMode + m);
canvas->save();
if (kShape_Pass == drawingPass) {
@@ -144,7 +144,7 @@ protected:
10);
} else {
SkASSERT(kBackground_Pass == drawingPass);
- canvas->drawColor(kBGColor, SkXfermode::kSrc_Mode);
+ canvas->drawColor(kBGColor, SkBlendMode::kSrc);
}
canvas->restore();
} else {
@@ -190,18 +190,17 @@ protected:
canvas->restore();
}
- void drawModeName(SkCanvas* canvas, SkXfermode::Mode mode) {
- const char* modeName = mode <= SkXfermode::kLastMode ? SkXfermode::ModeName(mode)
- : "Arithmetic";
+ void drawModeName(SkCanvas* canvas, SkBlendMode mode) {
+ const char* modeName = SkXfermode::ModeName(mode);
fLabelPaint.setTextAlign(SkPaint::kRight_Align);
canvas->drawText(modeName, strlen(modeName), kLabelSpacing - kShapeSize / 4,
fLabelPaint.getTextSize() / 4, fLabelPaint);
}
- void setupShapePaint(SkCanvas* canvas, GrColor color, SkXfermode::Mode mode, SkPaint* paint) {
+ void setupShapePaint(SkCanvas* canvas, GrColor color, SkBlendMode mode, SkPaint* paint) {
paint->setColor(color);
- if (mode == SkXfermode::kPlus_Mode) {
+ if (mode == SkBlendMode::kPlus) {
// Check for overflow, otherwise we might get confusing AA artifacts.
int maxSum = SkTMax(SkTMax(SkColorGetA(kBGColor) + SkColorGetA(color),
SkColorGetR(kBGColor) + SkColorGetR(color)),
@@ -211,7 +210,7 @@ protected:
if (maxSum > 255) {
SkPaint dimPaint;
dimPaint.setAntiAlias(false);
- dimPaint.setXfermodeMode(SkXfermode::kDstIn_Mode);
+ dimPaint.setBlendMode(SkBlendMode::kDstIn);
if (255 != paint->getAlpha()) {
// Dim the src and dst colors.
dimPaint.setARGB(255 * 255 / maxSum, 0, 0, 0);
@@ -227,11 +226,11 @@ protected:
}
}
- void drawShape(SkCanvas* canvas, Shape shape, const SkPaint& paint, SkXfermode::Mode mode) {
- SkASSERT(mode <= SkXfermode::kLastMode);
+ void drawShape(SkCanvas* canvas, Shape shape, const SkPaint& paint, SkBlendMode mode) {
+ SkASSERT(mode <= SkBlendMode::kLastMode);
SkPaint shapePaint(paint);
shapePaint.setAntiAlias(kSquare_Shape != shape);
- shapePaint.setXfermodeMode(mode);
+ shapePaint.setBlendMode(mode);
switch (shape) {
case kSquare_Shape:
@@ -249,7 +248,7 @@ protected:
case kOval_Shape:
canvas->save();
- canvas->rotate(static_cast<SkScalar>((511 * mode + 257) % 360));
+ canvas->rotate(static_cast<SkScalar>((511 * (int)mode + 257) % 360));
canvas->drawPath(fOval, shapePaint);
canvas->restore();
break;
« no previous file with comments | « gm/aarectmodes.cpp ('k') | gm/bitmaprect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698