aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2017-04-05 12:45:52 +0000
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-04-05 12:46:02 +0000
commit171cc5fc87ede62712923f5a01db58059a027700 (patch)
tree7cdad3bf4c252d43badcc9ce6442f9a2368dadb3 /include
parent1cfcf2b167754cd3a9158ff6b73407c238c86269 (diff)
Revert "Rm readPixels from GrSurface & move read/writeSurfacePixels to GrContextPriv"
This reverts commit fb0bd98a43fa11e09705837418167dd72bb4a361. Reason for revert: ANGLE failures Original change's description: > Rm readPixels from GrSurface & move read/writeSurfacePixels to GrContextPriv > > This is in service of: https://skia-review.googlesource.com/c/11125/ (Add parallel proxyID to StencilOps & RenderTargetOpList) where I want a better choke point for texture creation to improve discard handling. > > Change-Id: If57a7de47edc0853dae7bc61337d9acdc03d63b0 > Reviewed-on: https://skia-review.googlesource.com/11200 > Reviewed-by: Brian Salomon <bsalomon@google.com> > Commit-Queue: Robert Phillips <robertphillips@google.com> > TBR=bsalomon@google.com,robertphillips@google.com,reviews@skia.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Change-Id: I7241070dc1f9df47181061e07adab141f9857974 Reviewed-on: https://skia-review.googlesource.com/11324 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'include')
-rw-r--r--include/gpu/GrContext.h62
-rw-r--r--include/gpu/GrProcessorUnitTest.h6
-rw-r--r--include/gpu/GrSurface.h100
3 files changed, 165 insertions, 3 deletions
diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h
index 0987d96b2e..ccd27286c7 100644
--- a/include/gpu/GrContext.h
+++ b/include/gpu/GrContext.h
@@ -246,6 +246,68 @@ public:
*/
void flush();
+ /**
+ * These flags can be used with the read/write pixels functions below.
+ */
+ enum PixelOpsFlags {
+ /** The GrContext will not be flushed before the surface read or write. This means that
+ the read or write may occur before previous draws have executed. */
+ kDontFlush_PixelOpsFlag = 0x1,
+ /** Any surface writes should be flushed to the backend 3D API after the surface operation
+ is complete */
+ kFlushWrites_PixelOp = 0x2,
+ /** The src for write or dst read is unpremultiplied. This is only respected if both the
+ config src and dst configs are an RGBA/BGRA 8888 format. */
+ kUnpremul_PixelOpsFlag = 0x4,
+ };
+
+ /**
+ * Reads a rectangle of pixels from a surface.
+ * @param surface the surface to read from.
+ * @param srcColorSpace color space of the surface
+ * @param left left edge of the rectangle to read (inclusive)
+ * @param top top edge of the rectangle to read (inclusive)
+ * @param width width of rectangle to read in pixels.
+ * @param height height of rectangle to read in pixels.
+ * @param config the pixel config of the destination buffer
+ * @param dstColorSpace color space of the destination buffer
+ * @param buffer memory to read the rectangle into.
+ * @param rowBytes number of bytes bewtween consecutive rows. Zero means rows are tightly
+ * packed.
+ * @param pixelOpsFlags see PixelOpsFlags enum above.
+ *
+ * @return true if the read succeeded, false if not. The read can fail because of an unsupported
+ * pixel configs
+ */
+ bool readSurfacePixels(GrSurface* surface, SkColorSpace* srcColorSpace,
+ int left, int top, int width, int height,
+ GrPixelConfig config, SkColorSpace* dstColorSpace, void* buffer,
+ size_t rowBytes = 0,
+ uint32_t pixelOpsFlags = 0);
+
+ /**
+ * Writes a rectangle of pixels to a surface.
+ * @param surface the surface to write to.
+ * @param dstColorSpace color space of the surface
+ * @param left left edge of the rectangle to write (inclusive)
+ * @param top top edge of the rectangle to write (inclusive)
+ * @param width width of rectangle to write in pixels.
+ * @param height height of rectangle to write in pixels.
+ * @param config the pixel config of the source buffer
+ * @param srcColorSpace color space of the source buffer
+ * @param buffer memory to read pixels from
+ * @param rowBytes number of bytes between consecutive rows. Zero
+ * means rows are tightly packed.
+ * @param pixelOpsFlags see PixelOpsFlags enum above.
+ * @return true if the write succeeded, false if not. The write can fail because of an
+ * unsupported combination of surface and src configs.
+ */
+ bool writeSurfacePixels(GrSurface* surface, SkColorSpace* dstColorSpace,
+ int left, int top, int width, int height,
+ GrPixelConfig config, SkColorSpace* srcColorSpace, const void* buffer,
+ size_t rowBytes,
+ uint32_t pixelOpsFlags = 0);
+
/**
* An ID associated with this context, guaranteed to be unique.
*/
diff --git a/include/gpu/GrProcessorUnitTest.h b/include/gpu/GrProcessorUnitTest.h
index d6269c85bd..912e393ca0 100644
--- a/include/gpu/GrProcessorUnitTest.h
+++ b/include/gpu/GrProcessorUnitTest.h
@@ -49,12 +49,12 @@ struct GrProcessorTestData {
GrProcessorTestData(SkRandom* random,
GrContext* context,
const GrRenderTargetContext* renderTargetContext,
- sk_sp<GrTextureProxy> proxies[2])
+ GrTexture* const textures[2])
: fRandom(random)
, fRenderTargetContext(renderTargetContext)
, fContext(context) {
- fProxies[0] = proxies[0];
- fProxies[1] = proxies[1];
+ fProxies[0] = GrSurfaceProxy::MakeWrapped(sk_ref_sp(textures[0]));
+ fProxies[1] = GrSurfaceProxy::MakeWrapped(sk_ref_sp(textures[1]));
}
SkRandom* fRandom;
const GrRenderTargetContext* fRenderTargetContext;
diff --git a/include/gpu/GrSurface.h b/include/gpu/GrSurface.h
index 81bc215c01..328731c38f 100644
--- a/include/gpu/GrSurface.h
+++ b/include/gpu/GrSurface.h
@@ -66,6 +66,106 @@ public:
virtual GrRenderTarget* asRenderTarget() { return NULL; }
virtual const GrRenderTarget* asRenderTarget() const { return NULL; }
+ /**
+ * Reads a rectangle of pixels from the surface, possibly performing color space conversion.
+ * @param srcColorSpace color space of the source data (this surface)
+ * @param left left edge of the rectangle to read (inclusive)
+ * @param top top edge of the rectangle to read (inclusive)
+ * @param width width of rectangle to read in pixels.
+ * @param height height of rectangle to read in pixels.
+ * @param config the pixel config of the destination buffer
+ * @param dstColorSpace color space of the destination buffer
+ * @param buffer memory to read the rectangle into.
+ * @param rowBytes number of bytes between consecutive rows. Zero means rows are tightly
+ * packed.
+ * @param pixelOpsFlags See the GrContext::PixelOpsFlags enum.
+ *
+ * @return true if the read succeeded, false if not. The read can fail because of an unsupported
+ * pixel config.
+ */
+ bool readPixels(SkColorSpace* srcColorSpace,
+ int left, int top, int width, int height,
+ GrPixelConfig config,
+ SkColorSpace* dstColorSpace,
+ void* buffer,
+ size_t rowBytes = 0,
+ uint32_t pixelOpsFlags = 0);
+
+ /**
+ * Reads a rectangle of pixels from the surface. Does not perform any color space conversion.
+ * @param left left edge of the rectangle to read (inclusive)
+ * @param top top edge of the rectangle to read (inclusive)
+ * @param width width of rectangle to read in pixels.
+ * @param height height of rectangle to read in pixels.
+ * @param config the pixel config of the destination buffer
+ * @param buffer memory to read the rectangle into.
+ * @param rowBytes number of bytes between consecutive rows. Zero means rows are tightly
+ * packed.
+ * @param pixelOpsFlags See the GrContext::PixelOpsFlags enum.
+ *
+ * @return true if the read succeeded, false if not. The read can fail because of an unsupported
+ * pixel config.
+ */
+ bool readPixels(int left, int top, int width, int height,
+ GrPixelConfig config,
+ void* buffer,
+ size_t rowBytes = 0,
+ uint32_t pixelOpsFlags = 0) {
+ return this->readPixels(nullptr, left, top, width, height, config, nullptr, buffer,
+ rowBytes, pixelOpsFlags);
+ }
+
+ /**
+ * Copy the src pixels [buffer, rowbytes, pixelconfig] into the surface at the specified
+ * rectangle, possibly performing color space conversion.
+ * @param dstColorSpace color space of the destination (this surface)
+ * @param left left edge of the rectangle to write (inclusive)
+ * @param top top edge of the rectangle to write (inclusive)
+ * @param width width of rectangle to write in pixels.
+ * @param height height of rectangle to write in pixels.
+ * @param config the pixel config of the source buffer
+ * @param srcColorSpace color space of the source buffer
+ * @param buffer memory to read the rectangle from.
+ * @param rowBytes number of bytes between consecutive rows. Zero means rows are tightly
+ * packed.
+ * @param pixelOpsFlags See the GrContext::PixelOpsFlags enum.
+ *
+ * @return true if the write succeeded, false if not. The write can fail because of an
+ * unsupported pixel config.
+ */
+ bool writePixels(SkColorSpace* dstColorSpace,
+ int left, int top, int width, int height,
+ GrPixelConfig config,
+ SkColorSpace* srcColorSpace,
+ const void* buffer,
+ size_t rowBytes = 0,
+ uint32_t pixelOpsFlags = 0);
+
+ /**
+ * Copy the src pixels [buffer, rowbytes, pixelconfig] into the surface at the specified
+ * rectangle. Does not perform any color space conversion.
+ * @param left left edge of the rectangle to write (inclusive)
+ * @param top top edge of the rectangle to write (inclusive)
+ * @param width width of rectangle to write in pixels.
+ * @param height height of rectangle to write in pixels.
+ * @param config the pixel config of the source buffer
+ * @param buffer memory to read the rectangle from.
+ * @param rowBytes number of bytes between consecutive rows. Zero means rows are tightly
+ * packed.
+ * @param pixelOpsFlags See the GrContext::PixelOpsFlags enum.
+ *
+ * @return true if the write succeeded, false if not. The write can fail because of an
+ * unsupported pixel config.
+ */
+ bool writePixels(int left, int top, int width, int height,
+ GrPixelConfig config,
+ const void* buffer,
+ size_t rowBytes = 0,
+ uint32_t pixelOpsFlags = 0) {
+ return this->writePixels(nullptr, left, top, width, height, config, nullptr, buffer,
+ rowBytes, pixelOpsFlags);
+ }
+
/** Access methods that are only to be used within Skia code. */
inline GrSurfacePriv surfacePriv();
inline const GrSurfacePriv surfacePriv() const;