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

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

Issue 1144433002: Move copy-surface-as-draw fallback to GrGLGpu. (Closed) Base URL: https://skia.googlesource.com/skia.git@vares
Patch Set: remove incorrect assert Created 5 years, 7 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/gl/builders/GrGLFragmentShaderBuilder.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 "GrGLVertexArray.h" 8 #include "GrGLVertexArray.h"
9 #include "GrGLGpu.h" 9 #include "GrGLGpu.h"
10 10
11 11
12 void GrGLAttribArrayState::set(const GrGLGpu* gpu, 12
13 void GrGLAttribArrayState::set(GrGLGpu* gpu,
13 int index, 14 int index,
14 GrGLVertexBuffer* buffer, 15 GrGLuint vertexBufferID,
15 GrGLint size, 16 GrGLint size,
16 GrGLenum type, 17 GrGLenum type,
17 GrGLboolean normalized, 18 GrGLboolean normalized,
18 GrGLsizei stride, 19 GrGLsizei stride,
19 GrGLvoid* offset) { 20 GrGLvoid* offset) {
20 SkASSERT(index >= 0 && index < fAttribArrayStates.count()); 21 SkASSERT(index >= 0 && index < fAttribArrayStates.count());
21 AttribArrayState* array = &fAttribArrayStates[index]; 22 AttribArrayState* array = &fAttribArrayStates[index];
22 if (!array->fEnableIsValid || !array->fEnabled) { 23 if (!array->fEnableIsValid || !array->fEnabled) {
23 GR_GL_CALL(gpu->glInterface(), EnableVertexAttribArray(index)); 24 GR_GL_CALL(gpu->glInterface(), EnableVertexAttribArray(index));
24 array->fEnableIsValid = true; 25 array->fEnableIsValid = true;
25 array->fEnabled = true; 26 array->fEnabled = true;
26 } 27 }
27 if (!array->fAttribPointerIsValid || 28 if (!array->fAttribPointerIsValid ||
28 array->fVertexBufferID != buffer->bufferID() || 29 array->fVertexBufferID != vertexBufferID ||
29 array->fSize != size || 30 array->fSize != size ||
30 array->fNormalized != normalized || 31 array->fNormalized != normalized ||
31 array->fStride != stride || 32 array->fStride != stride ||
32 array->fOffset != offset) { 33 array->fOffset != offset) {
33 34
34 buffer->bind(); 35 gpu->bindVertexBuffer(vertexBufferID);
35 GR_GL_CALL(gpu->glInterface(), VertexAttribPointer(index, 36 GR_GL_CALL(gpu->glInterface(), VertexAttribPointer(index,
36 size, 37 size,
37 type, 38 type,
38 normalized, 39 normalized,
39 stride, 40 stride,
40 offset)); 41 offset));
41 array->fAttribPointerIsValid = true; 42 array->fAttribPointerIsValid = true;
42 array->fVertexBufferID = buffer->bufferID(); 43 array->fVertexBufferID = vertexBufferID;
43 array->fSize = size; 44 array->fSize = size;
44 array->fNormalized = normalized; 45 array->fNormalized = normalized;
45 array->fStride = stride; 46 array->fStride = stride;
46 array->fOffset = offset; 47 array->fOffset = offset;
47 } 48 }
48 } 49 }
49 50
50 void GrGLAttribArrayState::disableUnusedArrays(const GrGLGpu* gpu, uint64_t used Mask) { 51 void GrGLAttribArrayState::disableUnusedArrays(const GrGLGpu* gpu, uint64_t used Mask) {
51 int count = fAttribArrayStates.count(); 52 int count = fAttribArrayStates.count();
52 for (int i = 0; i < count; ++i) { 53 for (int i = 0; i < count; ++i) {
(...skipping 20 matching lines...) Expand all
73 } 74 }
74 75
75 GrGLAttribArrayState* GrGLVertexArray::bind(GrGLGpu* gpu) { 76 GrGLAttribArrayState* GrGLVertexArray::bind(GrGLGpu* gpu) {
76 if (0 == fID) { 77 if (0 == fID) {
77 return NULL; 78 return NULL;
78 } 79 }
79 gpu->bindVertexArray(fID); 80 gpu->bindVertexArray(fID);
80 return &fAttribArrays; 81 return &fAttribArrays;
81 } 82 }
82 83
83 GrGLAttribArrayState* GrGLVertexArray::bindWithIndexBuffer(GrGLGpu* gpu, 84 GrGLAttribArrayState* GrGLVertexArray::bindWithIndexBuffer(GrGLGpu* gpu, GrGLuin t ibufferID) {
84 const GrGLIndexBuffer * buffer) {
85 GrGLAttribArrayState* state = this->bind(gpu); 85 GrGLAttribArrayState* state = this->bind(gpu);
86 if (state && buffer) { 86 if (state) {
87 GrGLuint bufferID = buffer->bufferID(); 87 if (!fIndexBufferIDIsValid || ibufferID != fIndexBufferID) {
88 if (!fIndexBufferIDIsValid || bufferID != fIndexBufferID) { 88 GR_GL_CALL(gpu->glInterface(), BindBuffer(GR_GL_ELEMENT_ARRAY_BUFFER , ibufferID));
89 GR_GL_CALL(gpu->glInterface(), BindBuffer(GR_GL_ELEMENT_ARRAY_BUFFER , bufferID));
90 fIndexBufferIDIsValid = true; 89 fIndexBufferIDIsValid = true;
91 fIndexBufferID = bufferID; 90 fIndexBufferID = ibufferID;
92 } 91 }
93 } 92 }
94 return state; 93 return state;
95 } 94 }
96 95
97 void GrGLVertexArray::notifyIndexBufferDelete(GrGLuint bufferID) { 96 void GrGLVertexArray::notifyIndexBufferDelete(GrGLuint bufferID) {
98 if (fIndexBufferIDIsValid && bufferID == fIndexBufferID) { 97 if (fIndexBufferIDIsValid && bufferID == fIndexBufferID) {
99 fIndexBufferID = 0; 98 fIndexBufferID = 0;
100 } 99 }
101 } 100 }
102 101
103 void GrGLVertexArray::invalidateCachedState() { 102 void GrGLVertexArray::invalidateCachedState() {
104 fAttribArrays.invalidate(); 103 fAttribArrays.invalidate();
105 fIndexBufferIDIsValid = false; 104 fIndexBufferIDIsValid = false;
106 } 105 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLVertexArray.h ('k') | src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698