aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2017-01-18 10:08:39 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-01-18 16:22:59 +0000
commit2c86249465c28a532c8be55b6ba497021e3110ec (patch)
treeb33ecbfb9bfdb8e848e461ea67beeca1097d9cb6 /include
parentdfff166db5d5226dc002a22ab3e3097ef971d615 (diff)
Move read/write-Pixels up to GrSurfaceContext
This still needs to be propagated out in several ways: replace more instances of GrSurface::read/write-Pixels add colorSpace to more instances of the TextureContext but it establishes a beach-head and is exciting enough as is. Change-Id: If86035aa0245e70b54541e83722b3c75bc5ade13 Reviewed-on: https://skia-review.googlesource.com/7172 Reviewed-by: Brian Osman <brianosman@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'include')
-rw-r--r--include/gpu/GrRenderTargetContext.h38
-rw-r--r--include/gpu/GrSurfaceContext.h44
-rw-r--r--include/gpu/GrTextureContext.h8
3 files changed, 54 insertions, 36 deletions
diff --git a/include/gpu/GrRenderTargetContext.h b/include/gpu/GrRenderTargetContext.h
index 3636d5cfc1..e595a4f90f 100644
--- a/include/gpu/GrRenderTargetContext.h
+++ b/include/gpu/GrRenderTargetContext.h
@@ -316,34 +316,6 @@ public:
*/
void prepareForExternalIO();
- /**
- * Reads a rectangle of pixels from the render target context.
- * @param dstInfo image info for the destination
- * @param dstBuffer destination pixels for the read
- * @param dstRowBytes bytes in a row of 'dstBuffer'
- * @param x x offset w/in the render target context from which to read
- * @param y y offset w/in the render target context from which to read
- *
- * @return true if the read succeeded, false if not. The read can fail because of an
- * unsupported pixel config.
- */
- bool readPixels(const SkImageInfo& dstInfo, void* dstBuffer, size_t dstRowBytes, int x, int y);
-
- /**
- * Writes a rectangle of pixels [srcInfo, srcBuffer, srcRowbytes] into the
- * renderTargetContext at the specified position.
- * @param srcInfo image info for the source pixels
- * @param srcBuffer source for the write
- * @param srcRowBytes bytes in a row of 'srcBuffer'
- * @param x x offset w/in the render target context at which to write
- * @param y y offset w/in the render target context at which to write
- *
- * @return true if the write succeeded, false if not. The write can fail because of an
- * unsupported pixel config.
- */
- bool writePixels(const SkImageInfo& srcInfo, const void* srcBuffer, size_t srcRowBytes,
- int x, int y);
-
bool isStencilBufferMultisampled() const {
return fRenderTargetProxy->isStencilBufferMultisampled();
}
@@ -356,10 +328,7 @@ public:
int height() const { return fRenderTargetProxy->height(); }
GrPixelConfig config() const { return fRenderTargetProxy->config(); }
int numColorSamples() const { return fRenderTargetProxy->numColorSamples(); }
- bool isGammaCorrect() const { return SkToBool(fColorSpace.get()); }
const SkSurfaceProps& surfaceProps() const { return fSurfaceProps; }
- SkColorSpace* getColorSpace() const { return fColorSpace.get(); }
- sk_sp<SkColorSpace> refColorSpace() const { return fColorSpace; }
GrColorSpaceXform* getColorXformFromSRGB() const { return fColorXformFromSRGB.get(); }
GrSurfaceOrigin origin() const { return fRenderTargetProxy->origin(); }
@@ -396,7 +365,7 @@ public:
protected:
GrRenderTargetContext(GrContext*, GrDrawingManager*, sk_sp<GrRenderTargetProxy>,
- sk_sp<SkColorSpace>, const SkSurfaceProps* surfaceProps, GrAuditTrail*,
+ sk_sp<SkColorSpace>, const SkSurfaceProps*, GrAuditTrail*,
GrSingleOwner*);
GrDrawingManager* drawingManager() { return fDrawingManager; }
@@ -469,6 +438,10 @@ 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) override;
+ bool onWritePixels(const SkImageInfo& srcInfo, const void* srcBuffer,
+ size_t srcRowBytes, int x, int y) override;
// This entry point allows the GrTextContext-derived classes to add their ops to the GrOpList.
void addDrawOp(const GrPipelineBuilder&, const GrClip&, std::unique_ptr<GrDrawOp>);
@@ -483,7 +456,6 @@ private:
GrRenderTargetOpList* fOpList;
GrInstancedPipelineInfo fInstancedPipelineInfo;
- sk_sp<SkColorSpace> fColorSpace;
sk_sp<GrColorSpaceXform> fColorXformFromSRGB;
SkSurfaceProps fSurfaceProps;
diff --git a/include/gpu/GrSurfaceContext.h b/include/gpu/GrSurfaceContext.h
index a772d19c27..6a40f2f8b2 100644
--- a/include/gpu/GrSurfaceContext.h
+++ b/include/gpu/GrSurfaceContext.h
@@ -30,6 +30,10 @@ class SK_API GrSurfaceContext : public SkRefCnt {
public:
~GrSurfaceContext() override {}
+ SkColorSpace* getColorSpace() const { return fColorSpace.get(); }
+ sk_sp<SkColorSpace> refColorSpace() const { return fColorSpace; }
+ bool isGammaCorrect() const { return SkToBool(fColorSpace.get()); }
+
/*
* Copy 'src' into the proxy backing this context
* @param src src of pixels
@@ -52,6 +56,39 @@ public:
SkIPoint::Make(0, 0));
}
+ /**
+ * Reads a rectangle of pixels from the render target context.
+ * @param dstInfo image info for the destination
+ * @param dstBuffer destination pixels for the read
+ * @param dstRowBytes bytes in a row of 'dstBuffer'
+ * @param x x offset w/in the render target context from which to read
+ * @param y y offset w/in the render target context from which to read
+ *
+ * @return true if the read succeeded, false if not. The read can fail because of an
+ * unsupported pixel config.
+ */
+ bool readPixels(const SkImageInfo& dstInfo, void* dstBuffer, size_t dstRowBytes,
+ int x, int y) {
+ return this->onReadPixels(dstInfo, dstBuffer, dstRowBytes, x, y);
+ }
+
+ /**
+ * Writes a rectangle of pixels [srcInfo, srcBuffer, srcRowbytes] into the
+ * renderTargetContext at the specified position.
+ * @param srcInfo image info for the source pixels
+ * @param srcBuffer source for the write
+ * @param srcRowBytes bytes in a row of 'srcBuffer'
+ * @param x x offset w/in the render target context at which to write
+ * @param y y offset w/in the render target context at which to write
+ *
+ * @return true if the write succeeded, false if not. The write can fail because of an
+ * unsupported pixel config.
+ */
+ bool writePixels(const SkImageInfo& srcInfo, const void* srcBuffer, size_t srcRowBytes,
+ int x, int y) {
+ return this->onWritePixels(srcInfo, srcBuffer, srcRowBytes, x, y);
+ }
+
// TODO: this is virtual b.c. this object doesn't have a pointer to the wrapped GrSurfaceProxy?
virtual GrSurfaceProxy* asDeferredSurface() = 0;
virtual GrTextureProxy* asDeferredTexture() = 0;
@@ -66,11 +103,12 @@ public:
protected:
friend class GrSurfaceContextPriv;
- GrSurfaceContext(GrContext*, GrAuditTrail*, GrSingleOwner*);
+ GrSurfaceContext(GrContext*, sk_sp<SkColorSpace>, GrAuditTrail*, GrSingleOwner*);
SkDEBUGCODE(GrSingleOwner* singleOwner() { return fSingleOwner; })
GrContext* fContext;
+ sk_sp<SkColorSpace> fColorSpace;
GrAuditTrail* fAuditTrail;
// In debug builds we guard against improper thread handling
@@ -80,6 +118,10 @@ 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) = 0;
+ virtual bool onWritePixels(const SkImageInfo& srcInfo, const void* srcBuffer,
+ size_t srcRowBytes, int x, int y) = 0;
typedef SkRefCnt INHERITED;
};
diff --git a/include/gpu/GrTextureContext.h b/include/gpu/GrTextureContext.h
index ef9613f3c3..b49b27255a 100644
--- a/include/gpu/GrTextureContext.h
+++ b/include/gpu/GrTextureContext.h
@@ -32,8 +32,8 @@ public:
GrRenderTargetProxy* asDeferredRenderTarget() override;
protected:
- GrTextureContext(GrContext*, GrDrawingManager*, sk_sp<GrTextureProxy>, GrAuditTrail*,
- GrSingleOwner*);
+ GrTextureContext(GrContext*, GrDrawingManager*, sk_sp<GrTextureProxy>,
+ sk_sp<SkColorSpace>, GrAuditTrail*, GrSingleOwner*);
GrDrawingManager* drawingManager() { return fDrawingManager; }
@@ -43,6 +43,10 @@ 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) override;
+ bool onWritePixels(const SkImageInfo& srcInfo, const void* srcBuffer,
+ size_t srcRowBytes, int x, int y) override;
GrTextureOpList* getOpList();