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