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 <liyuqian@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
This commit is contained in:
parent
9f9716281c
commit
f3c1f099de
@ -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; }
|
||||
|
Loading…
Reference in New Issue
Block a user