aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorGravatar bsalomon <bsalomon@google.com>2014-10-07 05:56:02 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-10-07 05:56:02 -0700
commitf80bfedc42fde88ae3f8dbd7b21950a22258fd22 (patch)
tree53f8fa79d21b8d3a352b1d31a227f6fe80754585 /include
parentb9ab5631703c258f1aae7a3ca1bb4b6596b5b42c (diff)
GrContext::copyTexture->GrContext::copySurface.
Add a flush writes pixel ops flag. Add an explicit flush writes for GrSurface. BUG=skia:2977 Committed: https://skia.googlesource.com/skia/+/cf99b00980b6c9c557e71abf1a7c9f9b21217262 Review URL: https://codereview.chromium.org/622663002
Diffstat (limited to 'include')
-rw-r--r--include/gpu/GrContext.h44
-rw-r--r--include/gpu/GrSurface.h5
2 files changed, 39 insertions, 10 deletions
diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h
index 366fba993e..4500936b82 100644
--- a/include/gpu/GrContext.h
+++ b/include/gpu/GrContext.h
@@ -597,12 +597,15 @@ public:
* These flags can be used with the read/write pixels functions below.
*/
enum PixelOpsFlags {
- /** The GrContext will not be flushed. This means that the read or write may occur before
- previous draws have executed. */
+ /** 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 = 0x2,
+ kUnpremul_PixelOpsFlag = 0x4,
};
/**
@@ -695,15 +698,36 @@ public:
uint32_t pixelOpsFlags = 0);
/**
- * Copies a rectangle of texels from src to dst. The size of dst is the size of the rectangle
- * copied and topLeft is the position of the rect in src. The rectangle is clipped to src's
+ * Copies a rectangle of texels from src to dst.
* bounds.
- * @param src the texture to copy from.
- * @param dst the render target to copy to.
- * @param topLeft the point in src that will be copied to the top-left of dst. If NULL,
- * (0, 0) will be used.
+ * @param dst the surface to copy to.
+ * @param src the surface to copy from.
+ * @param srcRect the rectangle of the src that should be copied.
+ * @param dstPoint the translation applied when writing the srcRect's pixels to the dst.
+ * @param pixelOpsFlags see PixelOpsFlags enum above. (kUnpremul_PixelOpsFlag is not allowed).
*/
- void copyTexture(GrTexture* src, GrRenderTarget* dst, const SkIPoint* topLeft = NULL);
+ void copySurface(GrSurface* dst,
+ GrSurface* src,
+ const SkIRect& srcRect,
+ const SkIPoint& dstPoint,
+ uint32_t pixelOpsFlags = 0);
+
+ /** Helper that copies the whole surface but fails when the two surfaces are not identically
+ sized. */
+ bool copySurface(GrSurface* dst, GrSurface* src) {
+ if (NULL == dst || NULL == src || dst->width() != src->width() ||
+ dst->height() != src->height()) {
+ return false;
+ }
+ this->copySurface(dst, src, SkIRect::MakeWH(dst->width(), dst->height()),
+ SkIPoint::Make(0,0));
+ return true;
+ }
+
+ /**
+ * After this returns any pending writes to the surface will have been issued to the backend 3D API.
+ */
+ void flushSurfaceWrites(GrSurface* surface);
/**
* Resolves a render target that has MSAA. The intermediate MSAA buffer is
diff --git a/include/gpu/GrSurface.h b/include/gpu/GrSurface.h
index 23311a2f52..0bbf8d9c12 100644
--- a/include/gpu/GrSurface.h
+++ b/include/gpu/GrSurface.h
@@ -112,6 +112,11 @@ public:
size_t rowBytes = 0,
uint32_t pixelOpsFlags = 0) = 0;
+ /**
+ * After this returns any pending writes to the surface will be issued to the backend 3D API.
+ */
+ void flushWrites();
+
/** Access methods that are only to be used within Skia code. */
inline GrSurfacePriv surfacePriv();
inline const GrSurfacePriv surfacePriv() const;