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

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

Issue 22850006: Replace uses of GrAssert by SkASSERT. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: rebase Created 7 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 | Annotate | Revision Log
« no previous file with comments | « src/gpu/gl/GrGLBufferImpl.h ('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 "GrGpuGL.h" 9 #include "GrGpuGL.h"
10 10
(...skipping 26 matching lines...) Expand all
37 if (NULL != fCPUData) { 37 if (NULL != fCPUData) {
38 VALIDATE(); 38 VALIDATE();
39 sk_free(fCPUData); 39 sk_free(fCPUData);
40 fCPUData = NULL; 40 fCPUData = NULL;
41 } else if (fDesc.fID && !fDesc.fIsWrapped) { 41 } else if (fDesc.fID && !fDesc.fIsWrapped) {
42 VALIDATE(); 42 VALIDATE();
43 GL_CALL(gpu, DeleteBuffers(1, &fDesc.fID)); 43 GL_CALL(gpu, DeleteBuffers(1, &fDesc.fID));
44 if (GR_GL_ARRAY_BUFFER == fBufferType) { 44 if (GR_GL_ARRAY_BUFFER == fBufferType) {
45 gpu->notifyVertexBufferDelete(fDesc.fID); 45 gpu->notifyVertexBufferDelete(fDesc.fID);
46 } else { 46 } else {
47 GrAssert(GR_GL_ELEMENT_ARRAY_BUFFER == fBufferType); 47 SkASSERT(GR_GL_ELEMENT_ARRAY_BUFFER == fBufferType);
48 gpu->notifyIndexBufferDelete(fDesc.fID); 48 gpu->notifyIndexBufferDelete(fDesc.fID);
49 } 49 }
50 fDesc.fID = 0; 50 fDesc.fID = 0;
51 } 51 }
52 fLockPtr = NULL; 52 fLockPtr = NULL;
53 } 53 }
54 54
55 void GrGLBufferImpl::abandon() { 55 void GrGLBufferImpl::abandon() {
56 fDesc.fID = 0; 56 fDesc.fID = 0;
57 fLockPtr = NULL; 57 fLockPtr = NULL;
58 sk_free(fCPUData); 58 sk_free(fCPUData);
59 fCPUData = NULL; 59 fCPUData = NULL;
60 } 60 }
61 61
62 void GrGLBufferImpl::bind(GrGpuGL* gpu) const { 62 void GrGLBufferImpl::bind(GrGpuGL* gpu) const {
63 VALIDATE(); 63 VALIDATE();
64 if (GR_GL_ARRAY_BUFFER == fBufferType) { 64 if (GR_GL_ARRAY_BUFFER == fBufferType) {
65 gpu->bindVertexBuffer(fDesc.fID); 65 gpu->bindVertexBuffer(fDesc.fID);
66 } else { 66 } else {
67 GrAssert(GR_GL_ELEMENT_ARRAY_BUFFER == fBufferType); 67 SkASSERT(GR_GL_ELEMENT_ARRAY_BUFFER == fBufferType);
68 gpu->bindIndexBufferAndDefaultVertexArray(fDesc.fID); 68 gpu->bindIndexBufferAndDefaultVertexArray(fDesc.fID);
69 } 69 }
70 } 70 }
71 71
72 void* GrGLBufferImpl::lock(GrGpuGL* gpu) { 72 void* GrGLBufferImpl::lock(GrGpuGL* gpu) {
73 VALIDATE(); 73 VALIDATE();
74 GrAssert(!this->isLocked()); 74 SkASSERT(!this->isLocked());
75 if (0 == fDesc.fID) { 75 if (0 == fDesc.fID) {
76 fLockPtr = fCPUData; 76 fLockPtr = fCPUData;
77 } else if (gpu->caps()->bufferLockSupport()) { 77 } else if (gpu->caps()->bufferLockSupport()) {
78 this->bind(gpu); 78 this->bind(gpu);
79 // Let driver know it can discard the old data 79 // Let driver know it can discard the old data
80 GL_CALL(gpu, BufferData(fBufferType, 80 GL_CALL(gpu, BufferData(fBufferType,
81 fDesc.fSizeInBytes, 81 fDesc.fSizeInBytes,
82 NULL, 82 NULL,
83 fDesc.fDynamic ? DYNAMIC_USAGE_PARAM : GR_GL_STA TIC_DRAW)); 83 fDesc.fDynamic ? DYNAMIC_USAGE_PARAM : GR_GL_STA TIC_DRAW));
84 GR_GL_CALL_RET(gpu->glInterface(), 84 GR_GL_CALL_RET(gpu->glInterface(),
85 fLockPtr, 85 fLockPtr,
86 MapBuffer(fBufferType, GR_GL_WRITE_ONLY)); 86 MapBuffer(fBufferType, GR_GL_WRITE_ONLY));
87 } 87 }
88 return fLockPtr; 88 return fLockPtr;
89 } 89 }
90 90
91 void GrGLBufferImpl::unlock(GrGpuGL* gpu) { 91 void GrGLBufferImpl::unlock(GrGpuGL* gpu) {
92 VALIDATE(); 92 VALIDATE();
93 GrAssert(this->isLocked()); 93 SkASSERT(this->isLocked());
94 if (0 != fDesc.fID) { 94 if (0 != fDesc.fID) {
95 GrAssert(gpu->caps()->bufferLockSupport()); 95 SkASSERT(gpu->caps()->bufferLockSupport());
96 this->bind(gpu); 96 this->bind(gpu);
97 GL_CALL(gpu, UnmapBuffer(fBufferType)); 97 GL_CALL(gpu, UnmapBuffer(fBufferType));
98 } 98 }
99 fLockPtr = NULL; 99 fLockPtr = NULL;
100 } 100 }
101 101
102 bool GrGLBufferImpl::isLocked() const { 102 bool GrGLBufferImpl::isLocked() const {
103 VALIDATE(); 103 VALIDATE();
104 return NULL != fLockPtr; 104 return NULL != fLockPtr;
105 } 105 }
106 106
107 bool GrGLBufferImpl::updateData(GrGpuGL* gpu, const void* src, size_t srcSizeInB ytes) { 107 bool GrGLBufferImpl::updateData(GrGpuGL* gpu, const void* src, size_t srcSizeInB ytes) {
108 GrAssert(!this->isLocked()); 108 SkASSERT(!this->isLocked());
109 VALIDATE(); 109 VALIDATE();
110 if (srcSizeInBytes > fDesc.fSizeInBytes) { 110 if (srcSizeInBytes > fDesc.fSizeInBytes) {
111 return false; 111 return false;
112 } 112 }
113 if (0 == fDesc.fID) { 113 if (0 == fDesc.fID) {
114 memcpy(fCPUData, src, srcSizeInBytes); 114 memcpy(fCPUData, src, srcSizeInBytes);
115 return true; 115 return true;
116 } 116 }
117 this->bind(gpu); 117 this->bind(gpu);
118 GrGLenum usage = fDesc.fDynamic ? DYNAMIC_USAGE_PARAM : GR_GL_STATIC_DRAW; 118 GrGLenum usage = fDesc.fDynamic ? DYNAMIC_USAGE_PARAM : GR_GL_STATIC_DRAW;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 GL_CALL(gpu, BufferData(fBufferType, srcSizeInBytes + 1, NULL, usage)); 150 GL_CALL(gpu, BufferData(fBufferType, srcSizeInBytes + 1, NULL, usage));
151 GL_CALL(gpu, BufferSubData(fBufferType, 0, srcSizeInBytes, src)); 151 GL_CALL(gpu, BufferSubData(fBufferType, 0, srcSizeInBytes, src));
152 } else { 152 } else {
153 GL_CALL(gpu, BufferData(fBufferType, srcSizeInBytes, src, usage)); 153 GL_CALL(gpu, BufferData(fBufferType, srcSizeInBytes, src, usage));
154 } 154 }
155 #endif 155 #endif
156 return true; 156 return true;
157 } 157 }
158 158
159 void GrGLBufferImpl::validate() const { 159 void GrGLBufferImpl::validate() const {
160 GrAssert(GR_GL_ARRAY_BUFFER == fBufferType || GR_GL_ELEMENT_ARRAY_BUFFER == fBufferType); 160 SkASSERT(GR_GL_ARRAY_BUFFER == fBufferType || GR_GL_ELEMENT_ARRAY_BUFFER == fBufferType);
161 // The following assert isn't valid when the buffer has been abandoned: 161 // The following assert isn't valid when the buffer has been abandoned:
162 // GrAssert((0 == fDesc.fID) == (NULL != fCPUData)); 162 // SkASSERT((0 == fDesc.fID) == (NULL != fCPUData));
163 GrAssert(0 != fDesc.fID || !fDesc.fIsWrapped); 163 SkASSERT(0 != fDesc.fID || !fDesc.fIsWrapped);
164 GrAssert(NULL == fCPUData || NULL == fLockPtr || fCPUData == fLockPtr); 164 SkASSERT(NULL == fCPUData || NULL == fLockPtr || fCPUData == fLockPtr);
165 } 165 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLBufferImpl.h ('k') | src/gpu/gl/GrGLCaps.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698