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

Side by Side Diff: gm/bmpfilterqualityrepeat.cpp

Issue 2476713002: Fix kMediumQuality invMatrix setup for sizes == mip levels (Closed)
Patch Set: tweak comment Created 4 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
« no previous file with comments | « no previous file | src/core/SkBitmapProcState.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"
(...skipping 17 matching lines...) Expand all
28 colorBmp.eraseColor(sk_tool_utils::color_to_565(0xFF008200)); 28 colorBmp.eraseColor(sk_tool_utils::color_to_565(0xFF008200));
29 canvas.drawBitmap(colorBmp, 20, 0); 29 canvas.drawBitmap(colorBmp, 20, 0);
30 colorBmp.eraseColor(sk_tool_utils::color_to_565(0xFFFF9000)); 30 colorBmp.eraseColor(sk_tool_utils::color_to_565(0xFFFF9000));
31 canvas.drawBitmap(colorBmp, 0, 20); 31 canvas.drawBitmap(colorBmp, 0, 20);
32 colorBmp.eraseColor(sk_tool_utils::color_to_565(0xFF2000FF)); 32 colorBmp.eraseColor(sk_tool_utils::color_to_565(0xFF2000FF));
33 canvas.drawBitmap(colorBmp, 20, 20); 33 canvas.drawBitmap(colorBmp, 20, 20);
34 } 34 }
35 35
36 SkString onShortName() override { return SkString("bmp_filter_quality_repeat "); } 36 SkString onShortName() override { return SkString("bmp_filter_quality_repeat "); }
37 37
38 SkISize onISize() override { return SkISize::Make(1000, 235); } 38 SkISize onISize() override { return SkISize::Make(1000, 400); }
39 39
40 void onDraw(SkCanvas* canvas) override { 40 void onDraw(SkCanvas* canvas) override {
41 this->drawAll(canvas, 2.5f);
42 canvas->translate(0, 250);
43 canvas->scale(0.5, 0.5);
44 this->drawAll(canvas, 1);
45 }
41 46
47 private:
48 void drawAll(SkCanvas* canvas, SkScalar scaleX) const {
42 constexpr struct { 49 constexpr struct {
43 SkFilterQuality fQuality; 50 SkFilterQuality fQuality;
44 const char* fName; 51 const char* fName;
45 } kQualities[] = { 52 } kQualities[] = {
46 {kNone_SkFilterQuality, "none"}, 53 {kNone_SkFilterQuality, "none"},
47 {kLow_SkFilterQuality, "low"}, 54 {kLow_SkFilterQuality, "low"},
48 {kMedium_SkFilterQuality, "medium"}, 55 {kMedium_SkFilterQuality, "medium"},
49 {kHigh_SkFilterQuality, "high"}, 56 {kHigh_SkFilterQuality, "high"},
50 }; 57 };
51 58
59 SkRect rect = SkRect::MakeLTRB(20, 60, 220, 210);
60 SkMatrix lm = SkMatrix::I();
61 lm.setScaleX(scaleX);
62 lm.setTranslateX(423);
63 lm.setTranslateY(330);
64
65 SkPaint textPaint;
66 sk_tool_utils::set_portable_typeface(&textPaint);
67 textPaint.setAntiAlias(true);
68
69 SkPaint bmpPaint(textPaint);
70
71 SkAutoCanvasRestore acr(canvas, true);
72
52 for (size_t q = 0; q < SK_ARRAY_COUNT(kQualities); ++q) { 73 for (size_t q = 0; q < SK_ARRAY_COUNT(kQualities); ++q) {
53 SkPaint paint;
54 sk_tool_utils::set_portable_typeface(&paint);
55 paint.setFilterQuality(kQualities[q].fQuality);
56 SkPaint bmpPaint(paint);
57 SkMatrix lm = SkMatrix::I();
58 lm.setScaleX(2.5);
59 lm.setTranslateX(423);
60 lm.setTranslateY(330);
61
62 constexpr SkShader::TileMode kTM = SkShader::kRepeat_TileMode; 74 constexpr SkShader::TileMode kTM = SkShader::kRepeat_TileMode;
63 bmpPaint.setShader(SkShader::MakeBitmapShader(fBmp, kTM, kTM, &lm)); 75 bmpPaint.setShader(SkShader::MakeBitmapShader(fBmp, kTM, kTM, &lm));
64 SkRect rect = SkRect::MakeLTRB(20, 60, 220, 210); 76 bmpPaint.setFilterQuality(kQualities[q].fQuality);
65 canvas->drawRect(rect, bmpPaint); 77 canvas->drawRect(rect, bmpPaint);
66 paint.setAntiAlias(true); 78 canvas->drawText(kQualities[q].fName, strlen(kQualities[q].fName), 2 0, 40, textPaint);
67 canvas->drawText(kQualities[q].fName, strlen(kQualities[q].fName), 2 0, 40, paint);
68 canvas->translate(250, 0); 79 canvas->translate(250, 0);
69 } 80 }
81
70 } 82 }
71 83
72 private:
73 SkBitmap fBmp; 84 SkBitmap fBmp;
74 85
75 typedef skiagm::GM INHERITED; 86 typedef skiagm::GM INHERITED;
76 }; 87 };
77 88
78 ////////////////////////////////////////////////////////////////////////////// 89 //////////////////////////////////////////////////////////////////////////////
79 90
80 DEF_GM(return new BmpFilterQualityRepeat;) 91 DEF_GM(return new BmpFilterQualityRepeat;)
OLDNEW
« no previous file with comments | « no previous file | src/core/SkBitmapProcState.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698