| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "GrGLRenderTarget.h" | 8 #include "GrGLRenderTarget.h" |
| 9 | 9 |
| 10 #include "GrGLGpu.h" | 10 #include "GrGLGpu.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 fViewport.fLeft = 0; | 57 fViewport.fLeft = 0; |
| 58 fViewport.fBottom = 0; | 58 fViewport.fBottom = 0; |
| 59 fViewport.fWidth = desc.fWidth; | 59 fViewport.fWidth = desc.fWidth; |
| 60 fViewport.fHeight = desc.fHeight; | 60 fViewport.fHeight = desc.fHeight; |
| 61 | 61 |
| 62 fGpuMemorySize = this->totalSamples() * this->totalBytesPerSample(); | 62 fGpuMemorySize = this->totalSamples() * this->totalBytesPerSample(); |
| 63 | 63 |
| 64 SkASSERT(fGpuMemorySize <= WorstCaseSize(desc)); | 64 SkASSERT(fGpuMemorySize <= WorstCaseSize(desc)); |
| 65 } | 65 } |
| 66 | 66 |
| 67 GrGLRenderTarget* GrGLRenderTarget::CreateWrapped(GrGLGpu* gpu, | 67 sk_sp<GrGLRenderTarget> GrGLRenderTarget::MakeWrapped(GrGLGpu* gpu, |
| 68 const GrSurfaceDesc& desc, | 68 const GrSurfaceDesc& desc, |
| 69 const IDDesc& idDesc, | 69 const IDDesc& idDesc, |
| 70 int stencilBits) { | 70 int stencilBits) { |
| 71 GrGLStencilAttachment* sb = nullptr; | 71 GrGLStencilAttachment* sb = nullptr; |
| 72 if (stencilBits) { | 72 if (stencilBits) { |
| 73 GrGLStencilAttachment::IDDesc sbDesc; | 73 GrGLStencilAttachment::IDDesc sbDesc; |
| 74 GrGLStencilAttachment::Format format; | 74 GrGLStencilAttachment::Format format; |
| 75 format.fInternalFormat = GrGLStencilAttachment::kUnknownInternalFormat; | 75 format.fInternalFormat = GrGLStencilAttachment::kUnknownInternalFormat; |
| 76 format.fPacked = false; | 76 format.fPacked = false; |
| 77 format.fStencilBits = stencilBits; | 77 format.fStencilBits = stencilBits; |
| 78 format.fTotalBits = stencilBits; | 78 format.fTotalBits = stencilBits; |
| 79 // Owndership of sb is passed to the GrRenderTarget so doesn't need to b
e deleted | 79 // Owndership of sb is passed to the GrRenderTarget so doesn't need to b
e deleted |
| 80 sb = new GrGLStencilAttachment(gpu, sbDesc, desc.fWidth, desc.fHeight, | 80 sb = new GrGLStencilAttachment(gpu, sbDesc, desc.fWidth, desc.fHeight, |
| 81 desc.fSampleCnt, format); | 81 desc.fSampleCnt, format); |
| 82 } | 82 } |
| 83 return (new GrGLRenderTarget(gpu, desc, idDesc, sb)); | 83 return sk_sp<GrGLRenderTarget>(new GrGLRenderTarget(gpu, desc, idDesc, sb)); |
| 84 } | 84 } |
| 85 | 85 |
| 86 size_t GrGLRenderTarget::onGpuMemorySize() const { | 86 size_t GrGLRenderTarget::onGpuMemorySize() const { |
| 87 return fGpuMemorySize; | 87 return fGpuMemorySize; |
| 88 } | 88 } |
| 89 | 89 |
| 90 bool GrGLRenderTarget::completeStencilAttachment() { | 90 bool GrGLRenderTarget::completeStencilAttachment() { |
| 91 GrGLGpu* gpu = this->getGLGpu(); | 91 GrGLGpu* gpu = this->getGLGpu(); |
| 92 const GrGLInterface* interface = gpu->glInterface(); | 92 const GrGLInterface* interface = gpu->glInterface(); |
| 93 GrStencilAttachment* stencil = this->renderTargetPriv().getStencilAttachment
(); | 93 GrStencilAttachment* stencil = this->renderTargetPriv().getStencilAttachment
(); |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 int GrGLRenderTarget::totalSamples() const { | 230 int GrGLRenderTarget::totalSamples() const { |
| 231 int total_samples = this->msaaSamples(); | 231 int total_samples = this->msaaSamples(); |
| 232 | 232 |
| 233 if (fTexFBOID != kUnresolvableFBOID) { | 233 if (fTexFBOID != kUnresolvableFBOID) { |
| 234 // If we own the resolve buffer then that is one more sample per pixel. | 234 // If we own the resolve buffer then that is one more sample per pixel. |
| 235 total_samples += 1; | 235 total_samples += 1; |
| 236 } | 236 } |
| 237 | 237 |
| 238 return total_samples; | 238 return total_samples; |
| 239 } | 239 } |
| OLD | NEW |