aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2017-07-27 16:16:25 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-07-27 22:16:06 +0000
commit16d8ec66cdce2f30ce89b87066d3ac7a244c460d (patch)
treec1428954ad363f7e2b6ce13bbb1640911c7a8262 /src
parent713195071dc7bdeddec2d1c9fab9b3720f049f07 (diff)
Pull non-substantive changes out of omnibus GrSurface CL
https://skia-review.googlesource.com/c/26363 (Remove origin field from GrSurface) is already too large. This pulls some of the cosmetic changes out for separate review. Change-Id: I1d8b95522144b2f4cbd916ef38faa3dde6f78087 Reviewed-on: https://skia-review.googlesource.com/27840 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src')
-rw-r--r--src/gpu/GrBackendTextureImageGenerator.cpp6
-rw-r--r--src/gpu/GrContext.cpp26
-rw-r--r--src/gpu/GrDrawOpAtlas.cpp1
-rw-r--r--src/gpu/GrGpu.h7
-rw-r--r--src/gpu/GrRenderTargetContext.cpp6
-rw-r--r--src/gpu/GrSurfaceProxy.cpp16
-rw-r--r--src/gpu/gl/GrGLGpu.cpp39
-rw-r--r--src/gpu/glsl/GrGLSLProgramBuilder.cpp2
-rw-r--r--src/gpu/vk/GrVkGpu.cpp12
-rw-r--r--src/image/SkImage_Gpu.cpp8
10 files changed, 52 insertions, 71 deletions
diff --git a/src/gpu/GrBackendTextureImageGenerator.cpp b/src/gpu/GrBackendTextureImageGenerator.cpp
index 3de6fec85c..ac4fee37ac 100644
--- a/src/gpu/GrBackendTextureImageGenerator.cpp
+++ b/src/gpu/GrBackendTextureImageGenerator.cpp
@@ -175,12 +175,12 @@ sk_sp<GrTextureProxy> GrBackendTextureImageGenerator::onGenerateTexture(
// Otherwise, make a copy of the requested subset. Make sure our temporary is renderable,
// because Vulkan will want to do the copy as a draw.
GrSurfaceDesc desc;
- desc.fConfig = proxy->config();
+ desc.fFlags = kRenderTarget_GrSurfaceFlag;
+ desc.fOrigin = proxy->origin();
desc.fWidth = info.width();
desc.fHeight = info.height();
- desc.fOrigin = proxy->origin();
+ desc.fConfig = proxy->config();
desc.fIsMipMapped = proxy->isMipMapped();
- desc.fFlags = kRenderTarget_GrSurfaceFlag;
sk_sp<GrSurfaceContext> sContext(context->contextPriv().makeDeferredSurfaceContext(
desc, SkBackingFit::kExact, SkBudgeted::kYes));
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 25408fbde7..347f0b5153 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -401,11 +401,12 @@ bool GrContextPriv::writeSurfacePixels(GrSurfaceContext* dst,
return false;
}
- GrSurface* dstSurface = dst->asSurfaceProxy()->priv().peekSurface();
+ GrSurfaceProxy* dstProxy = dst->asSurfaceProxy();
+ GrSurface* dstSurface = dstProxy->priv().peekSurface();
// The src is unpremul but the dst is premul -> premul the src before or as part of the write
const bool premul = SkToBool(kUnpremul_PixelOpsFlag & pixelOpsFlags);
- if (!valid_pixel_conversion(srcConfig, dstSurface->config(), premul)) {
+ if (!valid_pixel_conversion(srcConfig, dstProxy->config(), premul)) {
return false;
}
@@ -414,7 +415,7 @@ bool GrContextPriv::writeSurfacePixels(GrSurfaceContext* dst,
bool useConfigConversionEffect =
premul &&
pm_upm_must_round_trip(srcConfig, srcColorSpace) &&
- pm_upm_must_round_trip(dstSurface->config(), dst->getColorSpace());
+ pm_upm_must_round_trip(dstProxy->config(), dst->getColorSpace());
// Are we going to try to premul as part of a draw? For the non-legacy case, we always allow
// this. GrConfigConversionEffect fails on some GPUs, so only allow this if it works perfectly.
@@ -432,8 +433,8 @@ bool GrContextPriv::writeSurfacePixels(GrSurfaceContext* dst,
GrGpu::DrawPreference drawPreference = premulOnGpu ? GrGpu::kCallerPrefersDraw_DrawPreference
: GrGpu::kNoDraw_DrawPreference;
GrGpu::WritePixelTempDrawInfo tempDrawInfo;
- if (!fContext->fGpu->getWritePixelsInfo(dstSurface, width, height, srcConfig,
- &drawPreference, &tempDrawInfo)) {
+ if (!fContext->fGpu->getWritePixelsInfo(dstSurface, width, height,
+ srcConfig, &drawPreference, &tempDrawInfo)) {
return false;
}
@@ -531,11 +532,12 @@ bool GrContextPriv::readSurfacePixels(GrSurfaceContext* src,
return false;
}
- GrSurface* srcSurface = src->asSurfaceProxy()->priv().peekSurface();
+ GrSurfaceProxy* srcProxy = src->asSurfaceProxy();
+ GrSurface* srcSurface = srcProxy->priv().peekSurface();
// The src is premul but the dst is unpremul -> unpremul the src after or as part of the read
bool unpremul = SkToBool(kUnpremul_PixelOpsFlag & flags);
- if (!valid_pixel_conversion(srcSurface->config(), dstConfig, unpremul)) {
+ if (!valid_pixel_conversion(srcProxy->config(), dstConfig, unpremul)) {
return false;
}
@@ -543,7 +545,7 @@ bool GrContextPriv::readSurfacePixels(GrSurfaceContext* src,
// without any color spaces attached, and the caller wants us to unpremul.
bool useConfigConversionEffect =
unpremul &&
- pm_upm_must_round_trip(srcSurface->config(), src->getColorSpace()) &&
+ pm_upm_must_round_trip(srcProxy->config(), src->getColorSpace()) &&
pm_upm_must_round_trip(dstConfig, dstColorSpace);
// Are we going to try to unpremul as part of a draw? For the non-legacy case, we always allow
@@ -562,8 +564,8 @@ bool GrContextPriv::readSurfacePixels(GrSurfaceContext* src,
GrGpu::DrawPreference drawPreference = unpremulOnGpu ? GrGpu::kCallerPrefersDraw_DrawPreference
: GrGpu::kNoDraw_DrawPreference;
GrGpu::ReadPixelTempDrawInfo tempDrawInfo;
- if (!fContext->fGpu->getReadPixelsInfo(srcSurface, width, height, rowBytes, dstConfig,
- &drawPreference, &tempDrawInfo)) {
+ if (!fContext->fGpu->getReadPixelsInfo(srcSurface, width, height, rowBytes,
+ dstConfig, &drawPreference, &tempDrawInfo)) {
return false;
}
@@ -639,8 +641,8 @@ bool GrContextPriv::readSurfacePixels(GrSurfaceContext* src,
this->flushSurfaceWrites(proxyToRead.get());
configToRead = tempDrawInfo.fReadConfig;
}
- if (!fContext->fGpu->readPixels(surfaceToRead, left, top, width, height, configToRead,
- buffer, rowBytes)) {
+ if (!fContext->fGpu->readPixels(surfaceToRead,
+ left, top, width, height, configToRead, buffer, rowBytes)) {
return false;
}
diff --git a/src/gpu/GrDrawOpAtlas.cpp b/src/gpu/GrDrawOpAtlas.cpp
index 8bc0521ccc..897622ac28 100644
--- a/src/gpu/GrDrawOpAtlas.cpp
+++ b/src/gpu/GrDrawOpAtlas.cpp
@@ -21,6 +21,7 @@ std::unique_ptr<GrDrawOpAtlas> GrDrawOpAtlas::Make(GrContext* ctx, GrPixelConfig
void* data) {
GrSurfaceDesc desc;
desc.fFlags = kNone_GrSurfaceFlags;
+ desc.fOrigin = kTopLeft_GrSurfaceOrigin;
desc.fWidth = width;
desc.fHeight = height;
desc.fConfig = config;
diff --git a/src/gpu/GrGpu.h b/src/gpu/GrGpu.h
index c6684ac4fa..27a2d7958e 100644
--- a/src/gpu/GrGpu.h
+++ b/src/gpu/GrGpu.h
@@ -107,13 +107,13 @@ public:
* @param mipLevelCount the number of levels in 'texels'
* @return The texture object if successful, otherwise nullptr.
*/
- sk_sp<GrTexture> createTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted,
+ sk_sp<GrTexture> createTexture(const GrSurfaceDesc&, SkBudgeted,
const GrMipLevel texels[], int mipLevelCount);
/**
* Simplified createTexture() interface for when there is no initial texel data to upload.
*/
- sk_sp<GrTexture> createTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted);
+ sk_sp<GrTexture> createTexture(const GrSurfaceDesc& desc, SkBudgeted);
/**
* Implements GrResourceProvider::wrapBackendTexture
@@ -544,8 +544,7 @@ private:
// overridden by backend-specific derived class to create objects.
// Texture size and sample size will have already been validated in base class before
// onCreateTexture is called.
- virtual sk_sp<GrTexture> onCreateTexture(const GrSurfaceDesc& desc,
- SkBudgeted budgeted,
+ virtual sk_sp<GrTexture> onCreateTexture(const GrSurfaceDesc&, SkBudgeted,
const GrMipLevel texels[],
int mipLevelCount) = 0;
diff --git a/src/gpu/GrRenderTargetContext.cpp b/src/gpu/GrRenderTargetContext.cpp
index c9898c7480..4ec14bccf6 100644
--- a/src/gpu/GrRenderTargetContext.cpp
+++ b/src/gpu/GrRenderTargetContext.cpp
@@ -1806,8 +1806,8 @@ uint32_t GrRenderTargetContext::addDrawOp(const GrClip& clip, std::unique_ptr<Gr
}
bool GrRenderTargetContext::setupDstProxy(GrRenderTargetProxy* rtProxy, const GrClip& clip,
- const SkRect& opBounds,
- GrXferProcessor::DstProxy* dstProxy) {
+ const SkRect& opBounds,
+ GrXferProcessor::DstProxy* dstProxy) {
if (this->caps()->textureBarrierSupport()) {
if (GrTextureProxy* texProxy = rtProxy->asTextureProxy()) {
// The render target is a texture, so we can read from it directly in the shader. The XP
@@ -1839,8 +1839,8 @@ bool GrRenderTargetContext::setupDstProxy(GrRenderTargetProxy* rtProxy, const Gr
bool rectsMustMatch = false;
bool disallowSubrect = false;
if (!this->caps()->initDescForDstCopy(rtProxy, &desc, &rectsMustMatch, &disallowSubrect)) {
- desc.fOrigin = kBottomLeft_GrSurfaceOrigin;
desc.fFlags = kRenderTarget_GrSurfaceFlag;
+ desc.fOrigin = kBottomLeft_GrSurfaceOrigin;
desc.fConfig = rtProxy->config();
}
diff --git a/src/gpu/GrSurfaceProxy.cpp b/src/gpu/GrSurfaceProxy.cpp
index 804cabbacd..f8639406d6 100644
--- a/src/gpu/GrSurfaceProxy.cpp
+++ b/src/gpu/GrSurfaceProxy.cpp
@@ -48,16 +48,16 @@ sk_sp<GrSurface> GrSurfaceProxy::createSurfaceImpl(
GrSurfaceFlags flags, bool isMipMapped,
SkDestinationSurfaceColorMode mipColorMode) const {
GrSurfaceDesc desc;
- desc.fConfig = fConfig;
- desc.fWidth = fWidth;
- desc.fHeight = fHeight;
- desc.fOrigin = fOrigin;
- desc.fSampleCnt = sampleCnt;
- desc.fIsMipMapped = isMipMapped;
desc.fFlags = flags;
if (fNeedsClear) {
desc.fFlags |= kPerformInitialClear_GrSurfaceFlag;
}
+ desc.fOrigin = fOrigin;
+ desc.fWidth = fWidth;
+ desc.fHeight = fHeight;
+ desc.fConfig = fConfig;
+ desc.fSampleCnt = sampleCnt;
+ desc.fIsMipMapped = isMipMapped;
sk_sp<GrSurface> surface;
if (SkBackingFit::kApprox == fFit) {
@@ -300,10 +300,10 @@ sk_sp<GrTextureProxy> GrSurfaceProxy::Copy(GrContext* context,
}
GrSurfaceDesc dstDesc;
- dstDesc.fConfig = src->config();
+ dstDesc.fOrigin = src->origin();
dstDesc.fWidth = srcRect.width();
dstDesc.fHeight = srcRect.height();
- dstDesc.fOrigin = src->origin();
+ dstDesc.fConfig = src->config();
sk_sp<GrSurfaceContext> dstContext(context->contextPriv().makeDeferredSurfaceContext(
dstDesc,
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index 412f3c57cb..3c35def752 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -1742,12 +1742,7 @@ void GrGLGpu::flushScissor(const GrScissorState& scissorState,
GrSurfaceOrigin rtOrigin) {
if (scissorState.enabled()) {
GrGLIRect scissor;
- scissor.setRelativeTo(rtViewport,
- scissorState.rect().fLeft,
- scissorState.rect().fTop,
- scissorState.rect().width(),
- scissorState.rect().height(),
- rtOrigin);
+ scissor.setRelativeTo(rtViewport, scissorState.rect(), rtOrigin);
// if the scissor fully contains the viewport then we fall through and
// disable the scissor test.
if (!scissor.contains(rtViewport)) {
@@ -1860,7 +1855,7 @@ bool GrGLGpu::flushGLState(const GrPipeline& pipeline, const GrPrimitiveProcesso
glRT->renderTargetPriv().numStencilBits());
}
this->flushStencil(stencil);
- this->flushScissor(pipeline.getScissorState(), glRT->getViewport(), glRT->origin());
+ this->flushScissor(pipeline.getScissorState(), glRT->getViewport(), pipeline.proxy()->origin());
this->flushWindowRectangles(pipeline.getWindowRectsState(), glRT);
this->flushHWAAState(glRT, pipeline.isHWAntialiasState(), !stencil.isDisabled());
@@ -2123,11 +2118,12 @@ bool GrGLGpu::readPixelsSupported(GrRenderTarget* target, GrPixelConfig readConf
bool GrGLGpu::readPixelsSupported(GrPixelConfig rtConfig, GrPixelConfig readConfig) {
sk_sp<GrTexture> temp;
auto bindRenderTarget = [this, rtConfig, &temp]() -> bool {
- GrTextureDesc desc;
+ GrSurfaceDesc desc;
desc.fConfig = rtConfig;
desc.fWidth = desc.fHeight = 16;
if (this->glCaps().isConfigRenderable(rtConfig, false)) {
desc.fFlags = kRenderTarget_GrSurfaceFlag;
+ desc.fOrigin = kBottomLeft_GrSurfaceOrigin;
temp = this->createTexture(desc, SkBudgeted::kNo);
if (!temp) {
return false;
@@ -2136,6 +2132,7 @@ bool GrGLGpu::readPixelsSupported(GrPixelConfig rtConfig, GrPixelConfig readConf
this->flushRenderTarget(glrt, &SkIRect::EmptyIRect());
return true;
} else if (this->glCaps().canConfigBeFBOColorAttachment(rtConfig)) {
+ desc.fOrigin = kTopLeft_GrSurfaceOrigin;
temp = this->createTexture(desc, SkBudgeted::kNo);
if (!temp) {
return false;
@@ -2553,7 +2550,7 @@ void GrGLGpu::draw(const GrPipeline& pipeline,
if (pipeline.getScissorState().enabled()) {
GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(pipeline.renderTarget());
this->flushScissor(dynamicStates[i].fScissorRect,
- glRT->getViewport(), glRT->origin());
+ glRT->getViewport(), pipeline.proxy()->origin());
}
}
if (this->glCaps().requiresCullFaceEnableDisableWhenDrawingLinesAfterNonLines() &&
@@ -2694,8 +2691,7 @@ void GrGLGpu::onResolveRenderTarget(GrRenderTarget* target) {
t = target->height();
} else {
GrGLIRect rect;
- rect.setRelativeTo(vp, dirtyRect.fLeft, dirtyRect.fTop,
- dirtyRect.width(), dirtyRect.height(), target->origin());
+ rect.setRelativeTo(vp, dirtyRect, target->origin());
l = rect.fLeft;
b = rect.fBottom;
r = rect.fLeft + rect.fWidth;
@@ -3951,12 +3947,7 @@ void GrGLGpu::copySurfaceAsCopyTexSubImage(GrSurface* dst,
// We modified the bound FBO
fHWBoundRenderTargetUniqueID.makeInvalid();
GrGLIRect srcGLRect;
- srcGLRect.setRelativeTo(srcVP,
- srcRect.fLeft,
- srcRect.fTop,
- srcRect.width(),
- srcRect.height(),
- src->origin());
+ srcGLRect.setRelativeTo(srcVP, srcRect, src->origin());
this->setScratchTextureUnit();
GL_CALL(BindTexture(dstTex->target(), dstTex->textureID()));
@@ -3997,18 +3988,8 @@ bool GrGLGpu::copySurfaceAsBlitFramebuffer(GrSurface* dst,
fHWBoundRenderTargetUniqueID.makeInvalid();
GrGLIRect srcGLRect;
GrGLIRect dstGLRect;
- srcGLRect.setRelativeTo(srcVP,
- srcRect.fLeft,
- srcRect.fTop,
- srcRect.width(),
- srcRect.height(),
- src->origin());
- dstGLRect.setRelativeTo(dstVP,
- dstRect.fLeft,
- dstRect.fTop,
- dstRect.width(),
- dstRect.height(),
- dst->origin());
+ srcGLRect.setRelativeTo(srcVP, srcRect, src->origin());
+ dstGLRect.setRelativeTo(dstVP, dstRect, dst->origin());
// BlitFrameBuffer respects the scissor, so disable it.
this->disableScissor();
diff --git a/src/gpu/glsl/GrGLSLProgramBuilder.cpp b/src/gpu/glsl/GrGLSLProgramBuilder.cpp
index 0d87c4f5a2..5c78c07fc2 100644
--- a/src/gpu/glsl/GrGLSLProgramBuilder.cpp
+++ b/src/gpu/glsl/GrGLSLProgramBuilder.cpp
@@ -231,7 +231,7 @@ void GrGLSLProgramBuilder::emitAndInstallXferProc(const SkString& colorIn,
dstTextureSamplerHandle =
this->emitSampler(dstTexture->texturePriv().samplerType(), dstTexture->config(),
"DstTextureSampler", kFragment_GrShaderFlag);
- dstTextureOrigin = dstTexture->origin();
+ dstTextureOrigin = fPipeline.dstTextureProxy()->origin();
SkASSERT(kTextureExternalSampler_GrSLType != dstTexture->texturePriv().samplerType());
}
diff --git a/src/gpu/vk/GrVkGpu.cpp b/src/gpu/vk/GrVkGpu.cpp
index d1e535ea6a..31e55de46a 100644
--- a/src/gpu/vk/GrVkGpu.cpp
+++ b/src/gpu/vk/GrVkGpu.cpp
@@ -933,15 +933,14 @@ sk_sp<GrRenderTarget> GrVkGpu::onWrapBackendRenderTarget(const GrBackendRenderTa
}
GrSurfaceDesc desc;
- desc.fConfig = backendRT.config();
desc.fFlags = kRenderTarget_GrSurfaceFlag;
+ SkASSERT(kDefault_GrSurfaceOrigin != origin);
+ desc.fOrigin = origin;
desc.fWidth = backendRT.width();
desc.fHeight = backendRT.height();
+ desc.fConfig = backendRT.config();
desc.fSampleCnt = 0;
- SkASSERT(kDefault_GrSurfaceOrigin != origin);
- desc.fOrigin = origin;
-
sk_sp<GrVkRenderTarget> tgt = GrVkRenderTarget::MakeWrappedRenderTarget(this, desc, info);
if (tgt && backendRT.stencilBits()) {
if (!createStencilAttachmentForRenderTarget(tgt.get(), desc.fWidth, desc.fHeight)) {
@@ -965,13 +964,12 @@ sk_sp<GrRenderTarget> GrVkGpu::onWrapBackendTextureAsRenderTarget(const GrBacken
GrSurfaceDesc desc;
desc.fFlags = kRenderTarget_GrSurfaceFlag;
- desc.fConfig = tex.config();
+ desc.fOrigin = resolve_origin(origin);
desc.fWidth = tex.width();
desc.fHeight = tex.height();
+ desc.fConfig = tex.config();
desc.fSampleCnt = this->caps()->getSampleCount(sampleCnt, tex.config());
- desc.fOrigin = resolve_origin(origin);
-
sk_sp<GrVkRenderTarget> tgt = GrVkRenderTarget::MakeWrappedRenderTarget(this, desc, info);
return tgt;
}
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index 3bed9e8298..a19556b653 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -230,10 +230,10 @@ bool SkImage_Gpu::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size
sk_sp<SkImage> SkImage_Gpu::onMakeSubset(const SkIRect& subset) const {
GrSurfaceDesc desc;
- desc.fConfig = fProxy->config();
+ desc.fOrigin = fProxy->origin();
desc.fWidth = subset.width();
desc.fHeight = subset.height();
- desc.fOrigin = fProxy->origin();
+ desc.fConfig = fProxy->config();
sk_sp<GrSurfaceContext> sContext(fContext->contextPriv().makeDeferredSurfaceContext(
desc,
@@ -491,8 +491,8 @@ sk_sp<SkImage> SkImage::MakeCrossContextFromEncoded(GrContext* context, sk_sp<Sk
sk_sp<GrSemaphore> sema = context->getGpu()->prepareTextureForCrossContextUsage(texture.get());
- auto gen = GrBackendTextureImageGenerator::Make(std::move(texture), std::move(sema),
- codecImage->alphaType(),
+ auto gen = GrBackendTextureImageGenerator::Make(std::move(texture),
+ std::move(sema), codecImage->alphaType(),
std::move(texColorSpace));
return SkImage::MakeFromGenerator(std::move(gen));
}