diff options
author | 2017-08-01 13:51:44 +0000 | |
---|---|---|
committer | 2017-08-01 13:51:54 +0000 | |
commit | 7294b851d277d8e703b23657e1a990f1ae24ead6 (patch) | |
tree | b042db82a0b5bf61d0f453d404dbdeab2f8e3a47 /src/gpu/GrGpu.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/GrGpu.cpp')
-rw-r--r-- | src/gpu/GrGpu.cpp | 71 |
1 files changed, 42 insertions, 29 deletions
diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp index 50bb776182..3487f6fea0 100644 --- a/src/gpu/GrGpu.cpp +++ b/src/gpu/GrGpu.cpp @@ -68,6 +68,17 @@ bool GrGpu::isACopyNeededForTextureParams(int width, int height, return false; } +static GrSurfaceOrigin resolve_origin(GrSurfaceOrigin origin, bool renderTarget) { + // 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. + if (kDefault_GrSurfaceOrigin == origin) { + return renderTarget ? kBottomLeft_GrSurfaceOrigin : kTopLeft_GrSurfaceOrigin; + } else { + return origin; + } +} + /** * Prior to creating a texture, make sure the type of texture being created is * supported by calling check_texture_creation_params. @@ -135,7 +146,8 @@ sk_sp<GrTexture> GrGpu::createTexture(const GrSurfaceDesc& origDesc, SkBudgeted desc.fSampleCnt = caps->getSampleCount(desc.fSampleCnt, desc.fConfig); // Attempt to catch un- or wrongly initialized sample counts. SkASSERT(desc.fSampleCnt >= 0 && desc.fSampleCnt <= 64); - SkASSERT(kDefault_GrSurfaceOrigin != desc.fOrigin); + + desc.fOrigin = resolve_origin(desc.fOrigin, isRT); if (mipLevelCount && (desc.fFlags & kPerformInitialClear_GrSurfaceFlag)) { return nullptr; @@ -162,6 +174,7 @@ sk_sp<GrTexture> GrGpu::createTexture(const GrSurfaceDesc& desc, SkBudgeted budg } sk_sp<GrTexture> GrGpu::wrapBackendTexture(const GrBackendTexture& backendTex, + GrSurfaceOrigin origin, GrWrapOwnership ownership) { this->handleDirtyContext(); if (!this->caps()->isConfigTexturable(backendTex.config())) { @@ -171,7 +184,7 @@ sk_sp<GrTexture> GrGpu::wrapBackendTexture(const GrBackendTexture& backendTex, backendTex.height() > this->caps()->maxTextureSize()) { return nullptr; } - sk_sp<GrTexture> tex = this->onWrapBackendTexture(backendTex, ownership); + sk_sp<GrTexture> tex = this->onWrapBackendTexture(backendTex, origin, ownership); if (!tex) { return nullptr; } @@ -179,7 +192,8 @@ sk_sp<GrTexture> GrGpu::wrapBackendTexture(const GrBackendTexture& backendTex, } sk_sp<GrTexture> GrGpu::wrapRenderableBackendTexture(const GrBackendTexture& backendTex, - int sampleCnt, GrWrapOwnership ownership) { + GrSurfaceOrigin origin, int sampleCnt, + GrWrapOwnership ownership) { this->handleDirtyContext(); if (!this->caps()->isConfigTexturable(backendTex.config()) || !this->caps()->isConfigRenderable(backendTex.config(), sampleCnt > 0)) { @@ -191,7 +205,7 @@ sk_sp<GrTexture> GrGpu::wrapRenderableBackendTexture(const GrBackendTexture& bac return nullptr; } sk_sp<GrTexture> tex = - this->onWrapRenderableBackendTexture(backendTex, sampleCnt, ownership); + this->onWrapRenderableBackendTexture(backendTex, origin, sampleCnt, ownership); if (!tex) { return nullptr; } @@ -205,15 +219,17 @@ sk_sp<GrTexture> GrGpu::wrapRenderableBackendTexture(const GrBackendTexture& bac return tex; } -sk_sp<GrRenderTarget> GrGpu::wrapBackendRenderTarget(const GrBackendRenderTarget& backendRT) { +sk_sp<GrRenderTarget> GrGpu::wrapBackendRenderTarget(const GrBackendRenderTarget& backendRT, + GrSurfaceOrigin origin) { if (!this->caps()->isConfigRenderable(backendRT.config(), backendRT.sampleCnt() > 0)) { return nullptr; } this->handleDirtyContext(); - return this->onWrapBackendRenderTarget(backendRT); + return this->onWrapBackendRenderTarget(backendRT, origin); } sk_sp<GrRenderTarget> GrGpu::wrapBackendTextureAsRenderTarget(const GrBackendTexture& tex, + GrSurfaceOrigin origin, int sampleCnt) { this->handleDirtyContext(); if (!this->caps()->isConfigRenderable(tex.config(), sampleCnt > 0)) { @@ -223,7 +239,7 @@ sk_sp<GrRenderTarget> GrGpu::wrapBackendTextureAsRenderTarget(const GrBackendTex if (tex.width() > maxSize || tex.height() > maxSize) { return nullptr; } - return this->onWrapBackendTextureAsRenderTarget(tex, sampleCnt); + return this->onWrapBackendTextureAsRenderTarget(tex, origin, sampleCnt); } GrBuffer* GrGpu::createBuffer(size_t size, GrBufferType intendedType, @@ -246,9 +262,10 @@ gr_instanced::InstancedRendering* GrGpu::createInstancedRendering() { return this->onCreateInstancedRendering(); } -bool GrGpu::copySurface(GrSurface* dst, GrSurfaceOrigin dstOrigin, - GrSurface* src, GrSurfaceOrigin srcOrigin, - const SkIRect& srcRect, const SkIPoint& dstPoint) { +bool GrGpu::copySurface(GrSurface* dst, + GrSurface* src, + const SkIRect& srcRect, + const SkIPoint& dstPoint) { GR_CREATE_TRACE_MARKER_CONTEXT("GrGpu", "copySurface", fContext); SkASSERT(dst && src); this->handleDirtyContext(); @@ -256,11 +273,10 @@ bool GrGpu::copySurface(GrSurface* dst, GrSurfaceOrigin dstOrigin, if (GrPixelConfigIsSint(dst->config()) != GrPixelConfigIsSint(src->config())) { return false; } - return this->onCopySurface(dst, dstOrigin, src, srcOrigin, srcRect, dstPoint); + return this->onCopySurface(dst, src, srcRect, dstPoint); } -bool GrGpu::getReadPixelsInfo(GrSurface* srcSurface, GrSurfaceOrigin srcOrigin, - int width, int height, size_t rowBytes, +bool GrGpu::getReadPixelsInfo(GrSurface* srcSurface, int width, int height, size_t rowBytes, GrPixelConfig readConfig, DrawPreference* drawPreference, ReadPixelTempDrawInfo* tempDrawInfo) { SkASSERT(drawPreference); @@ -274,8 +290,8 @@ bool GrGpu::getReadPixelsInfo(GrSurface* srcSurface, GrSurfaceOrigin srcOrigin, return false; } - if (!this->onGetReadPixelsInfo(srcSurface, srcOrigin, width, height, rowBytes, readConfig, - drawPreference, tempDrawInfo)) { + if (!this->onGetReadPixelsInfo(srcSurface, width, height, rowBytes, readConfig, drawPreference, + tempDrawInfo)) { return false; } @@ -291,8 +307,7 @@ bool GrGpu::getReadPixelsInfo(GrSurface* srcSurface, GrSurfaceOrigin srcOrigin, return true; } -bool GrGpu::getWritePixelsInfo(GrSurface* dstSurface, GrSurfaceOrigin dstOrigin, - int width, int height, +bool GrGpu::getWritePixelsInfo(GrSurface* dstSurface, int width, int height, GrPixelConfig srcConfig, DrawPreference* drawPreference, WritePixelTempDrawInfo* tempDrawInfo) { SkASSERT(drawPreference); @@ -300,7 +315,7 @@ bool GrGpu::getWritePixelsInfo(GrSurface* dstSurface, GrSurfaceOrigin dstOrigin, SkASSERT(dstSurface); SkASSERT(kGpuPrefersDraw_DrawPreference != *drawPreference); - if (!this->onGetWritePixelsInfo(dstSurface, dstOrigin, width, height, srcConfig, drawPreference, + if (!this->onGetWritePixelsInfo(dstSurface, width, height, srcConfig, drawPreference, tempDrawInfo)) { return false; } @@ -318,7 +333,7 @@ bool GrGpu::getWritePixelsInfo(GrSurface* dstSurface, GrSurfaceOrigin dstOrigin, return true; } -bool GrGpu::readPixels(GrSurface* surface, GrSurfaceOrigin origin, +bool GrGpu::readPixels(GrSurface* surface, int left, int top, int width, int height, GrPixelConfig config, void* buffer, size_t rowBytes) { @@ -339,13 +354,13 @@ bool GrGpu::readPixels(GrSurface* surface, GrSurfaceOrigin origin, this->handleDirtyContext(); - return this->onReadPixels(surface, origin, + return this->onReadPixels(surface, left, top, width, height, config, buffer, rowBytes); } -bool GrGpu::writePixels(GrSurface* surface, GrSurfaceOrigin origin, +bool GrGpu::writePixels(GrSurface* surface, int left, int top, int width, int height, GrPixelConfig config, const GrMipLevel texels[], int mipLevelCount) { SkASSERT(surface); @@ -373,8 +388,7 @@ bool GrGpu::writePixels(GrSurface* surface, GrSurfaceOrigin origin, } this->handleDirtyContext(); - if (this->onWritePixels(surface, origin, left, top, width, height, config, - texels, mipLevelCount)) { + if (this->onWritePixels(surface, left, top, width, height, config, texels, mipLevelCount)) { SkIRect rect = SkIRect::MakeXYWH(left, top, width, height); this->didWriteToSurface(surface, &rect, mipLevelCount); fStats.incTextureUploads(); @@ -383,13 +397,13 @@ bool GrGpu::writePixels(GrSurface* surface, GrSurfaceOrigin origin, return false; } -bool GrGpu::writePixels(GrSurface* surface, GrSurfaceOrigin origin, +bool GrGpu::writePixels(GrSurface* surface, int left, int top, int width, int height, GrPixelConfig config, const void* buffer, size_t rowBytes) { GrMipLevel mipLevel = { buffer, rowBytes }; - return this->writePixels(surface, origin, left, top, width, height, config, &mipLevel, 1); + return this->writePixels(surface, left, top, width, height, config, &mipLevel, 1); } bool GrGpu::transferPixels(GrTexture* texture, @@ -422,10 +436,10 @@ bool GrGpu::transferPixels(GrTexture* texture, return false; } -void GrGpu::resolveRenderTarget(GrRenderTarget* target, GrSurfaceOrigin origin) { +void GrGpu::resolveRenderTarget(GrRenderTarget* target) { SkASSERT(target); this->handleDirtyContext(); - this->onResolveRenderTarget(target, origin); + this->onResolveRenderTarget(target); } void GrGpu::didWriteToSurface(GrSurface* surface, const SkIRect* bounds, uint32_t mipLevels) const { @@ -456,8 +470,7 @@ const GrGpu::MultisampleSpecs& GrGpu::queryMultisampleSpecs(const GrPipeline& pi int effectiveSampleCnt; SkSTArray<16, SkPoint, true> pattern; - this->onQueryMultisampleSpecs(rt, pipeline.proxy()->origin(), stencil, - &effectiveSampleCnt, &pattern); + this->onQueryMultisampleSpecs(rt, stencil, &effectiveSampleCnt, &pattern); SkASSERT(effectiveSampleCnt >= rt->numStencilSamples()); uint8_t id; |