aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2016-12-13 18:48:08 +0000
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-12-13 18:48:20 +0000
commit293d696fcfb9f1c83019c4b15c4864cd6649ed78 (patch)
tree851514d761f33f5c508ddb8009338723cf52f27a /src/gpu
parent3c41773fcd5c8f4462aefcb2a5927aecdb2a1806 (diff)
Revert "Add a deferred copy surface"
This reverts commit 4431de6af930a8638c194b072558ea3a4b79d908. Reason for revert: ANGLE errors (at the very least) Original change's description: > Add a deferred copy surface > > This CL forces all GrSurface copies to go through a GrSurfaceContext (rather than GrContext). > > There is a bit of goofiness going on here until read/writePixels is also consolidated in GrSurfaceContext and a proxy-backed SkImage/SkSurface is added. > > Change-Id: Iab1867668d8146a766201158a251b9174438ee2b > Reviewed-on: https://skia-review.googlesource.com/5773 > Reviewed-by: Brian Osman <brianosman@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> > Commit-Queue: Robert Phillips <robertphillips@google.com> > TBR=bsalomon@google.com,robertphillips@google.com,brianosman@google.com NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Change-Id: I61408d9e306b9b1ab32f93ab086e95184e12857f Reviewed-on: https://skia-review.googlesource.com/5938 Commit-Queue: Robert Phillips <robertphillips@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src/gpu')
-rw-r--r--src/gpu/GrContext.cpp67
-rw-r--r--src/gpu/GrContextPriv.h7
-rw-r--r--src/gpu/GrRenderTargetContext.cpp16
-rw-r--r--src/gpu/GrRenderTargetContextPriv.h4
-rw-r--r--src/gpu/GrRenderTargetProxy.cpp8
-rw-r--r--src/gpu/GrSurfaceProxy.cpp50
-rw-r--r--src/gpu/GrTextureContext.cpp25
-rw-r--r--src/gpu/SkGpuDevice.cpp32
8 files changed, 66 insertions, 143 deletions
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 2e66c0c404..ff5b0266e6 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -541,6 +541,43 @@ void GrContext::prepareSurfaceForExternalIO(GrSurface* surface) {
fDrawingManager->prepareSurfaceForExternalIO(surface);
}
+bool GrContext::copySurface(GrSurface* dst, GrSurface* src, const SkIRect& srcRect,
+ const SkIPoint& dstPoint) {
+ ASSERT_SINGLE_OWNER
+ RETURN_FALSE_IF_ABANDONED
+ GR_AUDIT_TRAIL_AUTO_FRAME(&fAuditTrail, "GrContext::copySurface");
+
+ if (!src || !dst) {
+ return false;
+ }
+ ASSERT_OWNED_RESOURCE(src);
+ ASSERT_OWNED_RESOURCE(dst);
+
+ // We don't allow conversion between integer configs and float/fixed configs.
+ if (GrPixelConfigIsSint(dst->config()) != GrPixelConfigIsSint(src->config())) {
+ return false;
+ }
+
+#ifndef ENABLE_MDB
+ // We can't yet fully defer copies to textures, so GrTextureContext::copySurface will
+ // execute the copy immediately. Ensure the data is ready.
+ src->flushWrites();
+#endif
+
+ sk_sp<GrSurfaceContext> surfaceContext(
+ this->contextPriv().makeWrappedSurfaceContext(sk_ref_sp(dst)));
+
+ if (!surfaceContext) {
+ return false;
+ }
+
+ if (!surfaceContext->copySurface(src, srcRect, dstPoint)) {
+ return false;
+ }
+
+ return true;
+}
+
void GrContext::flushSurfaceWrites(GrSurface* surface) {
ASSERT_SINGLE_OWNER
RETURN_IF_ABANDONED
@@ -602,36 +639,8 @@ sk_sp<GrSurfaceContext> GrContextPriv::makeWrappedSurfaceContext(sk_sp<GrSurface
}
}
-sk_sp<GrSurfaceContext> GrContextPriv::makeDeferredSurfaceContext(const GrSurfaceDesc& dstDesc,
- SkBudgeted isDstBudgeted) {
-
- sk_sp<GrSurfaceProxy> proxy = GrSurfaceProxy::MakeDeferred(*fContext->caps(), dstDesc,
- SkBackingFit::kExact, isDstBudgeted);
-
- if (proxy->asRenderTargetProxy()) {
- return this->drawingManager()->makeRenderTargetContext(std::move(proxy), nullptr, nullptr);
- } else {
- SkASSERT(proxy->asTextureProxy());
- return this->drawingManager()->makeTextureContext(std::move(proxy));
- }
-
- return nullptr;
-}
-
-sk_sp<GrSurfaceContext> GrContextPriv::makeTestSurfaceContext(sk_sp<GrSurfaceProxy> proxy) {
-
- if (proxy->asRenderTargetProxy()) {
- return this->drawingManager()->makeRenderTargetContext(std::move(proxy), nullptr, nullptr);
- } else {
- SkASSERT(proxy->asTextureProxy());
- return this->drawingManager()->makeTextureContext(std::move(proxy));
- }
-
- return nullptr;
-}
-
sk_sp<GrRenderTargetContext> GrContextPriv::makeBackendTextureRenderTargetContext(
- const GrBackendTextureDesc& desc,
+ const GrBackendTextureDesc& desc,
sk_sp<SkColorSpace> colorSpace,
const SkSurfaceProps* props,
GrWrapOwnership ownership) {
diff --git a/src/gpu/GrContextPriv.h b/src/gpu/GrContextPriv.h
index 2b2a39e009..dcf0807507 100644
--- a/src/gpu/GrContextPriv.h
+++ b/src/gpu/GrContextPriv.h
@@ -11,8 +11,6 @@
#include "GrContext.h"
#include "GrSurfaceContext.h"
-class GrSurfaceProxy;
-
/** Class that adds methods to GrContext that are only intended for use internal to Skia.
This class is purely a privileged window into GrContext. It should never have additional
data members or virtual methods. */
@@ -28,11 +26,6 @@ public:
// Create a surfaceContext that wraps an existing texture or renderTarget
sk_sp<GrSurfaceContext> makeWrappedSurfaceContext(sk_sp<GrSurface> tex);
- sk_sp<GrSurfaceContext> makeDeferredSurfaceContext(const GrSurfaceDesc& dstDesc,
- SkBudgeted isDstBudgeted);
-
- sk_sp<GrSurfaceContext> makeTestSurfaceContext(sk_sp<GrSurfaceProxy> proxy);
-
sk_sp<GrRenderTargetContext> makeBackendTextureRenderTargetContext(
const GrBackendTextureDesc& desc,
sk_sp<SkColorSpace> colorSpace,
diff --git a/src/gpu/GrRenderTargetContext.cpp b/src/gpu/GrRenderTargetContext.cpp
index af50d873cc..a40473f566 100644
--- a/src/gpu/GrRenderTargetContext.cpp
+++ b/src/gpu/GrRenderTargetContext.cpp
@@ -133,20 +133,12 @@ GrRenderTargetOpList* GrRenderTargetContext::getOpList() {
return fOpList;
}
-// TODO: move this (and GrTextContext::copy) to GrSurfaceContext?
-bool GrRenderTargetContext::onCopy(GrSurfaceProxy* srcProxy,
- const SkIRect& srcRect,
- const SkIPoint& dstPoint) {
+bool GrRenderTargetContext::copySurface(GrSurface* src, const SkIRect& srcRect,
+ const SkIPoint& dstPoint) {
ASSERT_SINGLE_OWNER
RETURN_FALSE_IF_ABANDONED
SkDEBUGCODE(this->validate();)
- GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrRenderTargetContext::copy");
-
- // TODO: defer instantiation until flush time
- sk_sp<GrSurface> src(sk_ref_sp(srcProxy->instantiate(fContext->textureProvider())));
- if (!src) {
- return false;
- }
+ GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrRenderTargetContext::copySurface");
// TODO: this needs to be fixed up since it ends the deferrable of the GrRenderTarget
sk_sp<GrRenderTarget> rt(
@@ -155,7 +147,7 @@ bool GrRenderTargetContext::onCopy(GrSurfaceProxy* srcProxy,
return false;
}
- return this->getOpList()->copySurface(rt.get(), src.get(), srcRect, dstPoint);
+ return this->getOpList()->copySurface(rt.get(), src, srcRect, dstPoint);
}
void GrRenderTargetContext::drawText(const GrClip& clip, const GrPaint& grPaint,
diff --git a/src/gpu/GrRenderTargetContextPriv.h b/src/gpu/GrRenderTargetContextPriv.h
index f1548cc9fa..b3bd72a563 100644
--- a/src/gpu/GrRenderTargetContextPriv.h
+++ b/src/gpu/GrRenderTargetContextPriv.h
@@ -114,10 +114,6 @@ public:
const GrUserStencilSettings* = nullptr,
bool snapToCenters = false);
- bool refsWrappedObjects() const {
- return fRenderTargetContext->fRenderTargetProxy->refsWrappedObjects();
- }
-
private:
explicit GrRenderTargetContextPriv(GrRenderTargetContext* renderTargetContext)
: fRenderTargetContext(renderTargetContext) {}
diff --git a/src/gpu/GrRenderTargetProxy.cpp b/src/gpu/GrRenderTargetProxy.cpp
index 882acf660c..03637cf9af 100644
--- a/src/gpu/GrRenderTargetProxy.cpp
+++ b/src/gpu/GrRenderTargetProxy.cpp
@@ -8,7 +8,6 @@
#include "GrRenderTargetProxy.h"
#include "GrCaps.h"
-#include "GrGpuResourcePriv.h"
#include "GrRenderTargetOpList.h"
#include "GrRenderTargetPriv.h"
#include "GrTextureProvider.h"
@@ -64,10 +63,3 @@ size_t GrRenderTargetProxy::onGpuMemorySize() const {
return GrSurface::ComputeSize(fDesc, fDesc.fSampleCnt+1, false, SkBackingFit::kApprox == fFit);
}
-bool GrRenderTargetProxy::refsWrappedObjects() const {
- if (!fTarget) {
- return false;
- }
-
- return fTarget->resourcePriv().refsWrappedObjects();
-}
diff --git a/src/gpu/GrSurfaceProxy.cpp b/src/gpu/GrSurfaceProxy.cpp
index 24c7cfe29a..4a0c3480a4 100644
--- a/src/gpu/GrSurfaceProxy.cpp
+++ b/src/gpu/GrSurfaceProxy.cpp
@@ -8,11 +8,8 @@
#include "GrSurfaceProxy.h"
#include "GrCaps.h"
-#include "GrContext.h"
-#include "GrContextPriv.h"
#include "GrGpuResourcePriv.h"
#include "GrOpList.h"
-#include "GrSurfaceContext.h"
#include "GrTextureProvider.h"
#include "GrTextureRenderTargetProxy.h"
@@ -164,50 +161,3 @@ void GrSurfaceProxy::validate(GrContext* context) const {
INHERITED::validate();
}
#endif
-
-sk_sp<GrSurfaceProxy> GrSurfaceProxy::Copy(GrContext* context,
- GrSurfaceProxy* src,
- SkIRect srcRect,
- SkBudgeted budgeted) {
- if (!srcRect.intersect(SkIRect::MakeWH(src->width(), src->height()))) {
- return nullptr;
- }
-
- GrSurfaceDesc dstDesc = src->desc();
- dstDesc.fWidth = srcRect.width();
- dstDesc.fHeight = srcRect.height();
-
- sk_sp<GrSurfaceContext> dstContext(context->contextPriv().makeDeferredSurfaceContext(dstDesc,
- budgeted));
- if (!dstContext) {
- return nullptr;
- }
-
- if (!dstContext->copy(src, srcRect, SkIPoint::Make(0, 0))) {
- return nullptr;
- }
-
- return sk_ref_sp(dstContext->asDeferredSurface());
-}
-
-sk_sp<GrSurfaceProxy> GrSurfaceProxy::TestCopy(GrContext* context, const GrSurfaceDesc& dstDesc,
- GrTexture* srcTexture, SkBudgeted budgeted) {
-
- sk_sp<GrSurfaceContext> dstContext(context->contextPriv().makeDeferredSurfaceContext(
- dstDesc,
- budgeted));
- if (!dstContext) {
- return nullptr;
- }
-
- sk_sp<GrSurfaceProxy> srcProxy(GrSurfaceProxy::MakeWrapped(sk_ref_sp(srcTexture)));
- if (!srcProxy) {
- return nullptr;
- }
-
- if (!dstContext->copy(srcProxy.get())) {
- return nullptr;
- }
-
- return sk_ref_sp(dstContext->asDeferredSurface());
-}
diff --git a/src/gpu/GrTextureContext.cpp b/src/gpu/GrTextureContext.cpp
index 28240f8a79..22620fed0f 100644
--- a/src/gpu/GrTextureContext.cpp
+++ b/src/gpu/GrTextureContext.cpp
@@ -24,7 +24,8 @@ GrTextureContext::GrTextureContext(GrContext* context,
: GrSurfaceContext(context, auditTrail, singleOwner)
, fDrawingManager(drawingMgr)
, fTextureProxy(std::move(textureProxy))
- , fOpList(SkSafeRef(fTextureProxy->getLastTextureOpList())) {
+ , fOpList(SkSafeRef(fTextureProxy->getLastTextureOpList()))
+{
SkDEBUGCODE(this->validate();)
}
@@ -55,26 +56,12 @@ GrTextureOpList* GrTextureContext::getOpList() {
return fOpList;
}
-// TODO: move this (and GrRenderTargetContext::copy) to GrSurfaceContext?
-bool GrTextureContext::onCopy(GrSurfaceProxy* srcProxy,
- const SkIRect& srcRect,
- const SkIPoint& dstPoint) {
+bool GrTextureContext::copySurface(GrSurface* src, const SkIRect& srcRect,
+ const SkIPoint& dstPoint) {
ASSERT_SINGLE_OWNER
RETURN_FALSE_IF_ABANDONED
SkDEBUGCODE(this->validate();)
- GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrTextureContext::copy");
-
- // TODO: defer instantiation until flush time
- sk_sp<GrSurface> src(sk_ref_sp(srcProxy->instantiate(fContext->textureProvider())));
- if (!src) {
- return false;
- }
-
-#ifndef ENABLE_MDB
- // We can't yet fully defer copies to textures, so GrTextureContext::copySurface will
- // execute the copy immediately. Ensure the data is ready.
- src->flushWrites();
-#endif
+ GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrTextureContext::copySurface");
// TODO: this needs to be fixed up since it ends the deferrable of the GrTexture
sk_sp<GrTexture> tex(sk_ref_sp(fTextureProxy->instantiate(fContext->textureProvider())));
@@ -83,7 +70,7 @@ bool GrTextureContext::onCopy(GrSurfaceProxy* srcProxy,
}
GrTextureOpList* opList = this->getOpList();
- bool result = opList->copySurface(tex.get(), src.get(), srcRect, dstPoint);
+ bool result = opList->copySurface(tex.get(), src, srcRect, dstPoint);
#ifndef ENABLE_MDB
GrOpFlushState flushState(fContext->getGpu(), nullptr);
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 5738764a5b..3cdc34e982 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -15,7 +15,6 @@
#include "GrRenderTargetContextPriv.h"
#include "GrStyle.h"
#include "GrTextureAdjuster.h"
-#include "GrTextureProxy.h"
#include "GrTracing.h"
#include "SkCanvasPriv.h"
@@ -263,7 +262,9 @@ void SkGpuDevice::replaceRenderTargetContext(bool shouldRetainContent) {
if (fRenderTargetContext->wasAbandoned()) {
return;
}
- newRTC->copy(fRenderTargetContext->asDeferredSurface());
+ newRTC->copySurface(fRenderTargetContext->asTexture().get(),
+ SkIRect::MakeWH(this->width(), this->height()),
+ SkIPoint::Make(0, 0));
}
fRenderTargetContext = newRTC;
@@ -1331,15 +1332,19 @@ sk_sp<SkSpecialImage> SkGpuDevice::makeSpecial(const SkImage* image) {
}
sk_sp<SkSpecialImage> SkGpuDevice::snapSpecial() {
- sk_sp<GrSurfaceProxy> sProxy(sk_ref_sp(this->accessRenderTargetContext()->asDeferredTexture()));
- if (!sProxy) {
+ sk_sp<GrTexture> texture(this->accessRenderTargetContext()->asTexture());
+ if (!texture) {
// When the device doesn't have a texture, we create a temporary texture.
// TODO: we should actually only copy the portion of the source needed to apply the image
// filter
- sProxy = GrSurfaceProxy::Copy(fContext.get(),
- this->accessRenderTargetContext()->asDeferredSurface(),
- SkBudgeted::kYes);
- if (!sProxy) {
+ texture.reset(fContext->textureProvider()->createTexture(
+ this->accessRenderTargetContext()->desc(), SkBudgeted::kYes));
+ if (!texture) {
+ return nullptr;
+ }
+
+ if (!fContext->copySurface(texture.get(),
+ this->accessRenderTargetContext()->accessRenderTarget())) {
return nullptr;
}
}
@@ -1347,12 +1352,11 @@ sk_sp<SkSpecialImage> SkGpuDevice::snapSpecial() {
const SkImageInfo ii = this->imageInfo();
const SkIRect srcRect = SkIRect::MakeWH(ii.width(), ii.height());
- return SkSpecialImage::MakeDeferredFromGpu(fContext.get(),
- srcRect,
- kNeedNewImageUniqueID_SpecialImage,
- sProxy,
- sk_ref_sp(ii.colorSpace()),
- &this->surfaceProps());
+ return SkSpecialImage::MakeFromGpu(srcRect,
+ kNeedNewImageUniqueID_SpecialImage,
+ std::move(texture),
+ sk_ref_sp(ii.colorSpace()),
+ &this->surfaceProps());
}
void SkGpuDevice::drawDevice(const SkDraw& draw, SkBaseDevice* device,