aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2018-02-09 14:18:24 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-02-10 01:15:31 +0000
commitdfb3a169605dc340658070fbeb3c5490c7f3ded6 (patch)
tree399203c4fbf6476a1a4cd39173a7492229237dc5 /src
parent1617899b677050d3db63c3770c406e16501f356c (diff)
Move default init of tmp draw params out of subclasses into GrGpu
I want to move srgb conversion logic to GrGpu from subclasses and I think it will make more sense if the temp draw info is fully initialized before invoking the subclass. Change-Id: Icfc4d564fc0d3c7c12f78c77f5ea921d979e290d Reviewed-on: https://skia-review.googlesource.com/106260 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src')
-rw-r--r--src/gpu/GrGpu.cpp23
-rw-r--r--src/gpu/gl/GrGLGpu.cpp28
-rw-r--r--src/gpu/vk/GrVkGpu.cpp31
3 files changed, 23 insertions, 59 deletions
diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp
index ea13c851ad..afe9cd813f 100644
--- a/src/gpu/GrGpu.cpp
+++ b/src/gpu/GrGpu.cpp
@@ -202,6 +202,18 @@ bool GrGpu::getReadPixelsInfo(GrSurface* srcSurface, GrSurfaceOrigin srcOrigin,
SkASSERT(srcSurface);
SkASSERT(kGpuPrefersDraw_DrawPreference != *drawPreference);
+ // Default values for intermediate draws. The intermediate texture config matches the src's
+ // config, is approx sized to the read rect, no swizzling or spoofing of the dst config.
+ tempDrawInfo->fTempSurfaceDesc.fFlags = kRenderTarget_GrSurfaceFlag;
+ tempDrawInfo->fTempSurfaceDesc.fWidth = width;
+ tempDrawInfo->fTempSurfaceDesc.fHeight = height;
+ tempDrawInfo->fTempSurfaceDesc.fSampleCnt = 1;
+ tempDrawInfo->fTempSurfaceDesc.fOrigin = kTopLeft_GrSurfaceOrigin; // no CPU y-flip for TL.
+ tempDrawInfo->fTempSurfaceDesc.fConfig = srcSurface->config();
+ tempDrawInfo->fTempSurfaceFit = SkBackingFit::kApprox;
+ tempDrawInfo->fSwizzle = GrSwizzle::RGBA();
+ tempDrawInfo->fReadConfig = readConfig;
+
// We currently do not support reading into the packed formats 565 or 4444 as they are not
// required to have read back support on all devices and backends.
if (kRGB_565_GrPixelConfig == readConfig || kRGBA_4444_GrPixelConfig == readConfig) {
@@ -234,6 +246,17 @@ bool GrGpu::getWritePixelsInfo(GrSurface* dstSurface, GrSurfaceOrigin dstOrigin,
SkASSERT(dstSurface);
SkASSERT(kGpuPrefersDraw_DrawPreference != *drawPreference);
+ // Default values for intermediate draws. The intermediate texture config matches the dst's
+ // config, is approx sized to the write rect, no swizzling or sppofing of the src config.
+ tempDrawInfo->fTempSurfaceDesc.fFlags = kNone_GrSurfaceFlags;
+ tempDrawInfo->fTempSurfaceDesc.fConfig = srcConfig;
+ tempDrawInfo->fTempSurfaceDesc.fWidth = width;
+ tempDrawInfo->fTempSurfaceDesc.fHeight = height;
+ tempDrawInfo->fTempSurfaceDesc.fSampleCnt = 1;
+ tempDrawInfo->fTempSurfaceDesc.fOrigin = kTopLeft_GrSurfaceOrigin; // no CPU y-flip for TL.
+ tempDrawInfo->fSwizzle = GrSwizzle::RGBA();
+ tempDrawInfo->fWriteConfig = srcConfig;
+
if (!this->onGetWritePixelsInfo(dstSurface, dstOrigin, width, height, srcConfig, drawPreference,
tempDrawInfo)) {
return false;
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index 1eb2c1de95..6563215acd 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -698,19 +698,6 @@ bool GrGLGpu::onGetWritePixelsInfo(GrSurface* dstSurface, GrSurfaceOrigin dstOri
ElevateDrawPreference(drawPreference, kRequireDraw_DrawPreference);
}
- // Start off assuming no swizzling
- tempDrawInfo->fSwizzle = GrSwizzle::RGBA();
- tempDrawInfo->fWriteConfig = srcConfig;
-
- // These settings we will always want if a temp draw is performed. Initially set the config
- // to srcConfig, though that may be modified if we decide to do a R/G swap.
- tempDrawInfo->fTempSurfaceDesc.fFlags = kNone_GrSurfaceFlags;
- tempDrawInfo->fTempSurfaceDesc.fConfig = srcConfig;
- tempDrawInfo->fTempSurfaceDesc.fWidth = width;
- tempDrawInfo->fTempSurfaceDesc.fHeight = height;
- tempDrawInfo->fTempSurfaceDesc.fSampleCnt = 1;
- tempDrawInfo->fTempSurfaceDesc.fOrigin = kTopLeft_GrSurfaceOrigin; // no CPU y-flip for TL.
-
bool configsAreRBSwaps = GrPixelConfigSwapRAndB(srcConfig) == dstSurface->config();
if (configsAreRBSwaps) {
@@ -2191,23 +2178,8 @@ bool GrGLGpu::onGetReadPixelsInfo(GrSurface* srcSurface, GrSurfaceOrigin srcOrig
ReadPixelTempDrawInfo* tempDrawInfo) {
GrPixelConfig srcConfig = srcSurface->config();
- // These settings we will always want if a temp draw is performed.
- tempDrawInfo->fTempSurfaceDesc.fFlags = kRenderTarget_GrSurfaceFlag;
- tempDrawInfo->fTempSurfaceDesc.fWidth = width;
- tempDrawInfo->fTempSurfaceDesc.fHeight = height;
- tempDrawInfo->fTempSurfaceDesc.fSampleCnt = 1;
- tempDrawInfo->fTempSurfaceDesc.fOrigin = kTopLeft_GrSurfaceOrigin; // no CPU y-flip for TL.
tempDrawInfo->fTempSurfaceFit = this->glCaps().partialFBOReadIsSlow() ? SkBackingFit::kExact
: SkBackingFit::kApprox;
- // For now assume no swizzling, we may change that below.
- tempDrawInfo->fSwizzle = GrSwizzle::RGBA();
-
- // Depends on why we need/want a temp draw. Start off assuming no change, the surface we read
- // from will be srcConfig and we will read readConfig pixels from it.
- // Note that if we require a draw and return a non-renderable format for the temp surface the
- // base class will fail for us.
- tempDrawInfo->fTempSurfaceDesc.fConfig = srcConfig;
- tempDrawInfo->fReadConfig = readConfig;
if (requires_srgb_conversion(srcConfig, readConfig)) {
if (!this->readPixelsSupported(readConfig, readConfig)) {
diff --git a/src/gpu/vk/GrVkGpu.cpp b/src/gpu/vk/GrVkGpu.cpp
index 9d95c211f5..35c2fcc815 100644
--- a/src/gpu/vk/GrVkGpu.cpp
+++ b/src/gpu/vk/GrVkGpu.cpp
@@ -342,19 +342,6 @@ bool GrVkGpu::onGetWritePixelsInfo(GrSurface* dstSurface, GrSurfaceOrigin dstOri
WritePixelTempDrawInfo* tempDrawInfo) {
GrRenderTarget* renderTarget = dstSurface->asRenderTarget();
- // Start off assuming no swizzling
- tempDrawInfo->fSwizzle = GrSwizzle::RGBA();
- tempDrawInfo->fWriteConfig = srcConfig;
-
- // These settings we will always want if a temp draw is performed. Initially set the config
- // to srcConfig, though that may be modified if we decide to do a R/B swap
- tempDrawInfo->fTempSurfaceDesc.fFlags = kNone_GrSurfaceFlags;
- tempDrawInfo->fTempSurfaceDesc.fConfig = srcConfig;
- tempDrawInfo->fTempSurfaceDesc.fWidth = width;
- tempDrawInfo->fTempSurfaceDesc.fHeight = height;
- tempDrawInfo->fTempSurfaceDesc.fSampleCnt = 1;
- tempDrawInfo->fTempSurfaceDesc.fOrigin = kTopLeft_GrSurfaceOrigin;
-
if (dstSurface->config() == srcConfig) {
// We only support writing pixels to textures. Forcing a draw lets us write to pure RTs.
if (!dstSurface->asTexture()) {
@@ -1876,24 +1863,6 @@ bool GrVkGpu::onGetReadPixelsInfo(GrSurface* srcSurface, GrSurfaceOrigin srcOrig
int width, int height, size_t rowBytes,
GrPixelConfig readConfig, DrawPreference* drawPreference,
ReadPixelTempDrawInfo* tempDrawInfo) {
- // These settings we will always want if a temp draw is performed.
- tempDrawInfo->fTempSurfaceDesc.fFlags = kRenderTarget_GrSurfaceFlag;
- tempDrawInfo->fTempSurfaceDesc.fWidth = width;
- tempDrawInfo->fTempSurfaceDesc.fHeight = height;
- tempDrawInfo->fTempSurfaceDesc.fSampleCnt = 1;
- tempDrawInfo->fTempSurfaceDesc.fOrigin = kTopLeft_GrSurfaceOrigin; // no CPU y-flip for TL.
- tempDrawInfo->fTempSurfaceFit = SkBackingFit::kApprox;
-
- // For now assume no swizzling, we may change that below.
- tempDrawInfo->fSwizzle = GrSwizzle::RGBA();
-
- // Depends on why we need/want a temp draw. Start off assuming no change, the surface we read
- // from will be srcConfig and we will read readConfig pixels from it.
- // Note that if we require a draw and return a non-renderable format for the temp surface the
- // base class will fail for us.
- tempDrawInfo->fTempSurfaceDesc.fConfig = srcSurface->config();
- tempDrawInfo->fReadConfig = readConfig;
-
if (srcSurface->config() == readConfig) {
return true;
}