Fix for Android ClipCache unit test crash
http://codereview.appspot.com/6199063/ git-svn-id: http://skia.googlecode.com/svn/trunk@3902 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
720faa4b5d
commit
d82f3fae92
@ -14,16 +14,15 @@ static const int Y_SIZE = 12;
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
static GrTexture* createTexture(GrContext* context) {
|
static GrTexture* createTexture(GrContext* context) {
|
||||||
unsigned char textureData[X_SIZE][Y_SIZE];
|
unsigned char textureData[X_SIZE][Y_SIZE][4];
|
||||||
|
|
||||||
memset(textureData, 0, X_SIZE * Y_SIZE);
|
memset(textureData, 0, 4* X_SIZE * Y_SIZE);
|
||||||
|
|
||||||
GrTextureDesc desc;
|
GrTextureDesc desc;
|
||||||
|
|
||||||
// let Skia know we will be using this texture as a render target
|
// let Skia know we will be using this texture as a render target
|
||||||
desc.fFlags = kRenderTarget_GrTextureFlagBit;
|
desc.fFlags = kRenderTarget_GrTextureFlagBit;
|
||||||
// it is a single channel texture
|
desc.fConfig = kSkia8888_PM_GrPixelConfig;
|
||||||
desc.fConfig = kAlpha_8_GrPixelConfig;
|
|
||||||
desc.fWidth = X_SIZE;
|
desc.fWidth = X_SIZE;
|
||||||
desc.fHeight = Y_SIZE;
|
desc.fHeight = Y_SIZE;
|
||||||
desc.fSampleCnt = 0;
|
desc.fSampleCnt = 0;
|
||||||
@ -84,6 +83,11 @@ static void test_cache(skiatest::Reporter* reporter, GrContext* context) {
|
|||||||
clip1.setFromRect(bound1);
|
clip1.setFromRect(bound1);
|
||||||
|
|
||||||
SkAutoTUnref<GrTexture> texture(createTexture(context));
|
SkAutoTUnref<GrTexture> texture(createTexture(context));
|
||||||
|
REPORTER_ASSERT(reporter, texture.get());
|
||||||
|
|
||||||
|
if (NULL == texture.get()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
cache.set(clip1, 128, 128, texture.get(), bound1);
|
cache.set(clip1, 128, 128, texture.get(), bound1);
|
||||||
|
|
||||||
@ -144,7 +148,7 @@ static void test_cache(skiatest::Reporter* reporter, GrContext* context) {
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
static void TestClipCache(skiatest::Reporter* reporter, GrContext* context) {
|
static void TestClipCache(skiatest::Reporter* reporter, GrContext* context) {
|
||||||
|
|
||||||
// test_cache(reporter, context);
|
test_cache(reporter, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
Loading…
Reference in New Issue
Block a user