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

Side by Side Diff: gm/lcdoverlap.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 unified diff | Download patch
« no previous file with comments | « gm/lcdblendmodes.cpp ('k') | gm/lumafilter.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 2015 Google Inc. 2 * Copyright 2015 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 8
9 /* 9 /*
10 * Tests overlapping LCD text 10 * Tests overlapping LCD text
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 const char* text = "able was I ere I saw elba"; 42 const char* text = "able was I ere I saw elba";
43 paint.setAntiAlias(true); 43 paint.setAntiAlias(true);
44 paint.setSubpixelText(true); 44 paint.setSubpixelText(true);
45 paint.setLCDRenderText(true); 45 paint.setLCDRenderText(true);
46 sk_tool_utils::add_to_text_blob(&builder, text, paint, 0, 0); 46 sk_tool_utils::add_to_text_blob(&builder, text, paint, 0, 0);
47 fBlob = builder.make(); 47 fBlob = builder.make();
48 } 48 }
49 49
50 SkISize onISize() override { return SkISize::Make(kWidth, kHeight); } 50 SkISize onISize() override { return SkISize::Make(kWidth, kHeight); }
51 51
52 void drawTestCase(SkCanvas* canvas, SkScalar x, SkScalar y, SkXfermode::Mode mode, 52 void drawTestCase(SkCanvas* canvas, SkScalar x, SkScalar y, SkBlendMode mode ,
53 SkXfermode::Mode mode2) { 53 SkBlendMode mode2) {
54 const SkColor colors[] { 54 const SkColor colors[] {
55 SK_ColorRED, 55 SK_ColorRED,
56 SK_ColorGREEN, 56 SK_ColorGREEN,
57 SK_ColorBLUE, 57 SK_ColorBLUE,
58 SK_ColorYELLOW, 58 SK_ColorYELLOW,
59 SK_ColorCYAN, 59 SK_ColorCYAN,
60 SK_ColorMAGENTA, 60 SK_ColorMAGENTA,
61 }; 61 };
62 62
63 sk_sp<SkXfermode> xfermode(SkXfermode::Make(mode));
64 sk_sp<SkXfermode> xfermode2(SkXfermode::Make(mode2));
65 for (size_t i = 0; i < SK_ARRAY_COUNT(colors); i++) { 63 for (size_t i = 0; i < SK_ARRAY_COUNT(colors); i++) {
66 canvas->save(); 64 canvas->save();
67 canvas->translate(x, y); 65 canvas->translate(x, y);
68 canvas->rotate(360.0f / SK_ARRAY_COUNT(colors) * i); 66 canvas->rotate(360.0f / SK_ARRAY_COUNT(colors) * i);
69 canvas->translate(-fBlob->bounds().width() / 2.0f + 0.5f, 0); 67 canvas->translate(-fBlob->bounds().width() / 2.0f + 0.5f, 0);
70 68
71 SkPaint textPaint; 69 SkPaint textPaint;
72 textPaint.setColor(colors[i]); 70 textPaint.setColor(colors[i]);
73 textPaint.setXfermode(i % 2 == 0 ? xfermode : xfermode2); 71 textPaint.setBlendMode(i % 2 == 0 ? mode : mode2);
74 canvas->drawTextBlob(fBlob, 0, 0, textPaint); 72 canvas->drawTextBlob(fBlob, 0, 0, textPaint);
75 canvas->restore(); 73 canvas->restore();
76 } 74 }
77 } 75 }
78 76
79 void onDraw(SkCanvas* canvas) override { 77 void onDraw(SkCanvas* canvas) override {
80 SkScalar offsetX = kWidth / 4.0f; 78 SkScalar offsetX = kWidth / 4.0f;
81 SkScalar offsetY = kHeight / 4.0f; 79 SkScalar offsetY = kHeight / 4.0f;
82 drawTestCase(canvas, offsetX, offsetY, SkXfermode::kSrc_Mode, SkXfermod e::kSrc_Mode); 80 drawTestCase(canvas, offsetX, offsetY, SkBlendMode::kSrc, SkBlendMode:: kSrc);
83 drawTestCase(canvas, 3 * offsetX, offsetY, SkXfermode::kSrcOver_Mode, 81 drawTestCase(canvas, 3 * offsetX, offsetY, SkBlendMode::kSrcOver, SkBle ndMode::kSrcOver);
84 SkXfermode::kSrcOver_Mode); 82 drawTestCase(canvas, offsetX, 3 * offsetY, SkBlendMode::kHardLight,
85 drawTestCase(canvas, offsetX, 3 * offsetY, SkXfermode::kHardLight_Mode, 83 SkBlendMode::kLuminosity);
86 SkXfermode::kLuminosity_Mode); 84 drawTestCase(canvas, 3 * offsetX, 3 * offsetY, SkBlendMode::kSrcOver, S kBlendMode::kSrc);
87 drawTestCase(canvas, 3 * offsetX, 3 * offsetY, SkXfermode::kSrcOver_Mod e,
88 SkXfermode::kSrc_Mode);
89 } 85 }
90 86
91 private: 87 private:
92 SkScalar fTextHeight; 88 SkScalar fTextHeight;
93 sk_sp<SkTextBlob> fBlob; 89 sk_sp<SkTextBlob> fBlob;
94 typedef skiagm::GM INHERITED; 90 typedef skiagm::GM INHERITED;
95 }; 91 };
96 92
97 ////////////////////////////////////////////////////////////////////////////// 93 //////////////////////////////////////////////////////////////////////////////
98 94
99 DEF_GM( return new LcdOverlapGM; ) 95 DEF_GM( return new LcdOverlapGM; )
100 } 96 }
OLDNEW
« no previous file with comments | « gm/lcdblendmodes.cpp ('k') | gm/lumafilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698