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

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

Issue 12843026: Make GrDrawTarget::Caps ref counted and GrGLCaps derive from it. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 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 unified diff | Download patch | Annotate | Revision Log
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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 GrAssert(GR_GL_ELEMENT_ARRAY_BUFFER == fBufferType); 67 GrAssert(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 GrAssert(!this->isLocked());
75 if (0 == fDesc.fID) { 75 if (0 == fDesc.fID) {
76 fLockPtr = fCPUData; 76 fLockPtr = fCPUData;
77 } else if (gpu->getCaps().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 GrAssert(this->isLocked());
94 if (0 != fDesc.fID) { 94 if (0 != fDesc.fID) {
95 GrAssert(gpu->getCaps().bufferLockSupport()); 95 GrAssert(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 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 GrAssert(GR_GL_ARRAY_BUFFER == fBufferType || GR_GL_ELEMENT_ARRAY_BUFFER == fBufferType);
161 GrAssert((0 == fDesc.fID) == (NULL != fCPUData)); 161 GrAssert((0 == fDesc.fID) == (NULL != fCPUData));
162 GrAssert(0 != fDesc.fID || !fDesc.fIsWrapped); 162 GrAssert(0 != fDesc.fID || !fDesc.fIsWrapped);
163 GrAssert(NULL == fCPUData || NULL == fLockPtr || fCPUData == fLockPtr); 163 GrAssert(NULL == fCPUData || NULL == fLockPtr || fCPUData == fLockPtr);
164 } 164 }
OLDNEW
« no previous file with comments | « src/gpu/GrTexture.cpp ('k') | src/gpu/gl/GrGLCaps.h » ('j') | src/gpu/gl/GrGLContext.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698