2018-05-29 20:13:26 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2018 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "tools/DDLTileHelper.h"
|
2018-05-29 20:13:26 +00:00
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/core/SkCanvas.h"
|
|
|
|
#include "include/core/SkDeferredDisplayListRecorder.h"
|
|
|
|
#include "include/core/SkPicture.h"
|
|
|
|
#include "include/core/SkSurface.h"
|
|
|
|
#include "include/core/SkSurfaceCharacterization.h"
|
|
|
|
#include "src/core/SkDeferredDisplayListPriv.h"
|
|
|
|
#include "src/core/SkTaskGroup.h"
|
2020-02-20 17:45:19 +00:00
|
|
|
#include "src/gpu/GrContextPriv.h"
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "src/image/SkImage_Gpu.h"
|
|
|
|
#include "tools/DDLPromiseImageHelper.h"
|
2018-05-29 20:13:26 +00:00
|
|
|
|
2020-02-26 15:27:07 +00:00
|
|
|
void DDLTileHelper::TileData::init(int id,
|
2020-04-23 19:10:03 +00:00
|
|
|
GrContext* context,
|
2020-02-26 15:27:07 +00:00
|
|
|
const SkSurfaceCharacterization& dstSurfaceCharacterization,
|
|
|
|
const SkIRect& clip) {
|
2020-02-14 15:49:39 +00:00
|
|
|
fID = id;
|
|
|
|
fClip = clip;
|
|
|
|
|
2020-02-26 15:27:07 +00:00
|
|
|
fCharacterization = dstSurfaceCharacterization.createResized(clip.width(), clip.height());
|
2020-02-14 15:49:39 +00:00
|
|
|
SkASSERT(fCharacterization.isValid());
|
2020-04-23 19:10:03 +00:00
|
|
|
|
|
|
|
GrBackendFormat backendFormat = context->defaultBackendFormat(fCharacterization.colorType(),
|
|
|
|
GrRenderable::kYes);
|
|
|
|
SkDEBUGCODE(const GrCaps* caps = context->priv().caps());
|
|
|
|
SkASSERT(caps->isFormatTexturable(backendFormat));
|
|
|
|
|
|
|
|
fCallbackContext.reset(new PromiseImageCallbackContext(context, backendFormat));
|
2018-05-29 20:13:26 +00:00
|
|
|
}
|
|
|
|
|
2020-02-14 15:49:39 +00:00
|
|
|
DDLTileHelper::TileData::~TileData() {}
|
|
|
|
|
2018-05-29 20:13:26 +00:00
|
|
|
void DDLTileHelper::TileData::createTileSpecificSKP(SkData* compressedPictureData,
|
|
|
|
const DDLPromiseImageHelper& helper) {
|
2018-09-26 21:18:23 +00:00
|
|
|
SkASSERT(!fReconstitutedPicture);
|
2018-05-29 20:13:26 +00:00
|
|
|
|
2018-09-26 21:18:23 +00:00
|
|
|
// This is bending the DDLRecorder contract! The promise images in the SKP should be
|
|
|
|
// created by the same recorder used to create the matching DDL.
|
|
|
|
SkDeferredDisplayListRecorder recorder(fCharacterization);
|
2018-05-29 20:13:26 +00:00
|
|
|
|
2018-09-26 21:18:23 +00:00
|
|
|
fReconstitutedPicture = helper.reinflateSKP(&recorder, compressedPictureData, &fPromiseImages);
|
2018-09-27 18:26:47 +00:00
|
|
|
|
|
|
|
std::unique_ptr<SkDeferredDisplayList> ddl = recorder.detach();
|
2019-08-01 20:14:52 +00:00
|
|
|
if (ddl->priv().numRenderTasks()) {
|
2018-09-27 18:26:47 +00:00
|
|
|
// TODO: remove this once skbug.com/8424 is fixed. If the DDL resulting from the
|
2019-08-22 20:19:24 +00:00
|
|
|
// reinflation of the SKPs contains opsTasks that means some image subset operation
|
2018-09-27 18:26:47 +00:00
|
|
|
// created a draw.
|
|
|
|
fReconstitutedPicture.reset();
|
|
|
|
}
|
2018-05-29 20:13:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DDLTileHelper::TileData::createDDL() {
|
2020-03-06 20:26:28 +00:00
|
|
|
SkASSERT(!fDisplayList && fReconstitutedPicture);
|
2018-05-29 20:13:26 +00:00
|
|
|
|
2018-09-26 21:18:23 +00:00
|
|
|
SkDeferredDisplayListRecorder recorder(fCharacterization);
|
|
|
|
|
|
|
|
// DDL TODO: the DDLRecorder's GrContext isn't initialized until getCanvas is called.
|
|
|
|
// Maybe set it up in the ctor?
|
2020-03-06 20:26:28 +00:00
|
|
|
SkCanvas* recordingCanvas = recorder.getCanvas();
|
2018-09-26 21:18:23 +00:00
|
|
|
|
|
|
|
// Because we cheated in createTileSpecificSKP and used the wrong DDLRecorder, the GrContext's
|
|
|
|
// stored in fReconstitutedPicture's promise images are incorrect. Patch them with the correct
|
|
|
|
// one now.
|
|
|
|
for (int i = 0; i < fPromiseImages.count(); ++i) {
|
2020-03-06 20:26:28 +00:00
|
|
|
GrContext* newContext = recordingCanvas->getGrContext();
|
2018-09-26 21:18:23 +00:00
|
|
|
|
|
|
|
if (fPromiseImages[i]->isTextureBacked()) {
|
2018-10-12 19:00:20 +00:00
|
|
|
SkImage_GpuBase* gpuImage = (SkImage_GpuBase*) fPromiseImages[i].get();
|
2018-09-26 21:18:23 +00:00
|
|
|
gpuImage->resetContext(sk_ref_sp(newContext));
|
|
|
|
}
|
|
|
|
}
|
2018-05-29 20:13:26 +00:00
|
|
|
|
2020-03-06 20:26:28 +00:00
|
|
|
recordingCanvas->clipRect(SkRect::MakeWH(fClip.width(), fClip.height()));
|
|
|
|
recordingCanvas->translate(-fClip.fLeft, -fClip.fTop);
|
2018-05-29 20:13:26 +00:00
|
|
|
|
|
|
|
// Note: in this use case we only render a picture to the deferred canvas
|
|
|
|
// but, more generally, clients will use arbitrary draw calls.
|
2020-03-06 20:26:28 +00:00
|
|
|
recordingCanvas->drawPicture(fReconstitutedPicture);
|
2018-05-29 20:13:26 +00:00
|
|
|
|
2018-09-26 21:18:23 +00:00
|
|
|
fDisplayList = recorder.detach();
|
2018-05-29 20:13:26 +00:00
|
|
|
}
|
|
|
|
|
2020-04-23 19:10:03 +00:00
|
|
|
void DDLTileHelper::createComposeDDL() {
|
|
|
|
SkASSERT(!fComposeDDL);
|
|
|
|
|
|
|
|
SkDeferredDisplayListRecorder recorder(fDstCharacterization);
|
|
|
|
|
|
|
|
SkCanvas* recordingCanvas = recorder.getCanvas();
|
|
|
|
|
|
|
|
for (int i = 0; i < this->numTiles(); ++i) {
|
|
|
|
TileData* tile = &fTiles[i];
|
|
|
|
|
|
|
|
sk_sp<SkImage> promiseImage = tile->makePromiseImage(&recorder);
|
|
|
|
|
|
|
|
SkIRect clipRect = tile->clipRect();
|
|
|
|
|
|
|
|
SkASSERT(clipRect.width() == promiseImage->width() &&
|
|
|
|
clipRect.height() == promiseImage->height());
|
|
|
|
|
|
|
|
recordingCanvas->drawImage(promiseImage, clipRect.fLeft, clipRect.fTop);
|
|
|
|
}
|
|
|
|
|
|
|
|
fComposeDDL = recorder.detach();
|
|
|
|
}
|
|
|
|
|
2020-03-05 17:52:45 +00:00
|
|
|
void DDLTileHelper::TileData::precompile(GrContext* context) {
|
|
|
|
SkASSERT(fDisplayList);
|
|
|
|
|
|
|
|
SkDeferredDisplayList::ProgramIterator iter(context, fDisplayList.get());
|
|
|
|
for (; !iter.done(); iter.next()) {
|
|
|
|
iter.compile();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-16 20:27:45 +00:00
|
|
|
sk_sp<SkSurface> DDLTileHelper::TileData::makeWrappedTileDest(GrContext* context) {
|
2020-04-23 19:10:03 +00:00
|
|
|
SkASSERT(fCallbackContext && fCallbackContext->promiseImageTexture());
|
|
|
|
|
|
|
|
auto promiseImageTexture = fCallbackContext->promiseImageTexture();
|
|
|
|
if (!promiseImageTexture->backendTexture().isValid()) {
|
2020-04-16 20:27:45 +00:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2020-04-23 19:10:03 +00:00
|
|
|
// Here we are, unfortunately, aliasing the backend texture held by the SkPromiseImageTexture.
|
|
|
|
// Both the tile's destination surface and the promise image used to draw the tile will be
|
|
|
|
// backed by the same backendTexture - unbeknownst to Ganesh.
|
2020-04-16 20:27:45 +00:00
|
|
|
return SkSurface::MakeFromBackendTexture(context,
|
2020-04-23 19:10:03 +00:00
|
|
|
promiseImageTexture->backendTexture(),
|
2020-04-16 20:27:45 +00:00
|
|
|
fCharacterization.origin(),
|
|
|
|
fCharacterization.sampleCount(),
|
|
|
|
fCharacterization.colorType(),
|
|
|
|
fCharacterization.refColorSpace(),
|
|
|
|
&fCharacterization.surfaceProps());
|
|
|
|
}
|
|
|
|
|
2020-03-06 20:26:28 +00:00
|
|
|
void DDLTileHelper::TileData::drawSKPDirectly(GrContext* context) {
|
2020-04-16 20:27:45 +00:00
|
|
|
SkASSERT(!fDisplayList && !fTileSurface && fReconstitutedPicture);
|
2020-03-06 20:26:28 +00:00
|
|
|
|
2020-04-16 20:27:45 +00:00
|
|
|
fTileSurface = this->makeWrappedTileDest(context);
|
|
|
|
if (fTileSurface) {
|
|
|
|
SkCanvas* tileCanvas = fTileSurface->getCanvas();
|
2020-03-06 20:26:28 +00:00
|
|
|
|
|
|
|
tileCanvas->clipRect(SkRect::MakeWH(fClip.width(), fClip.height()));
|
|
|
|
tileCanvas->translate(-fClip.fLeft, -fClip.fTop);
|
|
|
|
|
|
|
|
tileCanvas->drawPicture(fReconstitutedPicture);
|
|
|
|
|
2020-04-16 20:27:45 +00:00
|
|
|
// We can't snap an image here bc, since we're using wrapped backend textures for the
|
|
|
|
// surfaces, that would incur a copy.
|
2020-03-06 20:26:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-14 15:49:39 +00:00
|
|
|
void DDLTileHelper::TileData::draw(GrContext* context) {
|
2020-04-16 20:27:45 +00:00
|
|
|
SkASSERT(fDisplayList && !fTileSurface);
|
2020-02-14 15:49:39 +00:00
|
|
|
|
2020-04-23 19:10:03 +00:00
|
|
|
// The tile's surface needs to be held until after the DDL is flushed bc the DDL doesn't take
|
|
|
|
// a ref on its destination proxy.
|
|
|
|
// TODO: make the DDL (or probably the drawing manager) take a ref on the destination proxy
|
|
|
|
// (maybe in GrDrawingManager::addDDLTarget).
|
2020-04-16 20:27:45 +00:00
|
|
|
fTileSurface = this->makeWrappedTileDest(context);
|
|
|
|
if (fTileSurface) {
|
|
|
|
fTileSurface->draw(fDisplayList.get());
|
2018-05-29 20:13:26 +00:00
|
|
|
|
2020-04-16 20:27:45 +00:00
|
|
|
// We can't snap an image here bc, since we're using wrapped backend textures for the
|
|
|
|
// surfaces, that would incur a copy.
|
2020-02-14 15:49:39 +00:00
|
|
|
}
|
2018-05-29 20:13:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DDLTileHelper::TileData::reset() {
|
|
|
|
// TODO: when DDLs are re-renderable we don't need to do this
|
|
|
|
fDisplayList = nullptr;
|
2020-04-23 19:10:03 +00:00
|
|
|
|
2020-04-16 20:27:45 +00:00
|
|
|
fTileSurface = nullptr;
|
|
|
|
}
|
|
|
|
|
2020-04-23 19:10:03 +00:00
|
|
|
sk_sp<SkImage> DDLTileHelper::TileData::makePromiseImage(SkDeferredDisplayListRecorder* recorder) {
|
|
|
|
SkASSERT(fCallbackContext);
|
|
|
|
|
|
|
|
// The promise image gets a ref on the promise callback context
|
|
|
|
sk_sp<SkImage> promiseImage = recorder->makePromiseTexture(
|
|
|
|
fCallbackContext->backendFormat(),
|
|
|
|
fClip.width(),
|
|
|
|
fClip.height(),
|
|
|
|
GrMipMapped::kNo,
|
|
|
|
GrSurfaceOrigin::kBottomLeft_GrSurfaceOrigin,
|
|
|
|
fCharacterization.colorType(),
|
|
|
|
kPremul_SkAlphaType,
|
|
|
|
fCharacterization.refColorSpace(),
|
|
|
|
PromiseImageCallbackContext::PromiseImageFulfillProc,
|
|
|
|
PromiseImageCallbackContext::PromiseImageReleaseProc,
|
|
|
|
PromiseImageCallbackContext::PromiseImageDoneProc,
|
|
|
|
(void*)this->refCallbackContext().release(),
|
|
|
|
SkDeferredDisplayListRecorder::PromiseImageApiVersion::kNew);
|
|
|
|
fCallbackContext->wasAddedToImage();
|
|
|
|
|
|
|
|
return promiseImage;
|
|
|
|
}
|
|
|
|
|
2020-04-16 20:27:45 +00:00
|
|
|
void DDLTileHelper::TileData::CreateBackendTexture(GrContext* context, TileData* tile) {
|
|
|
|
SkASSERT(context->priv().asDirectContext());
|
2020-04-23 19:10:03 +00:00
|
|
|
SkASSERT(tile->fCallbackContext && !tile->fCallbackContext->promiseImageTexture());
|
2020-04-16 20:27:45 +00:00
|
|
|
|
2020-04-23 19:10:03 +00:00
|
|
|
GrBackendTexture beTex = context->createBackendTexture(tile->fCharacterization);
|
|
|
|
tile->fCallbackContext->setBackendTexture(beTex);
|
2020-04-16 20:27:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DDLTileHelper::TileData::DeleteBackendTexture(GrContext* context, TileData* tile) {
|
|
|
|
SkASSERT(context->priv().asDirectContext());
|
2020-04-23 19:10:03 +00:00
|
|
|
SkASSERT(tile->fCallbackContext);
|
|
|
|
|
2020-04-16 20:27:45 +00:00
|
|
|
// TODO: it seems that, on the Linux bots, backend texture creation is failing
|
|
|
|
// a lot (skbug.com/10142)
|
2020-04-23 19:10:03 +00:00
|
|
|
SkASSERT(!tile->fCallbackContext->promiseImageTexture() ||
|
|
|
|
tile->fCallbackContext->promiseImageTexture()->backendTexture().isValid());
|
2020-04-16 20:27:45 +00:00
|
|
|
|
|
|
|
tile->fTileSurface = nullptr;
|
2020-04-23 19:10:03 +00:00
|
|
|
|
|
|
|
SkASSERT(tile->fCallbackContext->unique());
|
|
|
|
tile->fCallbackContext.reset();
|
2018-05-29 20:13:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2020-04-23 19:10:03 +00:00
|
|
|
DDLTileHelper::DDLTileHelper(GrContext* context,
|
2020-02-26 15:27:07 +00:00
|
|
|
const SkSurfaceCharacterization& dstChar,
|
2020-02-14 15:49:39 +00:00
|
|
|
const SkIRect& viewport,
|
|
|
|
int numDivisions)
|
2020-04-23 19:10:03 +00:00
|
|
|
: fNumDivisions(numDivisions)
|
2020-05-11 17:33:59 +00:00
|
|
|
, fTiles(numDivisions * numDivisions)
|
2020-04-23 19:10:03 +00:00
|
|
|
, fDstCharacterization(dstChar) {
|
2018-05-29 20:13:26 +00:00
|
|
|
SkASSERT(fNumDivisions > 0);
|
|
|
|
|
|
|
|
int xTileSize = viewport.width()/fNumDivisions;
|
|
|
|
int yTileSize = viewport.height()/fNumDivisions;
|
|
|
|
|
|
|
|
// Create the destination tiles
|
|
|
|
for (int y = 0, yOff = 0; y < fNumDivisions; ++y, yOff += yTileSize) {
|
|
|
|
int ySize = (y < fNumDivisions-1) ? yTileSize : viewport.height()-yOff;
|
|
|
|
|
|
|
|
for (int x = 0, xOff = 0; x < fNumDivisions; ++x, xOff += xTileSize) {
|
|
|
|
int xSize = (x < fNumDivisions-1) ? xTileSize : viewport.width()-xOff;
|
|
|
|
|
|
|
|
SkIRect clip = SkIRect::MakeXYWH(xOff, yOff, xSize, ySize);
|
|
|
|
|
|
|
|
SkASSERT(viewport.contains(clip));
|
|
|
|
|
2020-04-23 19:10:03 +00:00
|
|
|
fTiles[y*fNumDivisions+x].init(y*fNumDivisions+x, context, dstChar, clip);
|
2018-05-29 20:13:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DDLTileHelper::createSKPPerTile(SkData* compressedPictureData,
|
|
|
|
const DDLPromiseImageHelper& helper) {
|
2020-02-14 15:49:39 +00:00
|
|
|
for (int i = 0; i < this->numTiles(); ++i) {
|
2018-05-29 20:13:26 +00:00
|
|
|
fTiles[i].createTileSpecificSKP(compressedPictureData, helper);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DDLTileHelper::createDDLsInParallel() {
|
|
|
|
#if 1
|
2020-02-14 15:49:39 +00:00
|
|
|
SkTaskGroup().batch(this->numTiles(), [&](int i) { fTiles[i].createDDL(); });
|
2020-04-23 19:10:03 +00:00
|
|
|
SkTaskGroup().add([this]{ this->createComposeDDL(); });
|
2018-06-13 13:01:36 +00:00
|
|
|
SkTaskGroup().wait();
|
2018-05-29 20:13:26 +00:00
|
|
|
#else
|
|
|
|
// Use this code path to debug w/o threads
|
2020-03-06 20:26:28 +00:00
|
|
|
for (int i = 0; i < this->numTiles(); ++i) {
|
2018-05-29 20:13:26 +00:00
|
|
|
fTiles[i].createDDL();
|
|
|
|
}
|
2020-04-23 19:10:03 +00:00
|
|
|
this->createComposeDDL();
|
2018-05-29 20:13:26 +00:00
|
|
|
#endif
|
2020-02-14 15:49:39 +00:00
|
|
|
}
|
2018-05-29 20:13:26 +00:00
|
|
|
|
2020-02-20 17:45:19 +00:00
|
|
|
// On the gpu thread:
|
|
|
|
// precompile any programs
|
|
|
|
// replay the DDL into a surface to make the tile image
|
|
|
|
// compose the tile image into the main canvas
|
|
|
|
static void do_gpu_stuff(GrContext* context, DDLTileHelper::TileData* tile) {
|
|
|
|
|
|
|
|
// TODO: schedule program compilation as their own tasks
|
2020-03-05 17:52:45 +00:00
|
|
|
tile->precompile(context);
|
2020-02-20 17:45:19 +00:00
|
|
|
|
|
|
|
tile->draw(context);
|
2020-05-29 14:41:33 +00:00
|
|
|
|
|
|
|
// TODO: remove this flush once DDLs are reffed by the drawing manager
|
|
|
|
context->flushAndSubmit();
|
|
|
|
|
|
|
|
tile->dropDDL();
|
2020-02-20 17:45:19 +00:00
|
|
|
}
|
|
|
|
|
2020-02-14 15:49:39 +00:00
|
|
|
// We expect to have more than one recording thread but just one gpu thread
|
|
|
|
void DDLTileHelper::kickOffThreadedWork(SkTaskGroup* recordingTaskGroup,
|
|
|
|
SkTaskGroup* gpuTaskGroup,
|
|
|
|
GrContext* gpuThreadContext) {
|
|
|
|
SkASSERT(recordingTaskGroup && gpuTaskGroup && gpuThreadContext);
|
|
|
|
|
|
|
|
for (int i = 0; i < this->numTiles(); ++i) {
|
|
|
|
TileData* tile = &fTiles[i];
|
|
|
|
|
|
|
|
// On a recording thread:
|
|
|
|
// generate the tile's DDL
|
|
|
|
// schedule gpu-thread processing of the DDL
|
|
|
|
// Note: a finer grained approach would be add a scheduling task which would evaluate
|
|
|
|
// which DDLs were ready to be rendered based on their prerequisites
|
|
|
|
recordingTaskGroup->add([tile, gpuTaskGroup, gpuThreadContext]() {
|
|
|
|
tile->createDDL();
|
|
|
|
|
|
|
|
gpuTaskGroup->add([gpuThreadContext, tile]() {
|
2020-02-20 17:45:19 +00:00
|
|
|
do_gpu_stuff(gpuThreadContext, tile);
|
2020-02-14 15:49:39 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
2020-04-23 19:10:03 +00:00
|
|
|
|
|
|
|
recordingTaskGroup->add([this] { this->createComposeDDL(); });
|
2018-05-29 20:13:26 +00:00
|
|
|
}
|
|
|
|
|
2020-05-29 14:41:33 +00:00
|
|
|
// Only called from ViaDDL
|
2020-03-05 17:52:45 +00:00
|
|
|
void DDLTileHelper::precompileAndDrawAllTiles(GrContext* context) {
|
2020-02-14 15:49:39 +00:00
|
|
|
for (int i = 0; i < this->numTiles(); ++i) {
|
2020-03-05 17:52:45 +00:00
|
|
|
fTiles[i].precompile(context);
|
2020-02-14 15:49:39 +00:00
|
|
|
fTiles[i].draw(context);
|
2018-05-29 20:13:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-29 14:41:33 +00:00
|
|
|
// Only called from skpbench
|
2020-03-06 20:26:28 +00:00
|
|
|
void DDLTileHelper::interleaveDDLCreationAndDraw(GrContext* context) {
|
|
|
|
for (int i = 0; i < this->numTiles(); ++i) {
|
|
|
|
fTiles[i].createDDL();
|
|
|
|
fTiles[i].draw(context);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-29 14:41:33 +00:00
|
|
|
// Only called from skpbench
|
2020-03-06 20:26:28 +00:00
|
|
|
void DDLTileHelper::drawAllTilesDirectly(GrContext* context) {
|
|
|
|
for (int i = 0; i < this->numTiles(); ++i) {
|
|
|
|
fTiles[i].drawSKPDirectly(context);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-23 19:10:03 +00:00
|
|
|
void DDLTileHelper::dropCallbackContexts() {
|
2020-02-14 15:49:39 +00:00
|
|
|
for (int i = 0; i < this->numTiles(); ++i) {
|
2020-04-23 19:10:03 +00:00
|
|
|
fTiles[i].dropCallbackContext();
|
2018-05-29 20:13:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DDLTileHelper::resetAllTiles() {
|
2020-02-14 15:49:39 +00:00
|
|
|
for (int i = 0; i < this->numTiles(); ++i) {
|
2018-05-29 20:13:26 +00:00
|
|
|
fTiles[i].reset();
|
|
|
|
}
|
2020-04-23 19:10:03 +00:00
|
|
|
fComposeDDL.reset();
|
2018-05-29 20:13:26 +00:00
|
|
|
}
|
2020-04-16 20:27:45 +00:00
|
|
|
|
|
|
|
void DDLTileHelper::createBackendTextures(SkTaskGroup* taskGroup, GrContext* context) {
|
|
|
|
SkASSERT(context->priv().asDirectContext());
|
|
|
|
|
|
|
|
if (taskGroup) {
|
|
|
|
for (int i = 0; i < this->numTiles(); ++i) {
|
|
|
|
TileData* tile = &fTiles[i];
|
|
|
|
|
|
|
|
taskGroup->add([context, tile]() { TileData::CreateBackendTexture(context, tile); });
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (int i = 0; i < this->numTiles(); ++i) {
|
|
|
|
TileData::CreateBackendTexture(context, &fTiles[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DDLTileHelper::deleteBackendTextures(SkTaskGroup* taskGroup, GrContext* context) {
|
|
|
|
SkASSERT(context->priv().asDirectContext());
|
|
|
|
|
|
|
|
if (taskGroup) {
|
|
|
|
for (int i = 0; i < this->numTiles(); ++i) {
|
|
|
|
TileData* tile = &fTiles[i];
|
|
|
|
|
|
|
|
taskGroup->add([context, tile]() { TileData::DeleteBackendTexture(context, tile); });
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (int i = 0; i < this->numTiles(); ++i) {
|
|
|
|
TileData::DeleteBackendTexture(context, &fTiles[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|