aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrGpu.h
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2018-02-14 13:53:55 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-02-14 19:58:14 +0000
commit9b009bb069aa81425438d5403a1a29f2d047f77f (patch)
treea3ff6b83971d9c1564d1de84e219a187f703ed8b /src/gpu/GrGpu.h
parent95edb43251e8fcef4286c91d334c3259940a0095 (diff)
Prepare sRGB encoding conversion for the removal of GrPixelConfig
Standardizes that GrGpu subclass's onRead/WritePixels never do sRGB<->linear conversion. This means that they can eventually take a color type rather than config. It also means direct callers of GrGpu::read/writePixels can never expect conversion (which in practice is no change). Consolidate logic about whether to do sRGB<->linear encoding conversions in GrContext::read/writeSurfacePixels helpers. No change in when conversions are done (yet). This prepares this logic to operate on SkColorSpace and color type rather than config WRT the CPU data. Bug: skia:6718 Change-Id: I346d669624861578f1bb9ea465a7ab4b549117fa Reviewed-on: https://skia-review.googlesource.com/105286 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/gpu/GrGpu.h')
-rw-r--r--src/gpu/GrGpu.h56
1 files changed, 23 insertions, 33 deletions
diff --git a/src/gpu/GrGpu.h b/src/gpu/GrGpu.h
index baeb46ae75..87ddb76910 100644
--- a/src/gpu/GrGpu.h
+++ b/src/gpu/GrGpu.h
@@ -199,9 +199,9 @@ public:
* that would allow a successful readPixels call. The passed width, height, and rowBytes,
* must be non-zero and already reflect clipping to the src bounds.
*/
- bool getReadPixelsInfo(GrSurface* srcSurface, GrSurfaceOrigin srcOrigin,
- int readWidth, int readHeight, size_t rowBytes,
- GrPixelConfig readConfig, DrawPreference*, ReadPixelTempDrawInfo*);
+ bool getReadPixelsInfo(GrSurface*, GrSurfaceOrigin, int width,
+ int height, size_t rowBytes, GrPixelConfig,
+ GrSRGBConversion, DrawPreference*, ReadPixelTempDrawInfo*);
/** Info struct returned by getWritePixelsInfo about performing an intermediate draw in order
to write pixels to a GrSurface for either performance or correctness reasons. */
@@ -226,18 +226,19 @@ public:
* that would allow a successful transfer of the src pixels to the dst. The passed width,
* height, and rowBytes, must be non-zero and already reflect clipping to the dst bounds.
*/
- bool getWritePixelsInfo(GrSurface* dstSurface, GrSurfaceOrigin dstOrigin, int width, int height,
- GrPixelConfig srcConfig, DrawPreference*, WritePixelTempDrawInfo*);
+ bool getWritePixelsInfo(GrSurface*, GrSurfaceOrigin, int width, int height,
+ GrPixelConfig, GrSRGBConversion, DrawPreference*,
+ WritePixelTempDrawInfo*);
/**
- * Reads a rectangle of pixels from a render target.
+ * Reads a rectangle of pixels from a render target. No sRGB/linear conversions are performed.
*
* @param surface The surface to read from
* @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 dstConfig the pixel config of the destination buffer
* @param buffer memory to read the rectangle into.
* @param rowBytes the number of bytes between consecutive rows. Zero
* means rows are tightly packed.
@@ -248,39 +249,32 @@ public:
* because of a unsupported pixel config or because no render
* target is currently set.
*/
- bool readPixels(GrSurface* surface, GrSurfaceOrigin,
- int left, int top, int width, int height,
- GrPixelConfig config, void* buffer, size_t rowBytes);
+ bool readPixels(GrSurface* surface, GrSurfaceOrigin, int left, int top, int width, int height,
+ GrPixelConfig dstConfig, void* buffer, size_t rowBytes);
/**
- * Updates the pixels in a rectangle of a surface.
+ * Updates the pixels in a rectangle of a surface. No sRGB/linear conversions are performed.
*
* @param surface The surface to write to.
* @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 srcConfig the pixel config of the source buffer
* @param texels array of mipmap levels containing texture data
* @param mipLevelCount number of levels in 'texels'
*/
bool writePixels(GrSurface* surface, GrSurfaceOrigin origin,
int left, int top, int width, int height,
- GrPixelConfig config,
+ GrPixelConfig srcConfig,
const GrMipLevel texels[], int mipLevelCount);
/**
* This function is a shim which creates a SkTArray<GrMipLevel> of size 1.
* It then calls writePixels with that SkTArray.
- *
- * @param buffer memory to read pixels from.
- * @param rowBytes number of bytes between consecutive rows. Zero
- * means rows are tightly packed.
*/
- bool writePixels(GrSurface* surface, GrSurfaceOrigin origin,
- int left, int top, int width, int height,
- GrPixelConfig config, const void* buffer,
- size_t rowBytes);
+ bool writePixels(GrSurface*, GrSurfaceOrigin, int left, int top, int width,
+ int height, GrPixelConfig, const void* buffer, size_t rowBytes);
/**
* Updates the pixels in a rectangle of a texture using a buffer
@@ -293,16 +287,15 @@ public:
* @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 bufferConfig the pixel config of the source buffer
* @param transferBuffer GrBuffer to read pixels from (type must be "kXferCpuToGpu")
* @param offset offset from the start of the buffer
* @param rowBytes number of bytes between consecutive rows in the buffer. Zero
* means rows are tightly packed.
*/
- bool transferPixels(GrTexture* texture,
- int left, int top, int width, int height,
- GrPixelConfig config, GrBuffer* transferBuffer,
- size_t offset, size_t rowBytes);
+ bool transferPixels(GrTexture* texture, int left, int top, int width, int height,
+ GrPixelConfig bufferConfig, GrBuffer* transferBuffer, size_t offset,
+ size_t rowBytes);
// After the client interacts directly with the 3D context state the GrGpu
// must resync its internal state and assumptions about 3D context state.
@@ -567,14 +560,11 @@ private:
return false;
}
- virtual bool onGetReadPixelsInfo(GrSurface* srcSurface, GrSurfaceOrigin srcOrigin,
- int readWidth, int readHeight,
- size_t rowBytes, GrPixelConfig readConfig, DrawPreference*,
+ virtual bool onGetReadPixelsInfo(GrSurface*, GrSurfaceOrigin, int width, int height,
+ size_t rowBytes, GrPixelConfig, DrawPreference*,
ReadPixelTempDrawInfo*) = 0;
- virtual bool onGetWritePixelsInfo(GrSurface* dstSurface, GrSurfaceOrigin dstOrigin,
- int width, int height,
- GrPixelConfig srcConfig, DrawPreference*,
- WritePixelTempDrawInfo*) = 0;
+ virtual bool onGetWritePixelsInfo(GrSurface*, GrSurfaceOrigin, int width, int height,
+ GrPixelConfig, DrawPreference*, WritePixelTempDrawInfo*) = 0;
// overridden by backend-specific derived class to perform the surface read
virtual bool onReadPixels(GrSurface*, GrSurfaceOrigin,