aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2017-04-10 08:19:26 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-04-10 12:56:33 +0000
commita90aa2bfd430ca9bc321c3c7b3f1c727927606d1 (patch)
tree48176ea4a4fb3d529760e60ca9e9ca3978c5cf39 /src
parent768f52ff85662e6627438987e3277f3926eb6577 (diff)
consolidate read/writePixels in GrSurfaceContext
Change-Id: I118fcd49990597d4dfea92efd3f9d99e52fdbfab Reviewed-on: https://skia-review.googlesource.com/11481 Commit-Queue: Robert Phillips <robertphillips@google.com> Reviewed-by: Brian Osman <brianosman@google.com>
Diffstat (limited to 'src')
-rw-r--r--src/gpu/GrRenderTargetContext.cpp45
-rw-r--r--src/gpu/GrRenderTargetContext.h4
-rw-r--r--src/gpu/GrSurfaceContext.cpp44
-rw-r--r--src/gpu/GrSurfaceContext.h22
-rw-r--r--src/gpu/GrTextureContext.cpp42
-rw-r--r--src/gpu/GrTextureContext.h4
6 files changed, 52 insertions, 109 deletions
diff --git a/src/gpu/GrRenderTargetContext.cpp b/src/gpu/GrRenderTargetContext.cpp
index b0a1b6d4af..3aefde0dc5 100644
--- a/src/gpu/GrRenderTargetContext.cpp
+++ b/src/gpu/GrRenderTargetContext.cpp
@@ -42,9 +42,9 @@
#define ASSERT_OWNED_RESOURCE(R) SkASSERT(!(R) || (R)->getContext() == this->drawingManager()->getContext())
#define ASSERT_SINGLE_OWNER \
- SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(fSingleOwner);)
+ SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(this->singleOwner());)
#define ASSERT_SINGLE_OWNER_PRIV \
- SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(fRenderTargetContext->fSingleOwner);)
+ SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(fRenderTargetContext->singleOwner());)
#define RETURN_IF_ABANDONED if (this->drawingManager()->wasAbandoned()) { return; }
#define RETURN_IF_ABANDONED_PRIV if (fRenderTargetContext->drawingManager()->wasAbandoned()) { return; }
#define RETURN_FALSE_IF_ABANDONED if (this->drawingManager()->wasAbandoned()) { return false; }
@@ -141,47 +141,6 @@ bool GrRenderTargetContext::onCopy(GrSurfaceProxy* srcProxy,
fRenderTargetProxy.get(), srcProxy, srcRect, dstPoint);
}
-// TODO: move this (and GrTextureContext::onReadPixels) to GrSurfaceContext?
-bool GrRenderTargetContext::onReadPixels(const SkImageInfo& dstInfo, void* dstBuffer,
- size_t dstRowBytes, int x, int y, uint32_t flags) {
- // TODO: teach GrRenderTarget to take ImageInfo directly to specify the src pixels
- GrPixelConfig config = SkImageInfo2GrPixelConfig(dstInfo, *fContext->caps());
- if (kUnknown_GrPixelConfig == config) {
- return false;
- }
-
- // TODO: this seems to duplicate code in SkImage_Gpu::onReadPixels
- if (kUnpremul_SkAlphaType == dstInfo.alphaType()) {
- flags |= GrContextPriv::kUnpremul_PixelOpsFlag;
- }
-
- return fContext->contextPriv().readSurfacePixels(fRenderTargetProxy.get(),
- this->getColorSpace(), x, y,
- dstInfo.width(), dstInfo.height(), config,
- dstInfo.colorSpace(),
- dstBuffer, dstRowBytes, flags);
-}
-
-// TODO: move this (and GrTextureContext::onReadPixels) to GrSurfaceContext?
-bool GrRenderTargetContext::onWritePixels(const SkImageInfo& srcInfo, const void* srcBuffer,
- size_t srcRowBytes, int x, int y, uint32_t flags) {
- // TODO: teach GrRenderTarget to take ImageInfo directly to specify the src pixels
- GrPixelConfig config = SkImageInfo2GrPixelConfig(srcInfo, *fContext->caps());
- if (kUnknown_GrPixelConfig == config) {
- return false;
- }
- if (kUnpremul_SkAlphaType == srcInfo.alphaType()) {
- flags |= GrContextPriv::kUnpremul_PixelOpsFlag;
- }
-
- return fContext->contextPriv().writeSurfacePixels(fRenderTargetProxy.get(),
- this->getColorSpace(), x, y,
- srcInfo.width(), srcInfo.height(),
- config, srcInfo.colorSpace(),
- srcBuffer, srcRowBytes, flags);
-}
-
-
void GrRenderTargetContext::drawText(const GrClip& clip, const SkPaint& skPaint,
const SkMatrix& viewMatrix, const char text[],
size_t byteLength, SkScalar x, SkScalar y,
diff --git a/src/gpu/GrRenderTargetContext.h b/src/gpu/GrRenderTargetContext.h
index 8feec78c3b..1d1f9ecd18 100644
--- a/src/gpu/GrRenderTargetContext.h
+++ b/src/gpu/GrRenderTargetContext.h
@@ -457,10 +457,6 @@ private:
const GrClip&, GrPaint&&, GrAA, const SkMatrix&, const SkPath&, const GrStyle&);
bool onCopy(GrSurfaceProxy* src, const SkIRect& srcRect, const SkIPoint& dstPoint) override;
- bool onReadPixels(const SkImageInfo& dstInfo, void* dstBuffer,
- size_t dstRowBytes, int x, int y, uint32_t flags) override;
- bool onWritePixels(const SkImageInfo& srcInfo, const void* srcBuffer,
- size_t srcRowBytes, int x, int y, uint32_t flags) override;
// These perform processing specific to Gr[Mesh]DrawOp-derived ops before recording them into
// the op list. They return the id of the opList to which the op was added, or 0, if it was
diff --git a/src/gpu/GrSurfaceContext.cpp b/src/gpu/GrSurfaceContext.cpp
index a28c27a649..6b6a942720 100644
--- a/src/gpu/GrSurfaceContext.cpp
+++ b/src/gpu/GrSurfaceContext.cpp
@@ -6,7 +6,10 @@
*/
#include "GrSurfaceContext.h"
+
+#include "GrContextPriv.h"
#include "SkColorSpace_Base.h"
+#include "SkGr.h"
#include "../private/GrAuditTrail.h"
@@ -23,8 +26,47 @@ GrSurfaceContext::GrSurfaceContext(GrContext* context,
: fContext(context)
, fColorSpace(std::move(colorSpace))
, fAuditTrail(auditTrail)
+ , fDrawingManager(drawingMgr)
#ifdef SK_DEBUG
, fSingleOwner(singleOwner)
#endif
- , fDrawingManager(drawingMgr) {
+{
+}
+
+bool GrSurfaceContext::readPixels(const SkImageInfo& dstInfo, void* dstBuffer,
+ size_t dstRowBytes, int x, int y, uint32_t flags) {
+ // TODO: teach GrRenderTarget to take ImageInfo directly to specify the src pixels
+ GrPixelConfig config = SkImageInfo2GrPixelConfig(dstInfo, *fContext->caps());
+ if (kUnknown_GrPixelConfig == config) {
+ return false;
+ }
+
+ // TODO: this seems to duplicate code in SkImage_Gpu::onReadPixels
+ if (kUnpremul_SkAlphaType == dstInfo.alphaType()) {
+ flags |= GrContextPriv::kUnpremul_PixelOpsFlag;
+ }
+
+ return fContext->contextPriv().readSurfacePixels(this->asSurfaceProxy(),
+ this->getColorSpace(), x, y,
+ dstInfo.width(), dstInfo.height(), config,
+ dstInfo.colorSpace(),
+ dstBuffer, dstRowBytes, flags);
+}
+
+bool GrSurfaceContext::writePixels(const SkImageInfo& srcInfo, const void* srcBuffer,
+ size_t srcRowBytes, int x, int y, uint32_t flags) {
+ // TODO: teach GrRenderTarget to take ImageInfo directly to specify the src pixels
+ GrPixelConfig config = SkImageInfo2GrPixelConfig(srcInfo, *fContext->caps());
+ if (kUnknown_GrPixelConfig == config) {
+ return false;
+ }
+ if (kUnpremul_SkAlphaType == srcInfo.alphaType()) {
+ flags |= GrContextPriv::kUnpremul_PixelOpsFlag;
+ }
+
+ return fContext->contextPriv().writeSurfacePixels(this->asSurfaceProxy(),
+ this->getColorSpace(), x, y,
+ srcInfo.width(), srcInfo.height(),
+ config, srcInfo.colorSpace(),
+ srcBuffer, srcRowBytes, flags);
}
diff --git a/src/gpu/GrSurfaceContext.h b/src/gpu/GrSurfaceContext.h
index 88badc1c6e..bab753c069 100644
--- a/src/gpu/GrSurfaceContext.h
+++ b/src/gpu/GrSurfaceContext.h
@@ -74,9 +74,7 @@ public:
* unsupported pixel config.
*/
bool readPixels(const SkImageInfo& dstInfo, void* dstBuffer, size_t dstRowBytes,
- int x, int y, uint32_t flags = 0) {
- return this->onReadPixels(dstInfo, dstBuffer, dstRowBytes, x, y, flags);
- }
+ int x, int y, uint32_t flags = 0);
/**
* Writes a rectangle of pixels [srcInfo, srcBuffer, srcRowbytes] into the
@@ -91,9 +89,7 @@ public:
* unsupported pixel config.
*/
bool writePixels(const SkImageInfo& srcInfo, const void* srcBuffer, size_t srcRowBytes,
- int x, int y, uint32_t flags = 0) {
- return this->onWritePixels(srcInfo, srcBuffer, srcRowBytes, x, y, flags);
- }
+ int x, int y, uint32_t flags = 0);
// TODO: this is virtual b.c. this object doesn't have a pointer to the wrapped GrSurfaceProxy?
virtual GrSurfaceProxy* asSurfaceProxy() = 0;
@@ -129,20 +125,14 @@ protected:
sk_sp<SkColorSpace> fColorSpace;
GrAuditTrail* fAuditTrail;
- // In debug builds we guard against improper thread handling
- SkDEBUGCODE(mutable GrSingleOwner* fSingleOwner;)
-
private:
- virtual bool onCopy(GrSurfaceProxy* src,
- const SkIRect& srcRect,
- const SkIPoint& dstPoint) = 0;
- virtual bool onReadPixels(const SkImageInfo& dstInfo, void* dstBuffer,
- size_t dstRowBytes, int x, int y, uint32_t flags) = 0;
- virtual bool onWritePixels(const SkImageInfo& srcInfo, const void* srcBuffer,
- size_t srcRowBytes, int x, int y, uint32_t flags) = 0;
+ virtual bool onCopy(GrSurfaceProxy* src, const SkIRect& srcRect, const SkIPoint& dstPoint) = 0;
GrDrawingManager* fDrawingManager;
+ // In debug builds we guard against improper thread handling
+ SkDEBUGCODE(mutable GrSingleOwner* fSingleOwner;)
+
typedef SkRefCnt INHERITED;
};
diff --git a/src/gpu/GrTextureContext.cpp b/src/gpu/GrTextureContext.cpp
index ca6f7a20bd..76b7588e39 100644
--- a/src/gpu/GrTextureContext.cpp
+++ b/src/gpu/GrTextureContext.cpp
@@ -15,7 +15,7 @@
#include "../private/GrAuditTrail.h"
#define ASSERT_SINGLE_OWNER \
- SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(fSingleOwner);)
+ SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(this->singleOwner());)
#define RETURN_FALSE_IF_ABANDONED if (this->drawingManager()->wasAbandoned()) { return false; }
GrTextureContext::GrTextureContext(GrContext* context,
@@ -98,43 +98,3 @@ bool GrTextureContext::onCopy(GrSurfaceProxy* srcProxy,
return result;
}
-// TODO: move this (and GrRenderTargetContext::onReadPixels) to GrSurfaceContext?
-bool GrTextureContext::onReadPixels(const SkImageInfo& dstInfo, void* dstBuffer,
- size_t dstRowBytes, int x, int y, uint32_t flags) {
- // TODO: teach GrTexture to take ImageInfo directly to specify the src pixels
- GrPixelConfig config = SkImageInfo2GrPixelConfig(dstInfo, *fContext->caps());
- if (kUnknown_GrPixelConfig == config) {
- return false;
- }
-
- // TODO: this seems to duplicate code in SkImage_Gpu::onReadPixels
- if (kUnpremul_SkAlphaType == dstInfo.alphaType()) {
- flags |= GrContextPriv::kUnpremul_PixelOpsFlag;
- }
-
- return fContext->contextPriv().readSurfacePixels(fTextureProxy.get(), this->getColorSpace(),
- x, y, dstInfo.width(), dstInfo.height(),
- config,
- dstInfo.colorSpace(), dstBuffer, dstRowBytes,
- flags);
-}
-
-// TODO: move this (and GrRenderTargetContext::onReadPixels) to GrSurfaceContext?
-bool GrTextureContext::onWritePixels(const SkImageInfo& srcInfo, const void* srcBuffer,
- size_t srcRowBytes, int x, int y,
- uint32_t flags) {
- // TODO: teach GrTexture to take ImageInfo directly to specify the src pixels
- GrPixelConfig config = SkImageInfo2GrPixelConfig(srcInfo, *fContext->caps());
- if (kUnknown_GrPixelConfig == config) {
- return false;
- }
- if (kUnpremul_SkAlphaType == srcInfo.alphaType()) {
- flags |= GrContextPriv::kUnpremul_PixelOpsFlag;
- }
-
- return fContext->contextPriv().writeSurfacePixels(fTextureProxy.get(), this->getColorSpace(),
- x, y, srcInfo.width(), srcInfo.height(),
- config,
- srcInfo.colorSpace(), srcBuffer, srcRowBytes,
- flags);
-}
diff --git a/src/gpu/GrTextureContext.h b/src/gpu/GrTextureContext.h
index d5e1eb9b7c..995ebf53d2 100644
--- a/src/gpu/GrTextureContext.h
+++ b/src/gpu/GrTextureContext.h
@@ -47,10 +47,6 @@ private:
friend class GrDrawingManager; // for ctor
bool onCopy(GrSurfaceProxy* src, const SkIRect& srcRect, const SkIPoint& dstPoint) override;
- bool onReadPixels(const SkImageInfo& dstInfo, void* dstBuffer,
- size_t dstRowBytes, int x, int y, uint32_t flags) override;
- bool onWritePixels(const SkImageInfo& srcInfo, const void* srcBuffer,
- size_t srcRowBytes, int x, int y, uint32_t flags) override;
GrTextureOpList* getOpList();