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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « src/gpu/GrResourceProvider.cpp ('k') | src/gpu/GrTexture.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "GrSurfacePriv.h" 9 #include "GrSurfacePriv.h"
10 10
11 #include "SkBitmap.h" 11 #include "SkBitmap.h"
12 #include "SkGr.h" 12 #include "SkGr.h"
13 #include "SkImageEncoder.h" 13 #include "SkImageEncoder.h"
14 #include <stdio.h> 14 #include <stdio.h>
15 15
16 size_t GrSurface::WorseCaseSize(const GrSurfaceDesc& desc) {
17 size_t size;
18
19 bool isRenderTarget = SkToBool(desc.fFlags & kRenderTarget_GrSurfaceFlag);
20 if (isRenderTarget) {
21 // We own one color value for each MSAA sample.
22 int colorValuesPerPixel = SkTMax(1, desc.fSampleCnt);
23 if (desc.fSampleCnt) {
24 // Worse case, we own the resolve buffer so that is one more sample per pixel.
25 colorValuesPerPixel += 1;
26 }
27 SkASSERT(kUnknown_GrPixelConfig != desc.fConfig);
28 SkASSERT(!GrPixelConfigIsCompressed(desc.fConfig));
29 size_t colorBytes = GrBytesPerPixel(desc.fConfig);
30 SkASSERT(colorBytes > 0);
31 size = colorValuesPerPixel * desc.fWidth * desc.fHeight * colorBytes;
32 } else {
33 if (GrPixelConfigIsCompressed(desc.fConfig)) {
34 size = GrCompressedFormatDataSize(desc.fConfig, desc.fWidth, desc.fH eight);
35 } else {
36 size = (size_t) desc.fWidth * desc.fHeight * GrBytesPerPixel(desc.fC onfig);
37 }
38
39 size += size/3; // in case we have to mipmap
40 }
41
42 return size;
43 }
44
16 template<typename T> static bool adjust_params(int surfaceWidth, 45 template<typename T> static bool adjust_params(int surfaceWidth,
17 int surfaceHeight, 46 int surfaceHeight,
18 size_t bpp, 47 size_t bpp,
19 int* left, int* top, int* width, int* height, 48 int* left, int* top, int* width, int* height,
20 T** data, 49 T** data,
21 size_t* rowBytes) { 50 size_t* rowBytes) {
22 if (!*rowBytes) { 51 if (!*rowBytes) {
23 *rowBytes = *width * bpp; 52 *rowBytes = *width * bpp;
24 } 53 }
25 54
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 202
174 void GrSurface::onRelease() { 203 void GrSurface::onRelease() {
175 this->invokeReleaseProc(); 204 this->invokeReleaseProc();
176 this->INHERITED::onRelease(); 205 this->INHERITED::onRelease();
177 } 206 }
178 207
179 void GrSurface::onAbandon() { 208 void GrSurface::onAbandon() {
180 this->invokeReleaseProc(); 209 this->invokeReleaseProc();
181 this->INHERITED::onAbandon(); 210 this->INHERITED::onAbandon();
182 } 211 }
OLDNEW
« 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