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

Unified Diff: src/gpu/GrSurface.cpp

Issue 1286203002: Defer flushes if kPreferNoIO is specified (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: use explicit size in test Created 5 years, 4 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
« no previous file with comments | « src/gpu/GrResourceProvider.cpp ('k') | src/gpu/GrTexture.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrSurface.cpp
diff --git a/src/gpu/GrSurface.cpp b/src/gpu/GrSurface.cpp
index 9bd9e8b5ef51b24290d80969e19dba961382d8da..89cbf4a5460679fad26d154bc017126a84f168c8 100644
--- a/src/gpu/GrSurface.cpp
+++ b/src/gpu/GrSurface.cpp
@@ -13,6 +13,35 @@
#include "SkImageEncoder.h"
#include <stdio.h>
+size_t GrSurface::WorseCaseSize(const GrSurfaceDesc& desc) {
+ size_t size;
+
+ bool isRenderTarget = SkToBool(desc.fFlags & kRenderTarget_GrSurfaceFlag);
+ if (isRenderTarget) {
+ // 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;
+ }
+ 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;
+ } else {
+ if (GrPixelConfigIsCompressed(desc.fConfig)) {
+ size = GrCompressedFormatDataSize(desc.fConfig, desc.fWidth, desc.fHeight);
+ } else {
+ size = (size_t) desc.fWidth * desc.fHeight * GrBytesPerPixel(desc.fConfig);
+ }
+
+ size += size/3; // in case we have to mipmap
+ }
+
+ return size;
+}
+
template<typename T> static bool adjust_params(int surfaceWidth,
int surfaceHeight,
size_t bpp,
« no previous file with comments | « src/gpu/GrResourceProvider.cpp ('k') | src/gpu/GrTexture.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698