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

Side by Side Diff: gm/bmpfilterqualityrepeat.cpp

Issue 1182403003: Revert of Revert of make gm background colors 565 compatible (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 6 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/blurs.cpp ('k') | gm/clipdrawdraw.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 #include "gm.h" 8 #include "gm.h"
9 9
10 #include "SkShader.h" 10 #include "SkShader.h"
11 11
12 // Inspired by svg/as-border-image/svg-as-border-image.html. Draws a four-color checker board bitmap 12 // Inspired by svg/as-border-image/svg-as-border-image.html. Draws a four-color checker board bitmap
13 // such that it is stretched and repeat tiled with different filter qualities. I t is testing whether 13 // such that it is stretched and repeat tiled with different filter qualities. I t is testing whether
14 // the bmp filter respects the repeat mode at the tile seams. 14 // the bmp filter respects the repeat mode at the tile seams.
15 class BmpFilterQualityRepeat : public skiagm::GM { 15 class BmpFilterQualityRepeat : public skiagm::GM {
16 public: 16 public:
17 BmpFilterQualityRepeat() { this->setBGColor(0xFFCCBBAA); } 17 BmpFilterQualityRepeat() { this->setBGColor(sk_tool_utils::color_to_565(0xFF CCBBAA)); }
18 18
19 protected: 19 protected:
20 20
21 void onOnceBeforeDraw() override { 21 void onOnceBeforeDraw() override {
22 fBmp.allocN32Pixels(40, 40, true); 22 fBmp.allocN32Pixels(40, 40, true);
23 SkCanvas canvas(fBmp); 23 SkCanvas canvas(fBmp);
24 SkBitmap colorBmp; 24 SkBitmap colorBmp;
25 colorBmp.allocN32Pixels(20, 20, true); 25 colorBmp.allocN32Pixels(20, 20, true);
26 colorBmp.eraseColor(0xFFFF0000); 26 colorBmp.eraseColor(0xFFFF0000);
27 canvas.drawBitmap(colorBmp, 0, 0); 27 canvas.drawBitmap(colorBmp, 0, 0);
(...skipping 16 matching lines...) Expand all
44 const char* fName; 44 const char* fName;
45 } kQualities[] = { 45 } kQualities[] = {
46 {kNone_SkFilterQuality, "none"}, 46 {kNone_SkFilterQuality, "none"},
47 {kLow_SkFilterQuality, "low"}, 47 {kLow_SkFilterQuality, "low"},
48 {kMedium_SkFilterQuality, "medium"}, 48 {kMedium_SkFilterQuality, "medium"},
49 {kHigh_SkFilterQuality, "high"}, 49 {kHigh_SkFilterQuality, "high"},
50 }; 50 };
51 51
52 for (size_t q = 0; q < SK_ARRAY_COUNT(kQualities); ++q) { 52 for (size_t q = 0; q < SK_ARRAY_COUNT(kQualities); ++q) {
53 SkPaint paint; 53 SkPaint paint;
54 sk_tool_utils::set_portable_typeface_always(&paint);
54 paint.setFilterQuality(kQualities[q].fQuality); 55 paint.setFilterQuality(kQualities[q].fQuality);
55 SkPaint bmpPaint(paint); 56 SkPaint bmpPaint(paint);
56 SkMatrix lm = SkMatrix::I(); 57 SkMatrix lm = SkMatrix::I();
57 lm.setScaleX(2.5); 58 lm.setScaleX(2.5);
58 lm.setTranslateX(423); 59 lm.setTranslateX(423);
59 lm.setTranslateY(330); 60 lm.setTranslateY(330);
60 61
61 static const SkShader::TileMode kTM = SkShader::kRepeat_TileMode; 62 static const SkShader::TileMode kTM = SkShader::kRepeat_TileMode;
62 bmpPaint.setShader(SkShader::CreateBitmapShader(fBmp, kTM, kTM, &lm) )->unref(); 63 bmpPaint.setShader(SkShader::CreateBitmapShader(fBmp, kTM, kTM, &lm) )->unref();
63 SkRect rect = SkRect::MakeLTRB(20, 60, 220, 210); 64 SkRect rect = SkRect::MakeLTRB(20, 60, 220, 210);
64 canvas->drawRect(rect, bmpPaint); 65 canvas->drawRect(rect, bmpPaint);
65 paint.setAntiAlias(true); 66 paint.setAntiAlias(true);
66 canvas->drawText(kQualities[q].fName, strlen(kQualities[q].fName), 2 0, 40, paint); 67 canvas->drawText(kQualities[q].fName, strlen(kQualities[q].fName), 2 0, 40, paint);
67 canvas->translate(250, 0); 68 canvas->translate(250, 0);
68 } 69 }
69 } 70 }
70 71
71 private: 72 private:
72 SkBitmap fBmp; 73 SkBitmap fBmp;
73 74
74 typedef skiagm::GM INHERITED; 75 typedef skiagm::GM INHERITED;
75 }; 76 };
76 77
77 ////////////////////////////////////////////////////////////////////////////// 78 //////////////////////////////////////////////////////////////////////////////
78 79
79 DEF_GM( return SkNEW(BmpFilterQualityRepeat); ) 80 DEF_GM( return SkNEW(BmpFilterQualityRepeat); )
OLDNEW
« no previous file with comments | « gm/blurs.cpp ('k') | gm/clipdrawdraw.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698