Fix vulkan warning in RecordReplaceDrawTest

Vulkan debug layers complain that when we call readPixels on the texture
we are copying unitialized data from the image to a buffer.

BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2091823005

Review-Url: https://codereview.chromium.org/2091823005
This commit is contained in:
egdaniel 2016-06-23 15:06:29 -07:00 committed by Commit bot
parent ee41b7556d
commit 3fe0aabac1

View File

@ -124,8 +124,13 @@ void test_replacements(skiatest::Reporter* r, GrContext* context, bool doReplace
desc.fHeight = kHeight;
desc.fSampleCnt = 0;
// Giving the texture some initial data so the Gpu (specifically vulkan) does not complain
// when reading from an uninitialized texture.
SkAutoTMalloc<uint32_t> srcBuffer(kWidth*kHeight);
memset(srcBuffer.get(), 0, kWidth*kHeight*sizeof(uint32_t));
texture.reset(context->textureProvider()->createTexture(
desc, SkBudgeted::kNo, nullptr, 0));
desc, SkBudgeted::kNo, srcBuffer.get(), 0));
layer->setTexture(texture, SkIRect::MakeWH(kWidth, kHeight), false);
}