diff options
author | Robert Phillips <robertphillips@google.com> | 2017-08-29 08:26:54 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-08-29 17:36:31 +0000 |
commit | b0e93a22bbfad05bb834e33387880ece56e0f6d2 (patch) | |
tree | 41862bc027841d9d03a06661f2f3ef820610a9ac /src/gpu/GrGpu.cpp | |
parent | aa0ce825b877871f73532beb6fde6bf2f80e99dd (diff) |
Remove origin field from GrSurface (take 2)
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.
TBR=bsalomon@google.com
Change-Id: I4248b2a4749ef844da4233ce53b0dc504bc9eb74
Reviewed-on: https://skia-review.googlesource.com/30280
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/gpu/GrGpu.cpp')
-rw-r--r-- | src/gpu/GrGpu.cpp | 71 |
1 files changed, 29 insertions, 42 deletions
diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp index 50a05c86c9..f99dce4e97 100644 --- a/src/gpu/GrGpu.cpp +++ b/src/gpu/GrGpu.cpp @@ -71,17 +71,6 @@ 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. @@ -149,8 +138,7 @@ 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); - - desc.fOrigin = resolve_origin(desc.fOrigin, isRT); + SkASSERT(kDefault_GrSurfaceOrigin != desc.fOrigin); if (mipLevelCount && (desc.fFlags & kPerformInitialClear_GrSurfaceFlag)) { return nullptr; @@ -177,7 +165,6 @@ 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())) { @@ -187,7 +174,7 @@ sk_sp<GrTexture> GrGpu::wrapBackendTexture(const GrBackendTexture& backendTex, backendTex.height() > this->caps()->maxTextureSize()) { return nullptr; } - sk_sp<GrTexture> tex = this->onWrapBackendTexture(backendTex, origin, ownership); + sk_sp<GrTexture> tex = this->onWrapBackendTexture(backendTex, ownership); if (!tex) { return nullptr; } @@ -195,8 +182,7 @@ sk_sp<GrTexture> GrGpu::wrapBackendTexture(const GrBackendTexture& backendTex, } sk_sp<GrTexture> GrGpu::wrapRenderableBackendTexture(const GrBackendTexture& backendTex, - GrSurfaceOrigin origin, int sampleCnt, - GrWrapOwnership ownership) { + int sampleCnt, GrWrapOwnership ownership) { this->handleDirtyContext(); if (!this->caps()->isConfigTexturable(backendTex.config()) || !this->caps()->isConfigRenderable(backendTex.config(), sampleCnt > 0)) { @@ -208,7 +194,7 @@ sk_sp<GrTexture> GrGpu::wrapRenderableBackendTexture(const GrBackendTexture& bac return nullptr; } sk_sp<GrTexture> tex = - this->onWrapRenderableBackendTexture(backendTex, origin, sampleCnt, ownership); + this->onWrapRenderableBackendTexture(backendTex, sampleCnt, ownership); if (!tex) { return nullptr; } @@ -222,17 +208,15 @@ sk_sp<GrTexture> GrGpu::wrapRenderableBackendTexture(const GrBackendTexture& bac return tex; } -sk_sp<GrRenderTarget> GrGpu::wrapBackendRenderTarget(const GrBackendRenderTarget& backendRT, - GrSurfaceOrigin origin) { +sk_sp<GrRenderTarget> GrGpu::wrapBackendRenderTarget(const GrBackendRenderTarget& backendRT) { if (!this->caps()->isConfigRenderable(backendRT.config(), backendRT.sampleCnt() > 0)) { return nullptr; } this->handleDirtyContext(); - return this->onWrapBackendRenderTarget(backendRT, origin); + return this->onWrapBackendRenderTarget(backendRT); } sk_sp<GrRenderTarget> GrGpu::wrapBackendTextureAsRenderTarget(const GrBackendTexture& tex, - GrSurfaceOrigin origin, int sampleCnt) { this->handleDirtyContext(); if (!this->caps()->isConfigRenderable(tex.config(), sampleCnt > 0)) { @@ -242,7 +226,7 @@ sk_sp<GrRenderTarget> GrGpu::wrapBackendTextureAsRenderTarget(const GrBackendTex if (tex.width() > maxSize || tex.height() > maxSize) { return nullptr; } - return this->onWrapBackendTextureAsRenderTarget(tex, origin, sampleCnt); + return this->onWrapBackendTextureAsRenderTarget(tex, sampleCnt); } GrBuffer* GrGpu::createBuffer(size_t size, GrBufferType intendedType, @@ -265,10 +249,9 @@ gr_instanced::InstancedRendering* GrGpu::createInstancedRendering() { return this->onCreateInstancedRendering(); } -bool GrGpu::copySurface(GrSurface* dst, - GrSurface* src, - const SkIRect& srcRect, - const SkIPoint& dstPoint) { +bool GrGpu::copySurface(GrSurface* dst, GrSurfaceOrigin dstOrigin, + GrSurface* src, GrSurfaceOrigin srcOrigin, + const SkIRect& srcRect, const SkIPoint& dstPoint) { GR_CREATE_TRACE_MARKER_CONTEXT("GrGpu", "copySurface", fContext); SkASSERT(dst && src); this->handleDirtyContext(); @@ -276,10 +259,11 @@ bool GrGpu::copySurface(GrSurface* dst, if (GrPixelConfigIsSint(dst->config()) != GrPixelConfigIsSint(src->config())) { return false; } - return this->onCopySurface(dst, src, srcRect, dstPoint); + return this->onCopySurface(dst, dstOrigin, src, srcOrigin, srcRect, dstPoint); } -bool GrGpu::getReadPixelsInfo(GrSurface* srcSurface, int width, int height, size_t rowBytes, +bool GrGpu::getReadPixelsInfo(GrSurface* srcSurface, GrSurfaceOrigin srcOrigin, + int width, int height, size_t rowBytes, GrPixelConfig readConfig, DrawPreference* drawPreference, ReadPixelTempDrawInfo* tempDrawInfo) { SkASSERT(drawPreference); @@ -293,8 +277,8 @@ bool GrGpu::getReadPixelsInfo(GrSurface* srcSurface, int width, int height, size return false; } - if (!this->onGetReadPixelsInfo(srcSurface, width, height, rowBytes, readConfig, drawPreference, - tempDrawInfo)) { + if (!this->onGetReadPixelsInfo(srcSurface, srcOrigin, width, height, rowBytes, readConfig, + drawPreference, tempDrawInfo)) { return false; } @@ -310,7 +294,8 @@ bool GrGpu::getReadPixelsInfo(GrSurface* srcSurface, int width, int height, size return true; } -bool GrGpu::getWritePixelsInfo(GrSurface* dstSurface, int width, int height, +bool GrGpu::getWritePixelsInfo(GrSurface* dstSurface, GrSurfaceOrigin dstOrigin, + int width, int height, GrPixelConfig srcConfig, DrawPreference* drawPreference, WritePixelTempDrawInfo* tempDrawInfo) { SkASSERT(drawPreference); @@ -318,7 +303,7 @@ bool GrGpu::getWritePixelsInfo(GrSurface* dstSurface, int width, int height, SkASSERT(dstSurface); SkASSERT(kGpuPrefersDraw_DrawPreference != *drawPreference); - if (!this->onGetWritePixelsInfo(dstSurface, width, height, srcConfig, drawPreference, + if (!this->onGetWritePixelsInfo(dstSurface, dstOrigin, width, height, srcConfig, drawPreference, tempDrawInfo)) { return false; } @@ -336,7 +321,7 @@ bool GrGpu::getWritePixelsInfo(GrSurface* dstSurface, int width, int height, return true; } -bool GrGpu::readPixels(GrSurface* surface, +bool GrGpu::readPixels(GrSurface* surface, GrSurfaceOrigin origin, int left, int top, int width, int height, GrPixelConfig config, void* buffer, size_t rowBytes) { @@ -357,13 +342,13 @@ bool GrGpu::readPixels(GrSurface* surface, this->handleDirtyContext(); - return this->onReadPixels(surface, + return this->onReadPixels(surface, origin, left, top, width, height, config, buffer, rowBytes); } -bool GrGpu::writePixels(GrSurface* surface, +bool GrGpu::writePixels(GrSurface* surface, GrSurfaceOrigin origin, int left, int top, int width, int height, GrPixelConfig config, const GrMipLevel texels[], int mipLevelCount) { SkASSERT(surface); @@ -391,7 +376,8 @@ bool GrGpu::writePixels(GrSurface* surface, } this->handleDirtyContext(); - if (this->onWritePixels(surface, left, top, width, height, config, texels, mipLevelCount)) { + if (this->onWritePixels(surface, origin, left, top, width, height, config, + texels, mipLevelCount)) { SkIRect rect = SkIRect::MakeXYWH(left, top, width, height); this->didWriteToSurface(surface, &rect, mipLevelCount); fStats.incTextureUploads(); @@ -400,13 +386,13 @@ bool GrGpu::writePixels(GrSurface* surface, return false; } -bool GrGpu::writePixels(GrSurface* surface, +bool GrGpu::writePixels(GrSurface* surface, GrSurfaceOrigin origin, int left, int top, int width, int height, GrPixelConfig config, const void* buffer, size_t rowBytes) { GrMipLevel mipLevel = { buffer, rowBytes }; - return this->writePixels(surface, left, top, width, height, config, &mipLevel, 1); + return this->writePixels(surface, origin, left, top, width, height, config, &mipLevel, 1); } bool GrGpu::transferPixels(GrTexture* texture, @@ -439,10 +425,10 @@ bool GrGpu::transferPixels(GrTexture* texture, return false; } -void GrGpu::resolveRenderTarget(GrRenderTarget* target) { +void GrGpu::resolveRenderTarget(GrRenderTarget* target, GrSurfaceOrigin origin) { SkASSERT(target); this->handleDirtyContext(); - this->onResolveRenderTarget(target); + this->onResolveRenderTarget(target, origin); } void GrGpu::didWriteToSurface(GrSurface* surface, const SkIRect* bounds, uint32_t mipLevels) const { @@ -473,7 +459,8 @@ const GrGpu::MultisampleSpecs& GrGpu::queryMultisampleSpecs(const GrPipeline& pi int effectiveSampleCnt; SkSTArray<16, SkPoint, true> pattern; - this->onQueryMultisampleSpecs(rt, stencil, &effectiveSampleCnt, &pattern); + this->onQueryMultisampleSpecs(rt, pipeline.proxy()->origin(), stencil, + &effectiveSampleCnt, &pattern); SkASSERT(effectiveSampleCnt >= rt->numStencilSamples()); uint8_t id; |