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

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

Issue 1419203002: Remove mac buffer impl war (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: tweaks Created 5 years, 1 month 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 | « include/gpu/gl/GrGLConfig.h ('k') | no next file » | 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
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 // assign a different allocation for the new contents to avoid 188 // assign a different allocation for the new contents to avoid
189 // flushing the gpu past draws consuming the old contents. 189 // flushing the gpu past draws consuming the old contents.
190 fGLSizeInBytes = fDesc.fSizeInBytes; 190 fGLSizeInBytes = fDesc.fSizeInBytes;
191 GL_CALL(gpu, BufferData(fBufferType, fGLSizeInBytes, nullptr, usage)); 191 GL_CALL(gpu, BufferData(fBufferType, fGLSizeInBytes, nullptr, usage));
192 GL_CALL(gpu, BufferSubData(fBufferType, 0, (GrGLsizeiptr) srcSizeInBytes , src)); 192 GL_CALL(gpu, BufferSubData(fBufferType, 0, (GrGLsizeiptr) srcSizeInBytes , src));
193 } 193 }
194 #else 194 #else
195 // Note that we're cheating on the size here. Currently no methods 195 // Note that we're cheating on the size here. Currently no methods
196 // allow a partial update that preserves contents of non-updated 196 // allow a partial update that preserves contents of non-updated
197 // portions of the buffer (map() does a glBufferData(..size, nullptr..)) 197 // portions of the buffer (map() does a glBufferData(..size, nullptr..))
198 bool doSubData = false; 198 fGLSizeInBytes = srcSizeInBytes;
199 #if GR_GL_MAC_BUFFER_OBJECT_PERFOMANCE_WORKAROUND 199 GL_CALL(gpu, BufferData(fBufferType, fGLSizeInBytes, src, usage));
200 static int N = 0;
201 // 128 was chosen experimentally. At 256 a slight hitchiness was noticed
202 // when dragging a Chromium window around with a canvas tab backgrounded.
203 doSubData = 0 == (N % 128);
204 ++N;
205 #endif
206 if (doSubData) {
207 // The workaround is to do a glBufferData followed by glBufferSubData.
208 // Chromium's command buffer may turn a glBufferSubData where the size
209 // exactly matches the buffer size into a glBufferData. So we tack 1
210 // extra byte onto the glBufferData.
211 fGLSizeInBytes = srcSizeInBytes + 1;
212 GL_CALL(gpu, BufferData(fBufferType, fGLSizeInBytes, nullptr, usage));
213 GL_CALL(gpu, BufferSubData(fBufferType, 0, srcSizeInBytes, src));
214 } else {
215 fGLSizeInBytes = srcSizeInBytes;
216 GL_CALL(gpu, BufferData(fBufferType, fGLSizeInBytes, src, usage));
217 }
218 #endif 200 #endif
219 return true; 201 return true;
220 } 202 }
221 203
222 void GrGLBufferImpl::validate() const { 204 void GrGLBufferImpl::validate() const {
223 SkASSERT(GR_GL_ARRAY_BUFFER == fBufferType || GR_GL_ELEMENT_ARRAY_BUFFER == fBufferType); 205 SkASSERT(GR_GL_ARRAY_BUFFER == fBufferType || GR_GL_ELEMENT_ARRAY_BUFFER == fBufferType);
224 // The following assert isn't valid when the buffer has been abandoned: 206 // The following assert isn't valid when the buffer has been abandoned:
225 // SkASSERT((0 == fDesc.fID) == (fCPUData)); 207 // SkASSERT((0 == fDesc.fID) == (fCPUData));
226 SkASSERT(nullptr == fCPUData || 0 == fGLSizeInBytes); 208 SkASSERT(nullptr == fCPUData || 0 == fGLSizeInBytes);
227 SkASSERT(nullptr == fMapPtr || fCPUData || fGLSizeInBytes == fDesc.fSizeInBy tes); 209 SkASSERT(nullptr == fMapPtr || fCPUData || fGLSizeInBytes == fDesc.fSizeInBy tes);
228 SkASSERT(nullptr == fCPUData || nullptr == fMapPtr || fCPUData == fMapPtr); 210 SkASSERT(nullptr == fCPUData || nullptr == fMapPtr || fCPUData == fMapPtr);
229 } 211 }
OLDNEW
« no previous file with comments | « include/gpu/gl/GrGLConfig.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698