Chromium Code Reviews| Index: src/gpu/GrGpu.cpp |
| diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp |
| index 88e2bb961e6b8dd336713d6ee5928cb50b8a1dab..d57bac1dc5e69169747b09ccae7aa15eb2c5ca9f 100644 |
| --- a/src/gpu/GrGpu.cpp |
| +++ b/src/gpu/GrGpu.cpp |
| @@ -37,6 +37,21 @@ void GrGpu::contextAbandoned() {} |
| //////////////////////////////////////////////////////////////////////////////// |
| +namespace { |
| + |
| +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; |
| + } |
| +} |
| + |
| +} |
| + |
| GrTexture* GrGpu::createTexture(const GrSurfaceDesc& desc, bool budgeted, |
| const void* srcData, size_t rowBytes) { |
| if (!this->caps()->isConfigTexturable(desc.fConfig)) { |
| @@ -49,9 +64,34 @@ GrTexture* GrGpu::createTexture(const GrSurfaceDesc& desc, bool budgeted, |
| } |
| GrTexture *tex = NULL; |
| + |
| + if (isRT) { |
| + int maxRTSize = this->caps()->maxRenderTargetSize(); |
| + if (desc.fWidth > maxRTSize || desc.fHeight > maxRTSize) { |
| + return NULL; |
| + } |
| + } else { |
| + int maxSize = this->caps()->maxTextureSize(); |
| + if (desc.fWidth > maxSize || desc.fHeight > maxSize) { |
| + return NULL; |
| + } |
| + } |
| + |
| + GrGpuResource::LifeCycle lifeCycle = budgeted ? GrGpuResource::kCached_LifeCycle : |
| + GrGpuResource::kUncached_LifeCycle; |
| + |
| + GrSurfaceDesc descCopy = desc; |
| + |
| + descCopy.fSampleCnt = SkTMin(descCopy.fSampleCnt, this->caps()->maxSampleCount()); |
| + // Attempt to catch un- or wrongly initialized sample counts; |
| + SkASSERT(descCopy.fSampleCnt >= 0 && descCopy.fSampleCnt <= 64); |
| + |
| + descCopy.fOrigin = resolve_origin(descCopy.fOrigin, isRT); |
| + |
| if (GrPixelConfigIsCompressed(desc.fConfig)) { |
| // We shouldn't be rendering into this |
| - SkASSERT((desc.fFlags & kRenderTarget_GrSurfaceFlag) == 0); |
| + SkASSERT(!isRT); |
| + SkASSERT(0 == descCopy.fSampleCnt); |
| if (!this->caps()->npotTextureTileSupport() && |
| (!SkIsPow2(desc.fWidth) || !SkIsPow2(desc.fHeight))) { |
|
bsalomon
2015/04/22 20:11:11
descCopy x2 ?
minor suggestion: I think it is sl
egdaniel
2015/04/22 20:20:27
Done.
|
| @@ -59,10 +99,10 @@ GrTexture* GrGpu::createTexture(const GrSurfaceDesc& desc, bool budgeted, |
| } |
| this->handleDirtyContext(); |
| - tex = this->onCreateCompressedTexture(desc, budgeted, srcData); |
| + tex = this->onCreateCompressedTexture(descCopy, lifeCycle, srcData); |
| } else { |
| this->handleDirtyContext(); |
| - tex = this->onCreateTexture(desc, budgeted, srcData, rowBytes); |
| + tex = this->onCreateTexture(descCopy, lifeCycle, srcData, rowBytes); |
| } |
| if (!this->caps()->reuseScratchTextures() && !isRT) { |
| tex->resourcePriv().removeScratchKey(); |