aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2017-07-28 10:54:53 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-07-28 15:22:57 +0000
commitacaa607328fb0dfac0894d4a2fcdead520e696b3 (patch)
tree39ddb2a9f9bc56c861b2ba37edd20dadb2652159
parent5d169ed337c009175783f77f56b5d96f0e3ece67 (diff)
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>
-rw-r--r--src/gpu/GrDrawOpAtlas.cpp19
-rw-r--r--src/gpu/GrDrawOpAtlas.h2
-rw-r--r--src/gpu/GrOpFlushState.cpp22
-rw-r--r--src/gpu/ops/GrDrawOp.h2
4 files changed, 25 insertions, 20 deletions
diff --git a/src/gpu/GrDrawOpAtlas.cpp b/src/gpu/GrDrawOpAtlas.cpp
index 897622ac28..9b2afc774f 100644
--- a/src/gpu/GrDrawOpAtlas.cpp
+++ b/src/gpu/GrDrawOpAtlas.cpp
@@ -129,15 +129,15 @@ bool GrDrawOpAtlas::Plot::addSubImage(int width, int height, const void* image,
}
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 @@ inline bool GrDrawOpAtlas::updatePlot(GrDrawOp::Target* target, AtlasID* id, Plo
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 @@ bool GrDrawOpAtlas::addToAtlas(AtlasID* id, GrDrawOp::Target* target, int width,
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 1119e3de18..87bd6954f4 100644
--- a/src/gpu/GrDrawOpAtlas.h
+++ b/src/gpu/GrDrawOpAtlas.h
@@ -216,7 +216,7 @@ private:
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 a7129d1671..30636a4413 100644
--- a/src/gpu/GrOpFlushState.cpp
+++ b/src/gpu/GrOpFlushState.cpp
@@ -51,31 +51,35 @@ uint16_t* GrOpFlushState::makeIndexSpaceAtLeast(int minIndexCount, int fallbackI
}
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 58ef71ac90..54b9f1674b 100644
--- a/src/gpu/ops/GrDrawOp.h
+++ b/src/gpu/ops/GrDrawOp.h
@@ -47,7 +47,7 @@ private:
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)>;