aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--gm/bitmapshader.cpp29
1 files changed, 29 insertions, 0 deletions
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; }