aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrSurfaceContext.cpp
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2017-06-28 10:33:41 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-06-28 16:44:36 +0000
commit2de8cfadc34cd92a6f99659fa565c137b386fa5f (patch)
tree51a1eed5bdb6d8df712030f62f68ea1a33a3a5bc /src/gpu/GrSurfaceContext.cpp
parent90ca37726b6e00a1f5cde43e0c1fd0b0ad87b0d3 (diff)
Move copy operation from GrRenderTargetContext/GrTextureContext to GrSurfaceContext
Change-Id: I5f48ce9978370f07238a7318ccb6270e10069c92 Reviewed-on: https://skia-review.googlesource.com/21104 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src/gpu/GrSurfaceContext.cpp')
-rw-r--r--src/gpu/GrSurfaceContext.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/gpu/GrSurfaceContext.cpp b/src/gpu/GrSurfaceContext.cpp
index 2bde24baf5..52ace3ff32 100644
--- a/src/gpu/GrSurfaceContext.cpp
+++ b/src/gpu/GrSurfaceContext.cpp
@@ -8,11 +8,16 @@
#include "GrSurfaceContext.h"
#include "GrContextPriv.h"
+#include "GrDrawingManager.h"
+#include "GrOpList.h"
#include "SkColorSpace_Base.h"
#include "SkGr.h"
#include "../private/GrAuditTrail.h"
+#define ASSERT_SINGLE_OWNER \
+ SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(this->singleOwner());)
+#define RETURN_FALSE_IF_ABANDONED if (this->drawingManager()->wasAbandoned()) { return false; }
// In MDB mode the reffing of the 'getLastOpList' call's result allows in-progress
// GrOpLists to be picked up and added to by renderTargetContexts lower in the call
@@ -35,6 +40,11 @@ GrSurfaceContext::GrSurfaceContext(GrContext* context,
bool GrSurfaceContext::readPixels(const SkImageInfo& dstInfo, void* dstBuffer,
size_t dstRowBytes, int x, int y, uint32_t flags) {
+ ASSERT_SINGLE_OWNER
+ RETURN_FALSE_IF_ABANDONED
+ SkDEBUGCODE(this->validate();)
+ GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrSurfaceContext::readPixels");
+
// TODO: teach GrRenderTarget to take ImageInfo directly to specify the src pixels
GrPixelConfig config = SkImageInfo2GrPixelConfig(dstInfo, *fContext->caps());
if (kUnknown_GrPixelConfig == config) {
@@ -54,6 +64,11 @@ bool GrSurfaceContext::readPixels(const SkImageInfo& dstInfo, void* dstBuffer,
bool GrSurfaceContext::writePixels(const SkImageInfo& srcInfo, const void* srcBuffer,
size_t srcRowBytes, int x, int y, uint32_t flags) {
+ ASSERT_SINGLE_OWNER
+ RETURN_FALSE_IF_ABANDONED
+ SkDEBUGCODE(this->validate();)
+ GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrSurfaceContext::writePixels");
+
// TODO: teach GrRenderTarget to take ImageInfo directly to specify the src pixels
GrPixelConfig config = SkImageInfo2GrPixelConfig(srcInfo, *fContext->caps());
if (kUnknown_GrPixelConfig == config) {
@@ -68,3 +83,13 @@ bool GrSurfaceContext::writePixels(const SkImageInfo& srcInfo, const void* srcBu
config, srcInfo.colorSpace(),
srcBuffer, srcRowBytes, flags);
}
+
+bool GrSurfaceContext::copy(GrSurfaceProxy* src, const SkIRect& srcRect, const SkIPoint& dstPoint) {
+ ASSERT_SINGLE_OWNER
+ RETURN_FALSE_IF_ABANDONED
+ SkDEBUGCODE(this->validate();)
+ GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrSurfaceContext::onCopy");
+
+ return this->getOpList()->copySurface(*fContext->caps(),
+ this->asSurfaceProxy(), src, srcRect, dstPoint);
+}