Make op-level texture uploading be GrProxy-based
Change-Id: I898d626eff059fa7c687357b536d09409a174358
Reviewed-on: https://skia-review.googlesource.com/28001
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/GrDrawOpAtlas.cpp b/src/gpu/GrDrawOpAtlas.cpp
index 897622a..9b2afc7 100644
--- a/src/gpu/GrDrawOpAtlas.cpp
+++ b/src/gpu/GrDrawOpAtlas.cpp
@@ -129,15 +129,15 @@
}
void GrDrawOpAtlas::Plot::uploadToTexture(GrDrawOp::WritePixelsFn& writePixels,
- GrTexture* texture) {
+ GrTextureProxy* proxy) {
// We should only be issuing uploads if we are in fact dirty
- SkASSERT(fDirty && fData && texture);
+ SkASSERT(fDirty && fData && proxy && proxy->priv().peekTexture());
TRACE_EVENT0("skia.gpu", TRACE_FUNC);
size_t rowBytes = fBytesPerPixel * fWidth;
const unsigned char* dataPtr = fData;
dataPtr += rowBytes * fDirtyRect.fTop;
dataPtr += fBytesPerPixel * fDirtyRect.fLeft;
- writePixels(texture, fOffset.fX + fDirtyRect.fLeft, fOffset.fY + fDirtyRect.fTop,
+ writePixels(proxy, fOffset.fX + fDirtyRect.fLeft, fOffset.fY + fDirtyRect.fTop,
fDirtyRect.width(), fDirtyRect.height(), fConfig, dataPtr, rowBytes);
fDirtyRect.setEmpty();
SkDEBUGCODE(fDirty = false;)
@@ -213,11 +213,12 @@
if (!fProxy->instantiate(fContext->resourceProvider())) {
return false;
}
- GrTexture* texture = fProxy->priv().peekTexture();
+
+ GrTextureProxy* proxy = fProxy.get();
GrDrawOpUploadToken lastUploadToken = target->addAsapUpload(
- [plotsp, texture] (GrDrawOp::WritePixelsFn& writePixels) {
- plotsp->uploadToTexture(writePixels, texture);
+ [plotsp, proxy] (GrDrawOp::WritePixelsFn& writePixels) {
+ plotsp->uploadToTexture(writePixels, proxy);
}
);
plot->setLastUploadToken(lastUploadToken);
@@ -292,11 +293,11 @@
if (!fProxy->instantiate(fContext->resourceProvider())) {
return false;
}
- GrTexture* texture = fProxy->priv().peekTexture();
+ GrTextureProxy* proxy = fProxy.get();
GrDrawOpUploadToken lastUploadToken = target->addInlineUpload(
- [plotsp, texture] (GrDrawOp::WritePixelsFn& writePixels) {
- plotsp->uploadToTexture(writePixels, texture);
+ [plotsp, proxy] (GrDrawOp::WritePixelsFn& writePixels) {
+ plotsp->uploadToTexture(writePixels, proxy);
}
);
newPlot->setLastUploadToken(lastUploadToken);
diff --git a/src/gpu/GrDrawOpAtlas.h b/src/gpu/GrDrawOpAtlas.h
index 1119e3d..87bd695 100644
--- a/src/gpu/GrDrawOpAtlas.h
+++ b/src/gpu/GrDrawOpAtlas.h
@@ -216,7 +216,7 @@
void setLastUploadToken(GrDrawOpUploadToken token) { fLastUpload = token; }
void setLastUseToken(GrDrawOpUploadToken token) { fLastUse = token; }
- void uploadToTexture(GrDrawOp::WritePixelsFn&, GrTexture* texture);
+ void uploadToTexture(GrDrawOp::WritePixelsFn&, GrTextureProxy*);
void resetRects();
private:
diff --git a/src/gpu/GrOpFlushState.cpp b/src/gpu/GrOpFlushState.cpp
index a7129d1..30636a4 100644
--- a/src/gpu/GrOpFlushState.cpp
+++ b/src/gpu/GrOpFlushState.cpp
@@ -51,31 +51,35 @@
}
void GrOpFlushState::doUpload(GrDrawOp::DeferredUploadFn& upload) {
- GrDrawOp::WritePixelsFn wp = [this](GrSurface* surface, int left, int top, int width,
+ GrDrawOp::WritePixelsFn wp = [this](GrTextureProxy* proxy,
+ int left, int top, int width,
int height, GrPixelConfig config, const void* buffer,
size_t rowBytes) {
+ GrSurface* surface = proxy->priv().peekSurface();
GrGpu::DrawPreference drawPreference = GrGpu::kNoDraw_DrawPreference;
GrGpu::WritePixelTempDrawInfo tempInfo;
- fGpu->getWritePixelsInfo(surface, width, height, surface->config(), &drawPreference,
- &tempInfo);
+ fGpu->getWritePixelsInfo(surface, width, height, proxy->config(),
+ &drawPreference, &tempInfo);
if (GrGpu::kNoDraw_DrawPreference == drawPreference) {
- return this->fGpu->writePixels(surface, left, top, width, height, config, buffer,
- rowBytes);
+ return this->fGpu->writePixels(surface, left, top, width, height,
+ config, buffer, rowBytes);
}
GrSurfaceDesc desc;
- desc.fConfig = surface->config();
+ desc.fOrigin = proxy->origin();
desc.fWidth = width;
desc.fHeight = height;
- desc.fOrigin = surface->origin();
+ desc.fConfig = proxy->config();
sk_sp<GrTexture> temp(this->fResourceProvider->createApproxTexture(
desc, GrResourceProvider::kNoPendingIO_Flag));
if (!temp) {
return false;
}
- if (!fGpu->writePixels(temp.get(), 0, 0, width, height, desc.fConfig, buffer, rowBytes)) {
+ if (!fGpu->writePixels(temp.get(), 0, 0, width, height, desc.fConfig,
+ buffer, rowBytes)) {
return false;
}
- return fGpu->copySurface(surface, temp.get(), SkIRect::MakeWH(width, height), {left, top});
+ return fGpu->copySurface(surface, temp.get(),
+ SkIRect::MakeWH(width, height), {left, top});
};
upload(wp);
}
diff --git a/src/gpu/ops/GrDrawOp.h b/src/gpu/ops/GrDrawOp.h
index 58ef71a..54b9f16 100644
--- a/src/gpu/ops/GrDrawOp.h
+++ b/src/gpu/ops/GrDrawOp.h
@@ -47,7 +47,7 @@
class GrDrawOp : public GrOp {
public:
/** Method that performs an upload on behalf of a DeferredUploadFn. */
- using WritePixelsFn = std::function<bool(GrSurface* texture,
+ using WritePixelsFn = std::function<bool(GrTextureProxy*,
int left, int top, int width, int height,
GrPixelConfig config, const void* buffer,
size_t rowBytes)>;