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

Side by Side Diff: src/gpu/gl/GrGLBufferImpl.cpp

Issue 1300123002: Use calloc to allocate data that will be uploaded to vertex/index buffers in Chrome (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Address comment 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/GrCaps.cpp ('k') | src/gpu/gl/GrGLCaps.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 2013 Google Inc. 2 * Copyright 2013 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 "GrGLBufferImpl.h" 8 #include "GrGLBufferImpl.h"
9 #include "GrGLGpu.h" 9 #include "GrGLGpu.h"
10 10
11 #define GL_CALL(GPU, X) GR_GL_CALL(GPU->glInterface(), X) 11 #define GL_CALL(GPU, X) GR_GL_CALL(GPU->glInterface(), X)
12 12
13 #ifdef SK_DEBUG 13 #ifdef SK_DEBUG
14 #define VALIDATE() this->validate() 14 #define VALIDATE() this->validate()
15 #else 15 #else
16 #define VALIDATE() do {} while(false) 16 #define VALIDATE() do {} while(false)
17 #endif 17 #endif
18 18
19 // GL_STREAM_DRAW triggers an optimization in Chromium's GPU process where a cli ent's vertex buffer 19 // GL_STREAM_DRAW triggers an optimization in Chromium's GPU process where a cli ent's vertex buffer
20 // objects are implemented as client-side-arrays on tile-deferred architectures. 20 // objects are implemented as client-side-arrays on tile-deferred architectures.
21 #define DYNAMIC_USAGE_PARAM GR_GL_STREAM_DRAW 21 #define DYNAMIC_USAGE_PARAM GR_GL_STREAM_DRAW
22 22
23 GrGLBufferImpl::GrGLBufferImpl(GrGLGpu* gpu, const Desc& desc, GrGLenum bufferTy pe) 23 GrGLBufferImpl::GrGLBufferImpl(GrGLGpu* gpu, const Desc& desc, GrGLenum bufferTy pe)
24 : fDesc(desc) 24 : fDesc(desc)
25 , fBufferType(bufferType) 25 , fBufferType(bufferType)
26 , fMapPtr(NULL) { 26 , fMapPtr(NULL) {
27 if (0 == desc.fID) { 27 if (0 == desc.fID) {
28 fCPUData = sk_malloc_flags(desc.fSizeInBytes, SK_MALLOC_THROW); 28 if (gpu->caps()->mustClearUploadedBufferData()) {
29 fCPUData = sk_calloc_throw(desc.fSizeInBytes);
30 } else {
31 fCPUData = sk_malloc_flags(desc.fSizeInBytes, SK_MALLOC_THROW);
32 }
29 fGLSizeInBytes = 0; 33 fGLSizeInBytes = 0;
30 } else { 34 } else {
31 fCPUData = NULL; 35 fCPUData = NULL;
32 // We assume that the GL buffer was created at the desc's size initially . 36 // We assume that the GL buffer was created at the desc's size initially .
33 fGLSizeInBytes = fDesc.fSizeInBytes; 37 fGLSizeInBytes = fDesc.fSizeInBytes;
34 } 38 }
35 VALIDATE(); 39 VALIDATE();
36 } 40 }
37 41
38 void GrGLBufferImpl::release(GrGLGpu* gpu) { 42 void GrGLBufferImpl::release(GrGLGpu* gpu) {
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 } 220 }
217 221
218 void GrGLBufferImpl::validate() const { 222 void GrGLBufferImpl::validate() const {
219 SkASSERT(GR_GL_ARRAY_BUFFER == fBufferType || GR_GL_ELEMENT_ARRAY_BUFFER == fBufferType); 223 SkASSERT(GR_GL_ARRAY_BUFFER == fBufferType || GR_GL_ELEMENT_ARRAY_BUFFER == fBufferType);
220 // The following assert isn't valid when the buffer has been abandoned: 224 // The following assert isn't valid when the buffer has been abandoned:
221 // SkASSERT((0 == fDesc.fID) == (fCPUData)); 225 // SkASSERT((0 == fDesc.fID) == (fCPUData));
222 SkASSERT(NULL == fCPUData || 0 == fGLSizeInBytes); 226 SkASSERT(NULL == fCPUData || 0 == fGLSizeInBytes);
223 SkASSERT(NULL == fMapPtr || fCPUData || fGLSizeInBytes == fDesc.fSizeInBytes ); 227 SkASSERT(NULL == fMapPtr || fCPUData || fGLSizeInBytes == fDesc.fSizeInBytes );
224 SkASSERT(NULL == fCPUData || NULL == fMapPtr || fCPUData == fMapPtr); 228 SkASSERT(NULL == fCPUData || NULL == fMapPtr || fCPUData == fMapPtr);
225 } 229 }
OLDNEW
« no previous file with comments | « src/gpu/GrCaps.cpp ('k') | src/gpu/gl/GrGLCaps.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698