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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: src/gpu/GrSurface.cpp
diff --git a/src/gpu/GrSurface.cpp b/src/gpu/GrSurface.cpp
index 886945c71036052812e3e0e003ad931b1dfd672d..b157cf2028612d87e872416726fe22ca3491cbd5 100644
--- a/src/gpu/GrSurface.cpp
+++ b/src/gpu/GrSurface.cpp
@@ -19,17 +19,20 @@ size_t GrSurface::WorseCaseSize(const GrSurfaceDesc& desc) {
bool isRenderTarget = SkToBool(desc.fFlags & kRenderTarget_GrSurfaceFlag);
if (isRenderTarget) {
+ // We own one color value for texture storing the rendering result,
+ // e.g. the actual fbo texture attachment or the resolve texture.
// We own one color value for each MSAA sample.
- int colorValuesPerPixel = SkTMax(1, desc.fSampleCnt);
- if (desc.fSampleCnt) {
- // Worse case, we own the resolve buffer so that is one more sample per pixel.
- colorValuesPerPixel += 1;
- }
+ size_t colorValues = 1 + static_cast<size_t>(desc.fSampleCnt);
+
SkASSERT(kUnknown_GrPixelConfig != desc.fConfig);
SkASSERT(!GrPixelConfigIsCompressed(desc.fConfig));
size_t colorBytes = GrBytesPerPixel(desc.fConfig);
SkASSERT(colorBytes > 0);
- size = colorValuesPerPixel * desc.fWidth * desc.fHeight * colorBytes;
+ size_t bytesPerColorValue = desc.fWidth * desc.fHeight * colorBytes;
+ size = colorValues * bytesPerColorValue;
+ // Render target that is a texture might have mipmaps in the
+ // rendering target texture.
+ size += bytesPerColorValue / 3;
} else {
if (GrPixelConfigIsCompressed(desc.fConfig)) {
size = GrCompressedFormatDataSize(desc.fConfig, desc.fWidth, desc.fHeight);
« 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