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

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

Issue 2143333002: Add resource provider flag to avoid client-side buffers (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add resource provider flag to avoid client-side buffers Created 4 years, 5 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/gl/GrGLVertexArray.h ('k') | src/gpu/instanced/GLInstancedRendering.h » ('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 "GrGLVertexArray.h" 8 #include "GrGLVertexArray.h"
9 #include "GrGLBuffer.h" 9 #include "GrGLBuffer.h"
10 #include "GrGLGpu.h" 10 #include "GrGLGpu.h"
(...skipping 21 matching lines...) Expand all
32 GR_STATIC_ASSERT(2 == kVec3f_GrVertexAttribType); 32 GR_STATIC_ASSERT(2 == kVec3f_GrVertexAttribType);
33 GR_STATIC_ASSERT(3 == kVec4f_GrVertexAttribType); 33 GR_STATIC_ASSERT(3 == kVec4f_GrVertexAttribType);
34 GR_STATIC_ASSERT(4 == kUByte_GrVertexAttribType); 34 GR_STATIC_ASSERT(4 == kUByte_GrVertexAttribType);
35 GR_STATIC_ASSERT(5 == kVec4ub_GrVertexAttribType); 35 GR_STATIC_ASSERT(5 == kVec4ub_GrVertexAttribType);
36 GR_STATIC_ASSERT(6 == kVec2us_GrVertexAttribType); 36 GR_STATIC_ASSERT(6 == kVec2us_GrVertexAttribType);
37 GR_STATIC_ASSERT(7 == kInt_GrVertexAttribType); 37 GR_STATIC_ASSERT(7 == kInt_GrVertexAttribType);
38 GR_STATIC_ASSERT(8 == kUint_GrVertexAttribType); 38 GR_STATIC_ASSERT(8 == kUint_GrVertexAttribType);
39 39
40 void GrGLAttribArrayState::set(GrGLGpu* gpu, 40 void GrGLAttribArrayState::set(GrGLGpu* gpu,
41 int index, 41 int index,
42 const GrGLBuffer* vertexBuffer, 42 const GrBuffer* vertexBuffer,
43 GrVertexAttribType type, 43 GrVertexAttribType type,
44 GrGLsizei stride, 44 GrGLsizei stride,
45 GrGLvoid* offset) { 45 GrGLvoid* offset) {
46 SkASSERT(index >= 0 && index < fAttribArrayStates.count()); 46 SkASSERT(index >= 0 && index < fAttribArrayStates.count());
47 AttribArrayState* array = &fAttribArrayStates[index]; 47 AttribArrayState* array = &fAttribArrayStates[index];
48 if (!array->fEnableIsValid || !array->fEnabled) { 48 if (!array->fEnableIsValid || !array->fEnabled) {
49 GR_GL_CALL(gpu->glInterface(), EnableVertexAttribArray(index)); 49 GR_GL_CALL(gpu->glInterface(), EnableVertexAttribArray(index));
50 array->fEnableIsValid = true; 50 array->fEnableIsValid = true;
51 array->fEnabled = true; 51 array->fEnabled = true;
52 } 52 }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 } 105 }
106 106
107 GrGLAttribArrayState* GrGLVertexArray::bind(GrGLGpu* gpu) { 107 GrGLAttribArrayState* GrGLVertexArray::bind(GrGLGpu* gpu) {
108 if (0 == fID) { 108 if (0 == fID) {
109 return nullptr; 109 return nullptr;
110 } 110 }
111 gpu->bindVertexArray(fID); 111 gpu->bindVertexArray(fID);
112 return &fAttribArrays; 112 return &fAttribArrays;
113 } 113 }
114 114
115 GrGLAttribArrayState* GrGLVertexArray::bindWithIndexBuffer(GrGLGpu* gpu, const G rGLBuffer* ibuff) { 115 GrGLAttribArrayState* GrGLVertexArray::bindWithIndexBuffer(GrGLGpu* gpu, const G rBuffer* ibuff) {
116 GrGLAttribArrayState* state = this->bind(gpu); 116 GrGLAttribArrayState* state = this->bind(gpu);
117 if (state && fIndexBufferUniqueID != ibuff->getUniqueID()) { 117 if (state && fIndexBufferUniqueID != ibuff->getUniqueID()) {
118 GR_GL_CALL(gpu->glInterface(), BindBuffer(GR_GL_ELEMENT_ARRAY_BUFFER, ib uff->bufferID())); 118 if (ibuff->isCPUBacked()) {
119 GR_GL_CALL(gpu->glInterface(), BindBuffer(GR_GL_ELEMENT_ARRAY_BUFFER , 0));
120 } else {
121 const GrGLBuffer* glBuffer = static_cast<const GrGLBuffer*>(ibuff);
122 GR_GL_CALL(gpu->glInterface(), BindBuffer(GR_GL_ELEMENT_ARRAY_BUFFER ,
123 glBuffer->bufferID()));
124 }
119 fIndexBufferUniqueID = ibuff->getUniqueID(); 125 fIndexBufferUniqueID = ibuff->getUniqueID();
120 } 126 }
121 return state; 127 return state;
122 } 128 }
123 129
124 void GrGLVertexArray::invalidateCachedState() { 130 void GrGLVertexArray::invalidateCachedState() {
125 fAttribArrays.invalidate(); 131 fAttribArrays.invalidate();
126 fIndexBufferUniqueID = SK_InvalidUniqueID; 132 fIndexBufferUniqueID = SK_InvalidUniqueID;
127 } 133 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLVertexArray.h ('k') | src/gpu/instanced/GLInstancedRendering.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698