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

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: Have Nullable<T>::trace() use TraceIfNeeded<>. 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());
47 47
48 switch (m_type) { 48 switch (m_type) {
49 case VaoTypeDefault: 49 case VaoTypeDefault:
50 break; 50 break;
51 default: 51 default:
52 setObject(context()->webContext()->createVertexArrayOES()); 52 setObject(context()->webContext()->createVertexArrayOES());
53 break; 53 break;
54 } 54 }
55 } 55 }
56 56
57 WebGLVertexArrayObjectOES::~WebGLVertexArrayObjectOES() 57 WebGLVertexArrayObjectOES::~WebGLVertexArrayObjectOES()
58 { 58 {
59 deleteObject(0); 59 #if ENABLE(OILPAN)
60 m_boundElementArrayBuffer = nullptr;
61 m_vertexAttribState.clear();
62 #endif
63 detachAndDeleteObject();
Ken Russell (switch to Gerrit) 2014/07/19 00:27:16 Please add a comment about the need to manually ca
sof 2014/07/19 19:55:57 Added
60 } 64 }
61 65
62 void WebGLVertexArrayObjectOES::deleteObjectImpl(blink::WebGraphicsContext3D* co ntext3d, Platform3DObject object) 66 void WebGLVertexArrayObjectOES::deleteObjectImpl(blink::WebGraphicsContext3D* co ntext3d, Platform3DObject object)
63 { 67 {
64 switch (m_type) { 68 switch (m_type) {
65 case VaoTypeDefault: 69 case VaoTypeDefault:
66 break; 70 break;
67 default: 71 default:
68 context()->webContext()->deleteVertexArrayOES(object); 72 context3d->deleteVertexArrayOES(object);
69 break; 73 break;
70 } 74 }
71 75
72 if (m_boundElementArrayBuffer) 76 if (m_boundElementArrayBuffer)
73 m_boundElementArrayBuffer->onDetached(context3d); 77 m_boundElementArrayBuffer->onDetached(context3d);
74 78
75 for (size_t i = 0; i < m_vertexAttribState.size(); ++i) { 79 for (size_t i = 0; i < m_vertexAttribState.size(); ++i) {
76 VertexAttribState& state = m_vertexAttribState[i]; 80 VertexAttribState& state = m_vertexAttribState[i];
77 if (state.bufferBinding) 81 if (state.bufferBinding)
78 state.bufferBinding->onDetached(context3d); 82 state.bufferBinding->onDetached(context3d);
79 } 83 }
80 } 84 }
81 85
82 void WebGLVertexArrayObjectOES::setElementArrayBuffer(PassRefPtr<WebGLBuffer> bu ffer) 86 void WebGLVertexArrayObjectOES::setElementArrayBuffer(PassRefPtrWillBeRawPtr<Web GLBuffer> buffer)
83 { 87 {
84 if (buffer) 88 if (buffer)
85 buffer->onAttached(); 89 buffer->onAttached();
86 if (m_boundElementArrayBuffer) 90 if (m_boundElementArrayBuffer)
87 m_boundElementArrayBuffer->onDetached(context()->webContext()); 91 m_boundElementArrayBuffer->onDetached(context()->webContext());
88 m_boundElementArrayBuffer = buffer; 92 m_boundElementArrayBuffer = buffer;
89
90 } 93 }
91 94
92 void WebGLVertexArrayObjectOES::setVertexAttribState( 95 void WebGLVertexArrayObjectOES::setVertexAttribState(
93 GLuint index, GLsizei bytesPerElement, GLint size, GLenum type, GLboolean no rmalized, GLsizei stride, GLintptr offset, PassRefPtr<WebGLBuffer> buffer) 96 GLuint index, GLsizei bytesPerElement, GLint size, GLenum type, GLboolean no rmalized, GLsizei stride, GLintptr offset, PassRefPtrWillBeRawPtr<WebGLBuffer> b uffer)
94 { 97 {
95 GLsizei validatedStride = stride ? stride : bytesPerElement; 98 GLsizei validatedStride = stride ? stride : bytesPerElement;
96 99
97 VertexAttribState& state = m_vertexAttribState[index]; 100 VertexAttribState& state = m_vertexAttribState[index];
98 101
99 if (buffer) 102 if (buffer)
100 buffer->onAttached(); 103 buffer->onAttached();
101 if (state.bufferBinding) 104 if (state.bufferBinding)
102 state.bufferBinding->onDetached(context()->webContext()); 105 state.bufferBinding->onDetached(context()->webContext());
103 106
104 state.bufferBinding = buffer; 107 state.bufferBinding = buffer;
105 state.bytesPerElement = bytesPerElement; 108 state.bytesPerElement = bytesPerElement;
106 state.size = size; 109 state.size = size;
107 state.type = type; 110 state.type = type;
108 state.normalized = normalized; 111 state.normalized = normalized;
109 state.stride = validatedStride; 112 state.stride = validatedStride;
110 state.originalStride = stride; 113 state.originalStride = stride;
111 state.offset = offset; 114 state.offset = offset;
112 } 115 }
113 116
114 void WebGLVertexArrayObjectOES::unbindBuffer(PassRefPtr<WebGLBuffer> buffer) 117 void WebGLVertexArrayObjectOES::unbindBuffer(PassRefPtrWillBeRawPtr<WebGLBuffer> buffer)
115 { 118 {
116 if (m_boundElementArrayBuffer == buffer) { 119 if (m_boundElementArrayBuffer == buffer) {
117 m_boundElementArrayBuffer->onDetached(context()->webContext()); 120 m_boundElementArrayBuffer->onDetached(context()->webContext());
118 m_boundElementArrayBuffer = nullptr; 121 m_boundElementArrayBuffer = nullptr;
119 } 122 }
120 123
121 for (size_t i = 0; i < m_vertexAttribState.size(); ++i) { 124 for (size_t i = 0; i < m_vertexAttribState.size(); ++i) {
122 VertexAttribState& state = m_vertexAttribState[i]; 125 VertexAttribState& state = m_vertexAttribState[i];
123 if (state.bufferBinding == buffer) { 126 if (state.bufferBinding == buffer) {
124 buffer->onDetached(context()->webContext()); 127 buffer->onDetached(context()->webContext());
125 state.bufferBinding = nullptr; 128 state.bufferBinding = nullptr;
126 } 129 }
127 } 130 }
128 } 131 }
129 132
130 void WebGLVertexArrayObjectOES::setVertexAttribDivisor(GLuint index, GLuint divi sor) 133 void WebGLVertexArrayObjectOES::setVertexAttribDivisor(GLuint index, GLuint divi sor)
131 { 134 {
132 VertexAttribState& state = m_vertexAttribState[index]; 135 VertexAttribState& state = m_vertexAttribState[index];
133 state.divisor = divisor; 136 state.divisor = divisor;
134 } 137 }
135 138
139 void WebGLVertexArrayObjectOES::VertexAttribState::trace(Visitor* visitor)
140 {
141 visitor->trace(bufferBinding);
136 } 142 }
143
144 void WebGLVertexArrayObjectOES::trace(Visitor* visitor)
145 {
146 visitor->trace(m_boundElementArrayBuffer);
147 visitor->trace(m_vertexAttribState);
148 WebGLContextObject::trace(visitor);
149 }
150
151 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698