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

Side by Side Diff: Source/core/html/canvas/WebGLVertexArrayObjectOES.cpp

Issue 365653002: Oilpan: move 2D Canvas and WebGL objects to the heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Complete VectorTraits<> specialization for VertexAttribState Created 6 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 13 matching lines...) Expand all
24 */ 24 */
25 25
26 #include "config.h" 26 #include "config.h"
27 27
28 #include "core/html/canvas/WebGLVertexArrayObjectOES.h" 28 #include "core/html/canvas/WebGLVertexArrayObjectOES.h"
29 29
30 #include "core/html/canvas/WebGLRenderingContextBase.h" 30 #include "core/html/canvas/WebGLRenderingContextBase.h"
31 31
32 namespace WebCore { 32 namespace WebCore {
33 33
34 PassRefPtr<WebGLVertexArrayObjectOES> WebGLVertexArrayObjectOES::create(WebGLRen deringContextBase* ctx, VaoType type) 34 PassRefPtrWillBeRawPtr<WebGLVertexArrayObjectOES> WebGLVertexArrayObjectOES::cre ate(WebGLRenderingContextBase* ctx, VaoType type)
35 { 35 {
36 return adoptRef(new WebGLVertexArrayObjectOES(ctx, type)); 36 return adoptRefWillBeNoop(new WebGLVertexArrayObjectOES(ctx, type));
37 } 37 }
38 38
39 WebGLVertexArrayObjectOES::WebGLVertexArrayObjectOES(WebGLRenderingContextBase* ctx, VaoType type) 39 WebGLVertexArrayObjectOES::WebGLVertexArrayObjectOES(WebGLRenderingContextBase* ctx, VaoType type)
40 : WebGLContextObject(ctx) 40 : WebGLContextObject(ctx)
41 , m_type(type) 41 , m_type(type)
42 , m_hasEverBeenBound(false) 42 , m_hasEverBeenBound(false)
43 , m_boundElementArrayBuffer(nullptr) 43 , m_boundElementArrayBuffer(nullptr)
44 { 44 {
45 ScriptWrappable::init(this); 45 ScriptWrappable::init(this);
46 m_vertexAttribState.resize(ctx->maxVertexAttribs()); 46 m_vertexAttribState.resize(ctx->maxVertexAttribs());
(...skipping 25 matching lines...) Expand all
72 if (m_boundElementArrayBuffer) 72 if (m_boundElementArrayBuffer)
73 m_boundElementArrayBuffer->onDetached(context3d); 73 m_boundElementArrayBuffer->onDetached(context3d);
74 74
75 for (size_t i = 0; i < m_vertexAttribState.size(); ++i) { 75 for (size_t i = 0; i < m_vertexAttribState.size(); ++i) {
76 VertexAttribState& state = m_vertexAttribState[i]; 76 VertexAttribState& state = m_vertexAttribState[i];
77 if (state.bufferBinding) 77 if (state.bufferBinding)
78 state.bufferBinding->onDetached(context3d); 78 state.bufferBinding->onDetached(context3d);
79 } 79 }
80 } 80 }
81 81
82 void WebGLVertexArrayObjectOES::setElementArrayBuffer(PassRefPtr<WebGLBuffer> bu ffer) 82 void WebGLVertexArrayObjectOES::setElementArrayBuffer(PassRefPtrWillBeRawPtr<Web GLBuffer> buffer)
83 { 83 {
84 if (buffer) 84 if (buffer)
85 buffer->onAttached(); 85 buffer->onAttached();
86 if (m_boundElementArrayBuffer) 86 if (m_boundElementArrayBuffer)
87 m_boundElementArrayBuffer->onDetached(context()->webContext()); 87 m_boundElementArrayBuffer->onDetached(context()->webContext());
88 m_boundElementArrayBuffer = buffer; 88 m_boundElementArrayBuffer = buffer;
89 89
90 } 90 }
91 91
92 void WebGLVertexArrayObjectOES::setVertexAttribState( 92 void WebGLVertexArrayObjectOES::setVertexAttribState(
93 GLuint index, GLsizei bytesPerElement, GLint size, GLenum type, GLboolean no rmalized, GLsizei stride, GLintptr offset, PassRefPtr<WebGLBuffer> buffer) 93 GLuint index, GLsizei bytesPerElement, GLint size, GLenum type, GLboolean no rmalized, GLsizei stride, GLintptr offset, PassRefPtrWillBeRawPtr<WebGLBuffer> b uffer)
94 { 94 {
95 GLsizei validatedStride = stride ? stride : bytesPerElement; 95 GLsizei validatedStride = stride ? stride : bytesPerElement;
96 96
97 VertexAttribState& state = m_vertexAttribState[index]; 97 VertexAttribState& state = m_vertexAttribState[index];
98 98
99 if (buffer) 99 if (buffer)
100 buffer->onAttached(); 100 buffer->onAttached();
101 if (state.bufferBinding) 101 if (state.bufferBinding)
102 state.bufferBinding->onDetached(context()->webContext()); 102 state.bufferBinding->onDetached(context()->webContext());
103 103
104 state.bufferBinding = buffer; 104 state.bufferBinding = buffer;
105 state.bytesPerElement = bytesPerElement; 105 state.bytesPerElement = bytesPerElement;
106 state.size = size; 106 state.size = size;
107 state.type = type; 107 state.type = type;
108 state.normalized = normalized; 108 state.normalized = normalized;
109 state.stride = validatedStride; 109 state.stride = validatedStride;
110 state.originalStride = stride; 110 state.originalStride = stride;
111 state.offset = offset; 111 state.offset = offset;
112 } 112 }
113 113
114 void WebGLVertexArrayObjectOES::unbindBuffer(PassRefPtr<WebGLBuffer> buffer) 114 void WebGLVertexArrayObjectOES::unbindBuffer(PassRefPtrWillBeRawPtr<WebGLBuffer> buffer)
115 { 115 {
116 if (m_boundElementArrayBuffer == buffer) { 116 if (m_boundElementArrayBuffer == buffer) {
117 m_boundElementArrayBuffer->onDetached(context()->webContext()); 117 m_boundElementArrayBuffer->onDetached(context()->webContext());
118 m_boundElementArrayBuffer = nullptr; 118 m_boundElementArrayBuffer = nullptr;
119 } 119 }
120 120
121 for (size_t i = 0; i < m_vertexAttribState.size(); ++i) { 121 for (size_t i = 0; i < m_vertexAttribState.size(); ++i) {
122 VertexAttribState& state = m_vertexAttribState[i]; 122 VertexAttribState& state = m_vertexAttribState[i];
123 if (state.bufferBinding == buffer) { 123 if (state.bufferBinding == buffer) {
124 buffer->onDetached(context()->webContext()); 124 buffer->onDetached(context()->webContext());
125 state.bufferBinding = nullptr; 125 state.bufferBinding = nullptr;
126 } 126 }
127 } 127 }
128 } 128 }
129 129
130 void WebGLVertexArrayObjectOES::setVertexAttribDivisor(GLuint index, GLuint divi sor) 130 void WebGLVertexArrayObjectOES::setVertexAttribDivisor(GLuint index, GLuint divi sor)
131 { 131 {
132 VertexAttribState& state = m_vertexAttribState[index]; 132 VertexAttribState& state = m_vertexAttribState[index];
133 state.divisor = divisor; 133 state.divisor = divisor;
134 } 134 }
135 135
136 void WebGLVertexArrayObjectOES::VertexAttribState::trace(Visitor* visitor)
137 {
138 visitor->trace(bufferBinding);
136 } 139 }
140
141 void WebGLVertexArrayObjectOES::trace(Visitor* visitor)
142 {
143 visitor->trace(m_boundElementArrayBuffer);
144 visitor->trace(m_vertexAttribState);
145 WebGLContextObject::trace(visitor);
146 }
147
148 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698