aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/gl/GrGLGpu.cpp
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2018-06-01 14:13:43 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-06-01 18:59:16 +0000
commitd494f6e3d68269d1a60e864561aa66a7b125be1a (patch)
tree21541972d90da1252afd765d932020be1dd17a8e /src/gpu/gl/GrGLGpu.cpp
parentee56b834fcd5e1834772d8e60195a21811833267 (diff)
Replace GrContextPriv::read/writeSurfacePixels with GrContextPriv::read/WritePixels2
Change-Id: I08be0f347d360e97bf9a6d1aeb25f9f584cc3d89 Reviewed-on: https://skia-review.googlesource.com/131442 Commit-Queue: Brian Salomon <bsalomon@google.com> Commit-Queue: Brian Osman <brianosman@google.com> Auto-Submit: Brian Salomon <bsalomon@google.com> Reviewed-by: Brian Osman <brianosman@google.com>
Diffstat (limited to 'src/gpu/gl/GrGLGpu.cpp')
-rw-r--r--src/gpu/gl/GrGLGpu.cpp132
1 files changed, 0 insertions, 132 deletions
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index 3c4b1e8bca..f73a3138af 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -2069,32 +2069,6 @@ void GrGLGpu::clearStencilClip(const GrFixedClip& clip,
fHWStencilSettings.invalidate();
}
-static bool read_pixels_pays_for_y_flip(GrSurfaceOrigin origin, const GrGLCaps& caps,
- int width, int height, GrPixelConfig config,
- size_t rowBytes) {
- // If the surface is already TopLeft, we don't need to flip.
- if (kTopLeft_GrSurfaceOrigin == origin) {
- return false;
- }
-
- // If the read is really small or smaller than the min texture size, don't force a draw.
- static const int kMinSize = 32;
- if (width < kMinSize || height < kMinSize) {
- return false;
- }
-
- // if GL can do the flip then we'll never pay for it.
- if (caps.packFlipYSupport()) {
- return false;
- }
-
- // If we have to do memcpy to handle non-trim rowBytes then we
- // get the flip for free. Otherwise it costs.
- // Note that we're assuming that 0 rowBytes has already been handled and that the width has been
- // clipped.
- return caps.packRowLengthSupport() || GrBytesPerPixel(config) * width == rowBytes;
-}
-
bool GrGLGpu::readPixelsSupported(GrRenderTarget* target, GrPixelConfig readConfig) {
#ifdef SK_BUILD_FOR_MAC
// Chromium may ask us to read back from locked IOSurfaces. Calling the command buffer's
@@ -2165,112 +2139,6 @@ bool GrGLGpu::readPixelsSupported(GrSurface* surfaceForConfig, GrPixelConfig rea
}
}
-bool GrGLGpu::onGetReadPixelsInfo(GrSurface* srcSurface, GrSurfaceOrigin srcOrigin, int width,
- int height, size_t rowBytes, GrColorType dstColorType,
- DrawPreference* drawPreference,
- ReadPixelTempDrawInfo* tempDrawInfo) {
- // We don't want to introduce a sRGB conversion if we trigger a draw.
- auto dstConfigSRGBEncoded = GrPixelConfigIsSRGBEncoded(srcSurface->config());
- if (*drawPreference != kNoDraw_DrawPreference) {
- // We assume the base class has only inserted a draw for sRGB reasons. So the
- // the temp surface has the config of the dst data. There is no swizzling, nor dst config
- // spoofing.
- SkASSERT(tempDrawInfo->fReadColorType == dstColorType);
- SkASSERT(GrPixelConfigToColorType(tempDrawInfo->fTempSurfaceDesc.fConfig) == dstColorType);
- SkASSERT(tempDrawInfo->fSwizzle == GrSwizzle::RGBA());
- // Don't undo a sRGB conversion introduced by our caller via an intermediate draw.
- dstConfigSRGBEncoded = GrPixelConfigIsSRGBEncoded(tempDrawInfo->fTempSurfaceDesc.fConfig);
- }
- if (GrColorTypeIsAlphaOnly(dstColorType)) {
- dstConfigSRGBEncoded = GrSRGBEncoded::kNo;
- }
- GrPixelConfig srcConfig = srcSurface->config();
-
- tempDrawInfo->fTempSurfaceFit = this->glCaps().partialFBOReadIsSlow() ? SkBackingFit::kExact
- : SkBackingFit::kApprox;
-
- // TODO: Update this logic to use color type.
- auto dstAsConfig = GrColorTypeToPixelConfig(dstColorType, dstConfigSRGBEncoded);
-
- if (this->glCaps().rgba8888PixelsOpsAreSlow() && kRGBA_8888_GrPixelConfig == dstAsConfig &&
- this->readPixelsSupported(kBGRA_8888_GrPixelConfig, kBGRA_8888_GrPixelConfig)) {
- tempDrawInfo->fTempSurfaceDesc.fConfig = kBGRA_8888_GrPixelConfig;
- tempDrawInfo->fSwizzle = GrSwizzle::BGRA();
- tempDrawInfo->fReadColorType = GrColorType::kBGRA_8888;
- ElevateDrawPreference(drawPreference, kGpuPrefersDraw_DrawPreference);
- } else if (this->glCaps().rgbaToBgraReadbackConversionsAreSlow() &&
- GrBytesPerPixel(dstAsConfig) == 4 &&
- GrPixelConfigSwapRAndB(dstAsConfig) == srcConfig &&
- this->readPixelsSupported(srcSurface, srcConfig)) {
- // Mesa 3D takes a slow path on when reading back BGRA from an RGBA surface and vice-versa.
- // Better to do a draw with a R/B swap and then read as the original config.
- tempDrawInfo->fTempSurfaceDesc.fConfig = srcConfig;
- tempDrawInfo->fSwizzle = GrSwizzle::BGRA();
- tempDrawInfo->fReadColorType = GrPixelConfigToColorType(srcConfig);
- ElevateDrawPreference(drawPreference, kGpuPrefersDraw_DrawPreference);
- } else if (!this->readPixelsSupported(srcSurface, dstAsConfig)) {
- if (kBGRA_8888_GrPixelConfig == dstAsConfig &&
- this->glCaps().canConfigBeFBOColorAttachment(kRGBA_8888_GrPixelConfig) &&
- this->readPixelsSupported(kRGBA_8888_GrPixelConfig, kRGBA_8888_GrPixelConfig)) {
- // We're trying to read BGRA but it's not supported. If RGBA is renderable and
- // we can read it back, then do a swizzling draw to a RGBA and read it back (which
- // will effectively be BGRA).
- tempDrawInfo->fTempSurfaceDesc.fConfig = kRGBA_8888_GrPixelConfig;
- tempDrawInfo->fSwizzle = GrSwizzle::BGRA();
- tempDrawInfo->fReadColorType = GrColorType::kRGBA_8888;
- ElevateDrawPreference(drawPreference, kRequireDraw_DrawPreference);
- } else if (kSBGRA_8888_GrPixelConfig == dstAsConfig &&
- this->glCaps().canConfigBeFBOColorAttachment(kSRGBA_8888_GrPixelConfig) &&
- this->readPixelsSupported(kSRGBA_8888_GrPixelConfig,
- kSRGBA_8888_GrPixelConfig)) {
- // We're trying to read sBGRA but it's not supported. If sRGBA is renderable and
- // we can read it back, then do a swizzling draw to a sRGBA and read it back (which
- // will effectively be sBGRA).
- tempDrawInfo->fTempSurfaceDesc.fConfig = kSRGBA_8888_GrPixelConfig;
- tempDrawInfo->fSwizzle = GrSwizzle::BGRA();
- tempDrawInfo->fReadColorType = GrColorType::kRGBA_8888;
- ElevateDrawPreference(drawPreference, kRequireDraw_DrawPreference);
- } else if (kAlpha_8_GrPixelConfig == dstAsConfig) {
- // onReadPixels implements a fallback for cases where we want to read kAlpha_8,
- // it's unsupported, but 32bit RGBA reads are supported.
- if (!this->readPixelsSupported(srcSurface, kRGBA_8888_GrPixelConfig)) {
- // If we can't read RGBA from the src try to draw to a kRGBA_8888 (or kSRGBA_8888)
- // first and then onReadPixels will read that to a 32bit temporary buffer.
- if (this->glCaps().canConfigBeFBOColorAttachment(kRGBA_8888_GrPixelConfig)) {
- ElevateDrawPreference(drawPreference, kRequireDraw_DrawPreference);
- tempDrawInfo->fTempSurfaceDesc.fConfig = kRGBA_8888_GrPixelConfig;
- tempDrawInfo->fReadColorType = GrColorType::kAlpha_8;
- } else {
- return false;
- }
- } else {
- tempDrawInfo->fTempSurfaceDesc.fConfig = srcConfig;
- SkASSERT(tempDrawInfo->fReadColorType == GrColorType::kAlpha_8);
- }
- } else if (kRGBA_half_GrPixelConfig == dstAsConfig &&
- this->readPixelsSupported(srcSurface, kRGBA_float_GrPixelConfig)) {
- // If reading in half float format is not supported, then read in float format.
- return true;
- } else if (this->glCaps().canConfigBeFBOColorAttachment(dstAsConfig) &&
- this->readPixelsSupported(dstAsConfig, dstAsConfig)) {
- // Do a draw to convert from the src config to the read config.
- ElevateDrawPreference(drawPreference, kRequireDraw_DrawPreference);
- tempDrawInfo->fTempSurfaceDesc.fConfig = dstAsConfig;
- tempDrawInfo->fReadColorType = dstColorType;
- } else {
- return false;
- }
- }
-
- if ((srcSurface->asRenderTarget() || this->glCaps().canConfigBeFBOColorAttachment(srcConfig)) &&
- read_pixels_pays_for_y_flip(srcOrigin, this->glCaps(), width, height, dstAsConfig,
- rowBytes)) {
- ElevateDrawPreference(drawPreference, kGpuPrefersDraw_DrawPreference);
- }
-
- return true;
-}
-
bool GrGLGpu::onReadPixels(GrSurface* surface, GrSurfaceOrigin origin, int left, int top, int width,
int height, GrColorType dstColorType, void* buffer, size_t rowBytes) {
SkASSERT(surface);