本文整理汇总了C++中GrCachedLayer::setTexture方法的典型用法代码示例。如果您正苦于以下问题:C++ GrCachedLayer::setTexture方法的具体用法?C++ GrCachedLayer::setTexture怎么用?C++ GrCachedLayer::setTexture使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GrCachedLayer
的用法示例。
在下文中一共展示了GrCachedLayer::setTexture方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_replacements
// Test out the layer replacement functionality with and w/o a BBH
void test_replacements(skiatest::Reporter* r, GrContext* context, bool doReplace) {
sk_sp<SkPicture> pic;
{
SkPictureRecorder recorder;
SkCanvas* canvas = recorder.beginRecording(SkIntToScalar(kWidth), SkIntToScalar(kHeight));
SkPaint paint;
canvas->saveLayer(nullptr, &paint);
canvas->clear(SK_ColorRED);
canvas->restore();
canvas->drawRect(SkRect::MakeWH(SkIntToScalar(kWidth / 2), SkIntToScalar(kHeight / 2)),
SkPaint());
pic = recorder.finishRecordingAsPicture();
}
SkAutoTUnref<GrTexture> texture;
SkPaint paint;
GrLayerCache* layerCache = context->getLayerCache();
if (doReplace) {
int key[1] = { 0 };
GrCachedLayer* layer = layerCache->findLayerOrCreate(pic->uniqueID(), 0, 2,
SkIRect::MakeWH(kWidth, kHeight),
SkIRect::MakeWH(kWidth, kHeight),
SkMatrix::I(), key, 1, &paint);
GrSurfaceDesc desc;
desc.fConfig = kSkia8888_GrPixelConfig;
desc.fFlags = kRenderTarget_GrSurfaceFlag;
desc.fWidth = kWidth;
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, srcBuffer.get(), 0));
layer->setTexture(texture, SkIRect::MakeWH(kWidth, kHeight), false);
}
SkRecord rerecord;
SkRecorder canvas(&rerecord, kWidth, kHeight);
GrRecordReplaceDraw(pic.get(), &canvas, layerCache, SkMatrix::I(), nullptr/*callback*/);
int numLayers = count_instances_of_type<SkRecords::SaveLayer>(rerecord);
if (doReplace) {
REPORTER_ASSERT(r, 0 == numLayers);
} else {
REPORTER_ASSERT(r, 1 == numLayers);
}
}
示例2: test_replacements
// Test out the layer replacement functionality with and w/o a BBH
void test_replacements(skiatest::Reporter* r, GrContext* context, bool doReplace) {
SkAutoTUnref<const SkPicture> pic;
{
SkPictureRecorder recorder;
SkCanvas* canvas = recorder.beginRecording(SkIntToScalar(kWidth), SkIntToScalar(kHeight));
SkPaint paint;
canvas->saveLayer(nullptr, &paint);
canvas->clear(SK_ColorRED);
canvas->restore();
canvas->drawRect(SkRect::MakeWH(SkIntToScalar(kWidth / 2), SkIntToScalar(kHeight / 2)),
SkPaint());
pic.reset(recorder.endRecording());
}
SkAutoTUnref<GrTexture> texture;
SkPaint paint;
GrLayerCache* layerCache = context->getLayerCache();
if (doReplace) {
int key[1] = { 0 };
GrCachedLayer* layer = layerCache->findLayerOrCreate(pic->uniqueID(), 0, 2,
SkIRect::MakeWH(kWidth, kHeight),
SkIRect::MakeWH(kWidth, kHeight),
SkMatrix::I(), key, 1, &paint);
GrSurfaceDesc desc;
desc.fConfig = kSkia8888_GrPixelConfig;
desc.fFlags = kRenderTarget_GrSurfaceFlag;
desc.fWidth = kWidth;
desc.fHeight = kHeight;
desc.fSampleCnt = 0;
texture.reset(context->textureProvider()->createTexture(
desc, SkBudgeted::kNo, nullptr, 0));
layer->setTexture(texture, SkIRect::MakeWH(kWidth, kHeight), false);
}
SkRecord rerecord;
SkRecorder canvas(&rerecord, kWidth, kHeight);
GrRecordReplaceDraw(pic, &canvas, layerCache, SkMatrix::I(), nullptr/*callback*/);
int numLayers = count_instances_of_type<SkRecords::SaveLayer>(rerecord);
if (doReplace) {
REPORTER_ASSERT(r, 0 == numLayers);
} else {
REPORTER_ASSERT(r, 1 == numLayers);
}
}