diff options
author | Robert Phillips <robertphillips@google.com> | 2017-08-01 13:51:44 +0000 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-08-01 13:51:54 +0000 |
commit | 7294b851d277d8e703b23657e1a990f1ae24ead6 (patch) | |
tree | b042db82a0b5bf61d0f453d404dbdeab2f8e3a47 /src/gpu/GrTexture.cpp | |
parent | ac32662d128484eae3230653e3794a6f33dd9f5b (diff) |
Revert "Remove origin field from GrSurface"
This reverts commit df0e09feacb29290fe94d37f921731b18f2edae0.
Reason for revert: Experimental revert to see if this is blocking the roll
Original change's description:
> Remove origin field from GrSurface
>
> This mainly consists of rm origin from GrSurface and the wrapBackEnd*
> methods and then re-adding an explicit origin parameter to all the
> GrGpu methods that need it.
>
> Change-Id: Iabd79ae98b227b5b9409f3ab5bbcc48af9613c18
> Reviewed-on: https://skia-review.googlesource.com/26363
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Commit-Queue: Robert Phillips <robertphillips@google.com>
TBR=bsalomon@google.com,robertphillips@google.com
Change-Id: Id606aa01e84e2b83be71d833eefca477c1ad0d01
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/29220
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src/gpu/GrTexture.cpp')
-rw-r--r-- | src/gpu/GrTexture.cpp | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/src/gpu/GrTexture.cpp b/src/gpu/GrTexture.cpp index 8e79a699fc..4f4e5aa266 100644 --- a/src/gpu/GrTexture.cpp +++ b/src/gpu/GrTexture.cpp @@ -40,6 +40,24 @@ size_t GrTexture::onGpuMemorySize() const { } ///////////////////////////////////////////////////////////////////////////// + +namespace { + +// FIXME: This should be refactored with the code in gl/GrGLGpu.cpp. +GrSurfaceOrigin resolve_origin(const GrSurfaceDesc& desc) { + // By default, GrRenderTargets are GL's normal orientation so that they + // can be drawn to by the outside world without the client having + // to render upside down. + bool renderTarget = 0 != (desc.fFlags & kRenderTarget_GrSurfaceFlag); + if (kDefault_GrSurfaceOrigin == desc.fOrigin) { + return renderTarget ? kBottomLeft_GrSurfaceOrigin : kTopLeft_GrSurfaceOrigin; + } else { + return desc.fOrigin; + } +} +} + +////////////////////////////////////////////////////////////////////////////// GrTexture::GrTexture(GrGpu* gpu, const GrSurfaceDesc& desc, GrSLType samplerType, GrSamplerParams::FilterMode highestFilterMode, bool wasMipMapDataProvided) : INHERITED(gpu, desc) @@ -63,12 +81,12 @@ void GrTexture::computeScratchKey(GrScratchKey* key) const { sampleCount = rt->numStencilSamples(); } GrTexturePriv::ComputeScratchKey(this->config(), this->width(), this->height(), - SkToBool(rt), sampleCount, + this->origin(), SkToBool(rt), sampleCount, this->texturePriv().hasMipMaps(), key); } void GrTexturePriv::ComputeScratchKey(GrPixelConfig config, int width, int height, - bool isRenderTarget, int sampleCnt, + GrSurfaceOrigin origin, bool isRenderTarget, int sampleCnt, bool isMipMapped, GrScratchKey* key) { static const GrScratchKey::ResourceType kType = GrScratchKey::GenerateResourceType(); uint32_t flags = isRenderTarget; @@ -80,18 +98,17 @@ void GrTexturePriv::ComputeScratchKey(GrPixelConfig config, int width, int heigh SkASSERT(static_cast<int>(config) < (1 << 5)); SkASSERT(sampleCnt < (1 << 8)); SkASSERT(flags < (1 << 10)); + SkASSERT(static_cast<int>(origin) < (1 << 8)); GrScratchKey::Builder builder(key, kType, 3); builder[0] = width; builder[1] = height; - builder[2] = config | (isMipMapped << 5) | (sampleCnt << 6) | (flags << 14); + builder[2] = config | (isMipMapped << 5) | (sampleCnt << 6) | (flags << 14) | (origin << 24); } void GrTexturePriv::ComputeScratchKey(const GrSurfaceDesc& desc, GrScratchKey* key) { - SkASSERT(kDefault_GrSurfaceOrigin != desc.fOrigin); - - // Note: the fOrigin field is not used in the scratch key - return ComputeScratchKey(desc.fConfig, desc.fWidth, desc.fHeight, + GrSurfaceOrigin origin = resolve_origin(desc); + return ComputeScratchKey(desc.fConfig, desc.fWidth, desc.fHeight, origin, SkToBool(desc.fFlags & kRenderTarget_GrSurfaceFlag), desc.fSampleCnt, desc.fIsMipMapped, key); } |