From f3c1f099de2d0baa174874e3fa51739a160e835c Mon Sep 17 00:00:00 2001 From: Yuqian Li Date: Wed, 29 Nov 2017 16:07:22 -0500 Subject: [PATCH] Add a GM to test the fix in 73200 Bug: skia: Change-Id: I6a34138b699a96f51a0cacb049125f7bff9d5b84 Reviewed-on: https://skia-review.googlesource.com/77820 Commit-Queue: Yuqian Li Reviewed-by: Brian Salomon --- gm/bitmapshader.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/gm/bitmapshader.cpp b/gm/bitmapshader.cpp index 5ee7fca694..98205d2146 100644 --- a/gm/bitmapshader.cpp +++ b/gm/bitmapshader.cpp @@ -10,6 +10,7 @@ #include "SkBitmap.h" #include "SkPaint.h" #include "SkShader.h" +#include "GrContext.h" namespace skiagm { @@ -105,6 +106,34 @@ private: typedef GM INHERITED; }; +DEF_SIMPLE_GM(hugebitmapshader, canvas, 100, 100) { + SkPaint paint; + SkBitmap bitmap; + + // The huge height will exceed GL_MAX_TEXTURE_SIZE. We test that the GL backend will at least + // draw something with a default paint instead of drawing nothing. + // + // (See https://skia-review.googlesource.com/c/skia/+/73200) + int bitmapW = 1; + int bitmapH = 60000; + if (auto* ctx = canvas->getGrContext()) { + bitmapH = ctx->caps()->maxTextureSize() + 1; + } + bitmap.setInfo(SkImageInfo::MakeA8(bitmapW, bitmapH), bitmapW); + uint8_t* pixels = new uint8_t[bitmapH]; + for(int i = 0; i < bitmapH; ++i) { + pixels[i] = i & 0xff; + } + bitmap.setPixels(pixels); + + paint.setShader(SkShader::MakeBitmapShader(bitmap, + SkShader::kMirror_TileMode, SkShader::kMirror_TileMode)); + paint.setColor(SK_ColorRED); + paint.setAntiAlias(true); + canvas->drawCircle(50, 50, 50, paint); + delete [] pixels; +} + ////////////////////////////////////////////////////////////////////////////// static GM* MyFactory(void*) { return new BitmapShaderGM; }