robertphillips@google.com | aaa9b29 | 2013-07-25 21:34:00 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2013 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #include "gm.h" |
robertphillips@google.com | b706117 | 2013-09-06 14:16:12 +0000 | [diff] [blame] | 9 | #include "SkBlurMask.h" |
robertphillips@google.com | 2cc0b47 | 2013-08-20 16:51:20 +0000 | [diff] [blame] | 10 | #include "SkBlurMaskFilter.h" |
robertphillips@google.com | b706117 | 2013-09-06 14:16:12 +0000 | [diff] [blame] | 11 | #include "SkCanvas.h" |
reed | a5517e2 | 2015-07-14 10:54:12 -0700 | [diff] [blame] | 12 | #include "SkImage.h" |
robertphillips@google.com | aaa9b29 | 2013-07-25 21:34:00 +0000 | [diff] [blame] | 13 | |
| 14 | #if SK_SUPPORT_GPU |
| 15 | #include "GrContext.h" |
bsalomon | 4ee6bd8 | 2015-05-27 13:23:23 -0700 | [diff] [blame] | 16 | #include "GrContextOptions.h" |
robertphillips@google.com | aaa9b29 | 2013-07-25 21:34:00 +0000 | [diff] [blame] | 17 | #endif |
| 18 | |
reed | a5517e2 | 2015-07-14 10:54:12 -0700 | [diff] [blame] | 19 | static void draw_bitmap_rect(SkCanvas* canvas, const SkBitmap& bitmap, const SkImage*, |
reed | e47829b | 2015-08-06 10:02:53 -0700 | [diff] [blame] | 20 | const SkRect& src, const SkRect& dst, |
reed | a5517e2 | 2015-07-14 10:54:12 -0700 | [diff] [blame] | 21 | const SkPaint* paint, SkCanvas::SrcRectConstraint constraint) { |
| 22 | canvas->drawBitmapRect(bitmap, src, dst, paint, constraint); |
| 23 | } |
| 24 | |
| 25 | static void draw_image_rect(SkCanvas* canvas, const SkBitmap&, const SkImage* image, |
reed | e47829b | 2015-08-06 10:02:53 -0700 | [diff] [blame] | 26 | const SkRect& src, const SkRect& dst, |
reed | a5517e2 | 2015-07-14 10:54:12 -0700 | [diff] [blame] | 27 | const SkPaint* paint, SkCanvas::SrcRectConstraint constraint) { |
| 28 | canvas->drawImageRect(image, src, dst, paint, constraint); |
| 29 | } |
| 30 | |
| 31 | enum BleedTest { |
| 32 | kUseBitmap_BleedTest, |
| 33 | kUseImage_BleedTest, |
| 34 | }; |
| 35 | |
| 36 | const struct { |
| 37 | const char* fName; |
reed | e47829b | 2015-08-06 10:02:53 -0700 | [diff] [blame] | 38 | void (*fDraw)(SkCanvas*, const SkBitmap&, const SkImage*, const SkRect&, const SkRect&, |
reed | a5517e2 | 2015-07-14 10:54:12 -0700 | [diff] [blame] | 39 | const SkPaint*, SkCanvas::SrcRectConstraint); |
| 40 | } gBleedRec[] = { |
| 41 | { "bleed", draw_bitmap_rect }, |
| 42 | { "bleed_image", draw_image_rect }, |
| 43 | }; |
| 44 | |
commit-bot@chromium.org | ec39b50 | 2013-11-08 15:09:22 +0000 | [diff] [blame] | 45 | // Create a black&white checked texture with 2 1-pixel rings |
| 46 | // around the outside edge. The inner ring is red and the outer ring is blue. |
| 47 | static void make_ringed_bitmap(SkBitmap* result, int width, int height) { |
| 48 | SkASSERT(0 == width % 2 && 0 == height % 2); |
skia.committer@gmail.com | ed00084 | 2013-11-09 07:02:23 +0000 | [diff] [blame] | 49 | |
commit-bot@chromium.org | ec39b50 | 2013-11-08 15:09:22 +0000 | [diff] [blame] | 50 | static const SkPMColor kRed = SkPreMultiplyColor(SK_ColorRED); |
| 51 | static const SkPMColor kBlue = SkPreMultiplyColor(SK_ColorBLUE); |
| 52 | static const SkPMColor kBlack = SkPreMultiplyColor(SK_ColorBLACK); |
| 53 | static const SkPMColor kWhite = SkPreMultiplyColor(SK_ColorWHITE); |
robertphillips@google.com | aaa9b29 | 2013-07-25 21:34:00 +0000 | [diff] [blame] | 54 | |
reed@google.com | eb9a46c | 2014-01-25 16:46:20 +0000 | [diff] [blame] | 55 | result->allocN32Pixels(width, height, true); |
robertphillips@google.com | aaa9b29 | 2013-07-25 21:34:00 +0000 | [diff] [blame] | 56 | |
skia.committer@gmail.com | 956b310 | 2013-07-26 07:00:58 +0000 | [diff] [blame] | 57 | SkPMColor* scanline = result->getAddr32(0, 0); |
robertphillips@google.com | aaa9b29 | 2013-07-25 21:34:00 +0000 | [diff] [blame] | 58 | for (int x = 0; x < width; ++x) { |
commit-bot@chromium.org | ec39b50 | 2013-11-08 15:09:22 +0000 | [diff] [blame] | 59 | scanline[x] = kBlue; |
| 60 | } |
| 61 | scanline = result->getAddr32(0, 1); |
| 62 | scanline[0] = kBlue; |
| 63 | for (int x = 1; x < width - 1; ++x) { |
| 64 | scanline[x] = kRed; |
| 65 | } |
| 66 | scanline[width-1] = kBlue; |
| 67 | |
| 68 | for (int y = 2; y < height/2; ++y) { |
| 69 | scanline = result->getAddr32(0, y); |
| 70 | scanline[0] = kBlue; |
| 71 | scanline[1] = kRed; |
| 72 | for (int x = 2; x < width/2; ++x) { |
| 73 | scanline[x] = kBlack; |
| 74 | } |
| 75 | for (int x = width/2; x < width-2; ++x) { |
| 76 | scanline[x] = kWhite; |
| 77 | } |
| 78 | scanline[width-2] = kRed; |
| 79 | scanline[width-1] = kBlue; |
robertphillips@google.com | aaa9b29 | 2013-07-25 21:34:00 +0000 | [diff] [blame] | 80 | } |
| 81 | |
commit-bot@chromium.org | ec39b50 | 2013-11-08 15:09:22 +0000 | [diff] [blame] | 82 | for (int y = height/2; y < height-2; ++y) { |
robertphillips@google.com | aaa9b29 | 2013-07-25 21:34:00 +0000 | [diff] [blame] | 83 | scanline = result->getAddr32(0, y); |
commit-bot@chromium.org | ec39b50 | 2013-11-08 15:09:22 +0000 | [diff] [blame] | 84 | scanline[0] = kBlue; |
| 85 | scanline[1] = kRed; |
| 86 | for (int x = 2; x < width/2; ++x) { |
| 87 | scanline[x] = kWhite; |
robertphillips@google.com | aaa9b29 | 2013-07-25 21:34:00 +0000 | [diff] [blame] | 88 | } |
commit-bot@chromium.org | ec39b50 | 2013-11-08 15:09:22 +0000 | [diff] [blame] | 89 | for (int x = width/2; x < width-2; ++x) { |
| 90 | scanline[x] = kBlack; |
robertphillips@google.com | aaa9b29 | 2013-07-25 21:34:00 +0000 | [diff] [blame] | 91 | } |
commit-bot@chromium.org | ec39b50 | 2013-11-08 15:09:22 +0000 | [diff] [blame] | 92 | scanline[width-2] = kRed; |
| 93 | scanline[width-1] = kBlue; |
robertphillips@google.com | aaa9b29 | 2013-07-25 21:34:00 +0000 | [diff] [blame] | 94 | } |
| 95 | |
commit-bot@chromium.org | ec39b50 | 2013-11-08 15:09:22 +0000 | [diff] [blame] | 96 | scanline = result->getAddr32(0, height-2); |
| 97 | scanline[0] = kBlue; |
| 98 | for (int x = 1; x < width - 1; ++x) { |
| 99 | scanline[x] = kRed; |
robertphillips@google.com | aaa9b29 | 2013-07-25 21:34:00 +0000 | [diff] [blame] | 100 | } |
commit-bot@chromium.org | ec39b50 | 2013-11-08 15:09:22 +0000 | [diff] [blame] | 101 | scanline[width-1] = kBlue; |
robertphillips@google.com | aaa9b29 | 2013-07-25 21:34:00 +0000 | [diff] [blame] | 102 | |
| 103 | scanline = result->getAddr32(0, height-1); |
| 104 | for (int x = 0; x < width; ++x) { |
commit-bot@chromium.org | ec39b50 | 2013-11-08 15:09:22 +0000 | [diff] [blame] | 105 | scanline[x] = kBlue; |
robertphillips@google.com | aaa9b29 | 2013-07-25 21:34:00 +0000 | [diff] [blame] | 106 | } |
robertphillips@google.com | aaa9b29 | 2013-07-25 21:34:00 +0000 | [diff] [blame] | 107 | result->setImmutable(); |
| 108 | } |
| 109 | |
reed | a5517e2 | 2015-07-14 10:54:12 -0700 | [diff] [blame] | 110 | // This GM exercises the drawBitmapRect constraints |
robertphillips@google.com | aaa9b29 | 2013-07-25 21:34:00 +0000 | [diff] [blame] | 111 | class BleedGM : public skiagm::GM { |
| 112 | public: |
reed | a5517e2 | 2015-07-14 10:54:12 -0700 | [diff] [blame] | 113 | BleedGM(BleedTest bt) : fBT(bt) {} |
robertphillips@google.com | aaa9b29 | 2013-07-25 21:34:00 +0000 | [diff] [blame] | 114 | |
| 115 | protected: |
commit-bot@chromium.org | a90c680 | 2014-04-30 13:20:45 +0000 | [diff] [blame] | 116 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 117 | SkString onShortName() override { |
reed | a5517e2 | 2015-07-14 10:54:12 -0700 | [diff] [blame] | 118 | return SkString(gBleedRec[fBT].fName); |
robertphillips@google.com | aaa9b29 | 2013-07-25 21:34:00 +0000 | [diff] [blame] | 119 | } |
| 120 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 121 | SkISize onISize() override { |
commit-bot@chromium.org | d6ca4ac | 2013-11-22 20:34:59 +0000 | [diff] [blame] | 122 | return SkISize::Make(kWidth, 780); |
robertphillips@google.com | aaa9b29 | 2013-07-25 21:34:00 +0000 | [diff] [blame] | 123 | } |
| 124 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 125 | void onOnceBeforeDraw() override { |
commit-bot@chromium.org | ec39b50 | 2013-11-08 15:09:22 +0000 | [diff] [blame] | 126 | make_ringed_bitmap(&fBitmapSmall, kSmallTextureSize, kSmallTextureSize); |
reed | a5517e2 | 2015-07-14 10:54:12 -0700 | [diff] [blame] | 127 | fImageSmall.reset(SkImage::NewFromBitmap(fBitmapSmall)); |
robertphillips@google.com | aaa9b29 | 2013-07-25 21:34:00 +0000 | [diff] [blame] | 128 | |
| 129 | // To exercise the GPU's tiling path we need a texture |
| 130 | // too big for the GPU to handle in one go |
commit-bot@chromium.org | ec39b50 | 2013-11-08 15:09:22 +0000 | [diff] [blame] | 131 | make_ringed_bitmap(&fBitmapBig, 2*kMaxTextureSize, 2*kMaxTextureSize); |
reed | a5517e2 | 2015-07-14 10:54:12 -0700 | [diff] [blame] | 132 | fImageBig.reset(SkImage::NewFromBitmap(fBitmapBig)); |
robertphillips@google.com | aaa9b29 | 2013-07-25 21:34:00 +0000 | [diff] [blame] | 133 | } |
| 134 | |
robertphillips@google.com | d7ca661 | 2013-08-20 12:09:32 +0000 | [diff] [blame] | 135 | // Draw only the center of the small bitmap |
skia.committer@gmail.com | b74bdf0 | 2013-08-21 07:01:29 +0000 | [diff] [blame] | 136 | void drawCase1(SkCanvas* canvas, int transX, int transY, |
reed | a5517e2 | 2015-07-14 10:54:12 -0700 | [diff] [blame] | 137 | SkCanvas::SrcRectConstraint constraint, SkFilterQuality filter) { |
commit-bot@chromium.org | ec39b50 | 2013-11-08 15:09:22 +0000 | [diff] [blame] | 138 | SkRect src = SkRect::MakeXYWH(2, 2, |
commit-bot@chromium.org | d6ca4ac | 2013-11-22 20:34:59 +0000 | [diff] [blame] | 139 | SkIntToScalar(kSmallTextureSize-4), |
| 140 | SkIntToScalar(kSmallTextureSize-4)); |
reed | a5517e2 | 2015-07-14 10:54:12 -0700 | [diff] [blame] | 141 | SkRect dst = SkRect::MakeXYWH(SkIntToScalar(transX), SkIntToScalar(transY), |
| 142 | SkIntToScalar(kBlockSize), SkIntToScalar(kBlockSize)); |
robertphillips@google.com | d7ca661 | 2013-08-20 12:09:32 +0000 | [diff] [blame] | 143 | |
| 144 | SkPaint paint; |
reed | 93a1215 | 2015-03-16 10:08:34 -0700 | [diff] [blame] | 145 | paint.setFilterQuality(filter); |
robertphillips@google.com | d7ca661 | 2013-08-20 12:09:32 +0000 | [diff] [blame] | 146 | |
reed | e47829b | 2015-08-06 10:02:53 -0700 | [diff] [blame] | 147 | gBleedRec[fBT].fDraw(canvas, fBitmapSmall, fImageSmall, src, dst, &paint, constraint); |
robertphillips@google.com | d7ca661 | 2013-08-20 12:09:32 +0000 | [diff] [blame] | 148 | } |
| 149 | |
| 150 | // Draw almost all of the large bitmap |
skia.committer@gmail.com | b74bdf0 | 2013-08-21 07:01:29 +0000 | [diff] [blame] | 151 | void drawCase2(SkCanvas* canvas, int transX, int transY, |
reed | a5517e2 | 2015-07-14 10:54:12 -0700 | [diff] [blame] | 152 | SkCanvas::SrcRectConstraint constraint, SkFilterQuality filter) { |
commit-bot@chromium.org | ec39b50 | 2013-11-08 15:09:22 +0000 | [diff] [blame] | 153 | SkRect src = SkRect::MakeXYWH(2, 2, |
| 154 | SkIntToScalar(fBitmapBig.width()-4), |
| 155 | SkIntToScalar(fBitmapBig.height()-4)); |
reed | a5517e2 | 2015-07-14 10:54:12 -0700 | [diff] [blame] | 156 | SkRect dst = SkRect::MakeXYWH(SkIntToScalar(transX), SkIntToScalar(transY), |
| 157 | SkIntToScalar(kBlockSize), SkIntToScalar(kBlockSize)); |
robertphillips@google.com | d7ca661 | 2013-08-20 12:09:32 +0000 | [diff] [blame] | 158 | |
| 159 | SkPaint paint; |
reed | 93a1215 | 2015-03-16 10:08:34 -0700 | [diff] [blame] | 160 | paint.setFilterQuality(filter); |
robertphillips@google.com | d7ca661 | 2013-08-20 12:09:32 +0000 | [diff] [blame] | 161 | |
reed | e47829b | 2015-08-06 10:02:53 -0700 | [diff] [blame] | 162 | gBleedRec[fBT].fDraw(canvas, fBitmapBig, fImageBig, src, dst, &paint, constraint); |
robertphillips@google.com | d7ca661 | 2013-08-20 12:09:32 +0000 | [diff] [blame] | 163 | } |
| 164 | |
| 165 | // Draw ~1/4 of the large bitmap |
skia.committer@gmail.com | b74bdf0 | 2013-08-21 07:01:29 +0000 | [diff] [blame] | 166 | void drawCase3(SkCanvas* canvas, int transX, int transY, |
reed | a5517e2 | 2015-07-14 10:54:12 -0700 | [diff] [blame] | 167 | SkCanvas::SrcRectConstraint constraint, SkFilterQuality filter) { |
commit-bot@chromium.org | ec39b50 | 2013-11-08 15:09:22 +0000 | [diff] [blame] | 168 | SkRect src = SkRect::MakeXYWH(2, 2, |
| 169 | SkIntToScalar(fBitmapBig.width()/2-2), |
| 170 | SkIntToScalar(fBitmapBig.height()/2-2)); |
reed | a5517e2 | 2015-07-14 10:54:12 -0700 | [diff] [blame] | 171 | SkRect dst = SkRect::MakeXYWH(SkIntToScalar(transX), SkIntToScalar(transY), |
| 172 | SkIntToScalar(kBlockSize), SkIntToScalar(kBlockSize)); |
robertphillips@google.com | d7ca661 | 2013-08-20 12:09:32 +0000 | [diff] [blame] | 173 | |
| 174 | SkPaint paint; |
reed | 93a1215 | 2015-03-16 10:08:34 -0700 | [diff] [blame] | 175 | paint.setFilterQuality(filter); |
robertphillips@google.com | d7ca661 | 2013-08-20 12:09:32 +0000 | [diff] [blame] | 176 | |
reed | e47829b | 2015-08-06 10:02:53 -0700 | [diff] [blame] | 177 | gBleedRec[fBT].fDraw(canvas, fBitmapBig, fImageBig, src, dst, &paint, constraint); |
robertphillips@google.com | d7ca661 | 2013-08-20 12:09:32 +0000 | [diff] [blame] | 178 | } |
| 179 | |
robertphillips@google.com | 2cc0b47 | 2013-08-20 16:51:20 +0000 | [diff] [blame] | 180 | // Draw the center of the small bitmap with a mask filter |
skia.committer@gmail.com | b74bdf0 | 2013-08-21 07:01:29 +0000 | [diff] [blame] | 181 | void drawCase4(SkCanvas* canvas, int transX, int transY, |
reed | a5517e2 | 2015-07-14 10:54:12 -0700 | [diff] [blame] | 182 | SkCanvas::SrcRectConstraint constraint, SkFilterQuality filter) { |
commit-bot@chromium.org | ec39b50 | 2013-11-08 15:09:22 +0000 | [diff] [blame] | 183 | SkRect src = SkRect::MakeXYWH(2, 2, |
commit-bot@chromium.org | d6ca4ac | 2013-11-22 20:34:59 +0000 | [diff] [blame] | 184 | SkIntToScalar(kSmallTextureSize-4), |
| 185 | SkIntToScalar(kSmallTextureSize-4)); |
reed | a5517e2 | 2015-07-14 10:54:12 -0700 | [diff] [blame] | 186 | SkRect dst = SkRect::MakeXYWH(SkIntToScalar(transX), SkIntToScalar(transY), |
| 187 | SkIntToScalar(kBlockSize), SkIntToScalar(kBlockSize)); |
robertphillips@google.com | 2cc0b47 | 2013-08-20 16:51:20 +0000 | [diff] [blame] | 188 | |
| 189 | SkPaint paint; |
reed | 93a1215 | 2015-03-16 10:08:34 -0700 | [diff] [blame] | 190 | paint.setFilterQuality(filter); |
commit-bot@chromium.org | e396455 | 2014-04-28 16:25:35 +0000 | [diff] [blame] | 191 | SkMaskFilter* mf = SkBlurMaskFilter::Create(kNormal_SkBlurStyle, |
reed | a5517e2 | 2015-07-14 10:54:12 -0700 | [diff] [blame] | 192 | SkBlurMask::ConvertRadiusToSigma(3)); |
robertphillips@google.com | 2cc0b47 | 2013-08-20 16:51:20 +0000 | [diff] [blame] | 193 | paint.setMaskFilter(mf)->unref(); |
| 194 | |
reed | e47829b | 2015-08-06 10:02:53 -0700 | [diff] [blame] | 195 | gBleedRec[fBT].fDraw(canvas, fBitmapSmall, fImageSmall, src, dst, &paint, constraint); |
robertphillips@google.com | 2cc0b47 | 2013-08-20 16:51:20 +0000 | [diff] [blame] | 196 | } |
| 197 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 198 | void onDraw(SkCanvas* canvas) override { |
robertphillips@google.com | d7ca661 | 2013-08-20 12:09:32 +0000 | [diff] [blame] | 199 | |
| 200 | canvas->clear(SK_ColorGRAY); |
| 201 | |
commit-bot@chromium.org | d6ca4ac | 2013-11-22 20:34:59 +0000 | [diff] [blame] | 202 | for (int m = 0; m < 2; ++m) { |
| 203 | canvas->save(); |
| 204 | if (m) { |
| 205 | static const SkScalar kBottom = SkIntToScalar(kRow3Y + kBlockSize + kBlockSpacing); |
| 206 | canvas->translate(0, kBottom); |
| 207 | SkMatrix rotate; |
| 208 | rotate.setRotate(15.f, 0, kBottom + kBlockSpacing); |
| 209 | canvas->concat(rotate); |
| 210 | canvas->scale(0.71f, 1.22f); |
| 211 | } |
skia.committer@gmail.com | ed00084 | 2013-11-09 07:02:23 +0000 | [diff] [blame] | 212 | |
bsalomon | 4ee6bd8 | 2015-05-27 13:23:23 -0700 | [diff] [blame] | 213 | // First draw a column with no bleeding and no filtering |
reed | a5517e2 | 2015-07-14 10:54:12 -0700 | [diff] [blame] | 214 | this->drawCase1(canvas, kCol0X, kRow0Y, SkCanvas::kStrict_SrcRectConstraint, kNone_SkFilterQuality); |
| 215 | this->drawCase2(canvas, kCol0X, kRow1Y, SkCanvas::kStrict_SrcRectConstraint, kNone_SkFilterQuality); |
| 216 | this->drawCase3(canvas, kCol0X, kRow2Y, SkCanvas::kStrict_SrcRectConstraint, kNone_SkFilterQuality); |
| 217 | this->drawCase4(canvas, kCol0X, kRow3Y, SkCanvas::kStrict_SrcRectConstraint, kNone_SkFilterQuality); |
robertphillips@google.com | d7ca661 | 2013-08-20 12:09:32 +0000 | [diff] [blame] | 218 | |
bsalomon | 4ee6bd8 | 2015-05-27 13:23:23 -0700 | [diff] [blame] | 219 | // Then draw a column with no bleeding and low filtering |
reed | a5517e2 | 2015-07-14 10:54:12 -0700 | [diff] [blame] | 220 | this->drawCase1(canvas, kCol1X, kRow0Y, SkCanvas::kStrict_SrcRectConstraint, kLow_SkFilterQuality); |
| 221 | this->drawCase2(canvas, kCol1X, kRow1Y, SkCanvas::kStrict_SrcRectConstraint, kLow_SkFilterQuality); |
| 222 | this->drawCase3(canvas, kCol1X, kRow2Y, SkCanvas::kStrict_SrcRectConstraint, kLow_SkFilterQuality); |
| 223 | this->drawCase4(canvas, kCol1X, kRow3Y, SkCanvas::kStrict_SrcRectConstraint, kLow_SkFilterQuality); |
robertphillips@google.com | d7ca661 | 2013-08-20 12:09:32 +0000 | [diff] [blame] | 224 | |
bsalomon | 4ee6bd8 | 2015-05-27 13:23:23 -0700 | [diff] [blame] | 225 | // Then draw a column with no bleeding and high filtering |
reed | a5517e2 | 2015-07-14 10:54:12 -0700 | [diff] [blame] | 226 | this->drawCase1(canvas, kCol2X, kRow0Y, SkCanvas::kStrict_SrcRectConstraint, kHigh_SkFilterQuality); |
| 227 | this->drawCase2(canvas, kCol2X, kRow1Y, SkCanvas::kStrict_SrcRectConstraint, kHigh_SkFilterQuality); |
| 228 | this->drawCase3(canvas, kCol2X, kRow2Y, SkCanvas::kStrict_SrcRectConstraint, kHigh_SkFilterQuality); |
| 229 | this->drawCase4(canvas, kCol2X, kRow3Y, SkCanvas::kStrict_SrcRectConstraint, kHigh_SkFilterQuality); |
skia.committer@gmail.com | ed00084 | 2013-11-09 07:02:23 +0000 | [diff] [blame] | 230 | |
bsalomon | 4ee6bd8 | 2015-05-27 13:23:23 -0700 | [diff] [blame] | 231 | // Then draw a column with bleeding and no filtering (bleed should have no effect w/out blur) |
reed | a5517e2 | 2015-07-14 10:54:12 -0700 | [diff] [blame] | 232 | this->drawCase1(canvas, kCol3X, kRow0Y, SkCanvas::kFast_SrcRectConstraint, kNone_SkFilterQuality); |
| 233 | this->drawCase2(canvas, kCol3X, kRow1Y, SkCanvas::kFast_SrcRectConstraint, kNone_SkFilterQuality); |
| 234 | this->drawCase3(canvas, kCol3X, kRow2Y, SkCanvas::kFast_SrcRectConstraint, kNone_SkFilterQuality); |
| 235 | this->drawCase4(canvas, kCol3X, kRow3Y, SkCanvas::kFast_SrcRectConstraint, kNone_SkFilterQuality); |
skia.committer@gmail.com | 956b310 | 2013-07-26 07:00:58 +0000 | [diff] [blame] | 236 | |
bsalomon | 4ee6bd8 | 2015-05-27 13:23:23 -0700 | [diff] [blame] | 237 | // Then draw a column with bleeding and low filtering |
reed | a5517e2 | 2015-07-14 10:54:12 -0700 | [diff] [blame] | 238 | this->drawCase1(canvas, kCol4X, kRow0Y, SkCanvas::kFast_SrcRectConstraint, kLow_SkFilterQuality); |
| 239 | this->drawCase2(canvas, kCol4X, kRow1Y, SkCanvas::kFast_SrcRectConstraint, kLow_SkFilterQuality); |
| 240 | this->drawCase3(canvas, kCol4X, kRow2Y, SkCanvas::kFast_SrcRectConstraint, kLow_SkFilterQuality); |
| 241 | this->drawCase4(canvas, kCol4X, kRow3Y, SkCanvas::kFast_SrcRectConstraint, kLow_SkFilterQuality); |
robertphillips@google.com | aaa9b29 | 2013-07-25 21:34:00 +0000 | [diff] [blame] | 242 | |
bsalomon | 4ee6bd8 | 2015-05-27 13:23:23 -0700 | [diff] [blame] | 243 | // Finally draw a column with bleeding and high filtering |
reed | a5517e2 | 2015-07-14 10:54:12 -0700 | [diff] [blame] | 244 | this->drawCase1(canvas, kCol5X, kRow0Y, SkCanvas::kFast_SrcRectConstraint, kHigh_SkFilterQuality); |
| 245 | this->drawCase2(canvas, kCol5X, kRow1Y, SkCanvas::kFast_SrcRectConstraint, kHigh_SkFilterQuality); |
| 246 | this->drawCase3(canvas, kCol5X, kRow2Y, SkCanvas::kFast_SrcRectConstraint, kHigh_SkFilterQuality); |
| 247 | this->drawCase4(canvas, kCol5X, kRow3Y, SkCanvas::kFast_SrcRectConstraint, kHigh_SkFilterQuality); |
skia.committer@gmail.com | ed00084 | 2013-11-09 07:02:23 +0000 | [diff] [blame] | 248 | |
commit-bot@chromium.org | d6ca4ac | 2013-11-22 20:34:59 +0000 | [diff] [blame] | 249 | canvas->restore(); |
| 250 | } |
robertphillips@google.com | aaa9b29 | 2013-07-25 21:34:00 +0000 | [diff] [blame] | 251 | } |
| 252 | |
bsalomon | 4ee6bd8 | 2015-05-27 13:23:23 -0700 | [diff] [blame] | 253 | #if SK_SUPPORT_GPU |
| 254 | void modifyGrContextOptions(GrContextOptions* options) override { |
| 255 | options->fMaxTextureSizeOverride = kMaxTextureSize; |
| 256 | } |
| 257 | #endif |
| 258 | |
robertphillips@google.com | aaa9b29 | 2013-07-25 21:34:00 +0000 | [diff] [blame] | 259 | private: |
commit-bot@chromium.org | ec39b50 | 2013-11-08 15:09:22 +0000 | [diff] [blame] | 260 | static const int kBlockSize = 70; |
| 261 | static const int kBlockSpacing = 5; |
robertphillips@google.com | d7ca661 | 2013-08-20 12:09:32 +0000 | [diff] [blame] | 262 | |
| 263 | static const int kCol0X = kBlockSpacing; |
| 264 | static const int kCol1X = 2*kBlockSpacing + kBlockSize; |
| 265 | static const int kCol2X = 3*kBlockSpacing + 2*kBlockSize; |
| 266 | static const int kCol3X = 4*kBlockSpacing + 3*kBlockSize; |
commit-bot@chromium.org | ec39b50 | 2013-11-08 15:09:22 +0000 | [diff] [blame] | 267 | static const int kCol4X = 5*kBlockSpacing + 4*kBlockSize; |
| 268 | static const int kCol5X = 6*kBlockSpacing + 5*kBlockSize; |
bsalomon | 4ee6bd8 | 2015-05-27 13:23:23 -0700 | [diff] [blame] | 269 | static const int kWidth = 7*kBlockSpacing + 6*kBlockSize; |
robertphillips@google.com | d7ca661 | 2013-08-20 12:09:32 +0000 | [diff] [blame] | 270 | |
| 271 | static const int kRow0Y = kBlockSpacing; |
| 272 | static const int kRow1Y = 2*kBlockSpacing + kBlockSize; |
| 273 | static const int kRow2Y = 3*kBlockSpacing + 2*kBlockSize; |
robertphillips@google.com | 2cc0b47 | 2013-08-20 16:51:20 +0000 | [diff] [blame] | 274 | static const int kRow3Y = 4*kBlockSpacing + 3*kBlockSize; |
robertphillips@google.com | aaa9b29 | 2013-07-25 21:34:00 +0000 | [diff] [blame] | 275 | |
commit-bot@chromium.org | ec39b50 | 2013-11-08 15:09:22 +0000 | [diff] [blame] | 276 | static const int kSmallTextureSize = 6; |
robertphillips@google.com | aaa9b29 | 2013-07-25 21:34:00 +0000 | [diff] [blame] | 277 | static const int kMaxTextureSize = 32; |
| 278 | |
| 279 | SkBitmap fBitmapSmall; |
| 280 | SkBitmap fBitmapBig; |
reed | a5517e2 | 2015-07-14 10:54:12 -0700 | [diff] [blame] | 281 | SkAutoTUnref<SkImage> fImageSmall; |
| 282 | SkAutoTUnref<SkImage> fImageBig; |
| 283 | const BleedTest fBT; |
robertphillips@google.com | aaa9b29 | 2013-07-25 21:34:00 +0000 | [diff] [blame] | 284 | |
| 285 | typedef GM INHERITED; |
| 286 | }; |
| 287 | |
reed | a5517e2 | 2015-07-14 10:54:12 -0700 | [diff] [blame] | 288 | DEF_GM( return new BleedGM(kUseBitmap_BleedTest); ) |
| 289 | DEF_GM( return new BleedGM(kUseImage_BleedTest); ) |