Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(761)

Side by Side Diff: src/gpu/GrSurface.cpp

Issue 1810323002: Cache render targets that render to wrapped textures Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 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 "GrSurface.h" 8 #include "GrSurface.h"
9 #include "GrContext.h" 9 #include "GrContext.h"
10 #include "GrSurfacePriv.h" 10 #include "GrSurfacePriv.h"
11 11
12 #include "SkBitmap.h" 12 #include "SkBitmap.h"
13 #include "SkGrPriv.h" 13 #include "SkGrPriv.h"
14 #include "SkImageEncoder.h" 14 #include "SkImageEncoder.h"
15 #include <stdio.h> 15 #include <stdio.h>
16 16
17 size_t GrSurface::WorseCaseSize(const GrSurfaceDesc& desc) { 17 size_t GrSurface::WorseCaseSize(const GrSurfaceDesc& desc) {
18 size_t size; 18 size_t size;
19 19
20 bool isRenderTarget = SkToBool(desc.fFlags & kRenderTarget_GrSurfaceFlag); 20 bool isRenderTarget = SkToBool(desc.fFlags & kRenderTarget_GrSurfaceFlag);
21 if (isRenderTarget) { 21 if (isRenderTarget) {
22 // We own one color value for texture storing the rendering result,
23 // e.g. the actual fbo texture attachment or the resolve texture.
22 // We own one color value for each MSAA sample. 24 // We own one color value for each MSAA sample.
23 int colorValuesPerPixel = SkTMax(1, desc.fSampleCnt); 25 size_t colorValues = 1 + static_cast<size_t>(desc.fSampleCnt);
24 if (desc.fSampleCnt) { 26
25 // Worse case, we own the resolve buffer so that is one more sample per pixel.
26 colorValuesPerPixel += 1;
27 }
28 SkASSERT(kUnknown_GrPixelConfig != desc.fConfig); 27 SkASSERT(kUnknown_GrPixelConfig != desc.fConfig);
29 SkASSERT(!GrPixelConfigIsCompressed(desc.fConfig)); 28 SkASSERT(!GrPixelConfigIsCompressed(desc.fConfig));
30 size_t colorBytes = GrBytesPerPixel(desc.fConfig); 29 size_t colorBytes = GrBytesPerPixel(desc.fConfig);
31 SkASSERT(colorBytes > 0); 30 SkASSERT(colorBytes > 0);
32 size = colorValuesPerPixel * desc.fWidth * desc.fHeight * colorBytes; 31 size_t bytesPerColorValue = desc.fWidth * desc.fHeight * colorBytes;
32 size = colorValues * bytesPerColorValue;
33 // Render target that is a texture might have mipmaps in the
34 // rendering target texture.
35 size += bytesPerColorValue / 3;
33 } else { 36 } else {
34 if (GrPixelConfigIsCompressed(desc.fConfig)) { 37 if (GrPixelConfigIsCompressed(desc.fConfig)) {
35 size = GrCompressedFormatDataSize(desc.fConfig, desc.fWidth, desc.fH eight); 38 size = GrCompressedFormatDataSize(desc.fConfig, desc.fWidth, desc.fH eight);
36 } else { 39 } else {
37 size = (size_t) desc.fWidth * desc.fHeight * GrBytesPerPixel(desc.fC onfig); 40 size = (size_t) desc.fWidth * desc.fHeight * GrBytesPerPixel(desc.fC onfig);
38 } 41 }
39 42
40 size += size/3; // in case we have to mipmap 43 size += size/3; // in case we have to mipmap
41 } 44 }
42 45
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 206
204 void GrSurface::onRelease() { 207 void GrSurface::onRelease() {
205 this->invokeReleaseProc(); 208 this->invokeReleaseProc();
206 this->INHERITED::onRelease(); 209 this->INHERITED::onRelease();
207 } 210 }
208 211
209 void GrSurface::onAbandon() { 212 void GrSurface::onAbandon() {
210 this->invokeReleaseProc(); 213 this->invokeReleaseProc();
211 this->INHERITED::onAbandon(); 214 this->INHERITED::onAbandon();
212 } 215 }
OLDNEW
« no previous file with comments | « src/gpu/GrStencilAttachment.h ('k') | src/gpu/GrTest.cpp » ('j') | src/gpu/gl/GrGLGpu.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698