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

Side by Side Diff: Source/modules/webgl/WebGLFramebuffer.cpp

Issue 1234883002: [Oilpan] Migrate classes under module/webgl onto oilpan heap (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 5 years, 4 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) 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2009 Apple 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 18 matching lines...) Expand all
29 29
30 #include "modules/webgl/WebGLRenderbuffer.h" 30 #include "modules/webgl/WebGLRenderbuffer.h"
31 #include "modules/webgl/WebGLRenderingContextBase.h" 31 #include "modules/webgl/WebGLRenderingContextBase.h"
32 #include "modules/webgl/WebGLTexture.h" 32 #include "modules/webgl/WebGLTexture.h"
33 #include "platform/NotImplemented.h" 33 #include "platform/NotImplemented.h"
34 34
35 namespace blink { 35 namespace blink {
36 36
37 namespace { 37 namespace {
38 38
39 class WebGLRenderbufferAttachment final : public WebGLFramebuffer::WebGLAtta chment { 39 class WebGLRenderbufferAttachment final : public WebGLFramebuffer::WebGLAttachme nt {
Ken Russell (switch to Gerrit) 2015/08/01 00:11:56 The whitespace changes in this file are unfortunat
peria 2015/08/03 09:00:36 Acknowledged. https://codereview.chromium.org/1267
40 public: 40 public:
41 static PassRefPtrWillBeRawPtr<WebGLFramebuffer::WebGLAttachment> create( WebGLRenderbuffer*); 41 static WebGLFramebuffer::WebGLAttachment* create(WebGLRenderbuffer*);
42 42
43 DECLARE_VIRTUAL_TRACE(); 43 DECLARE_VIRTUAL_TRACE();
44 44
45 private: 45 private:
46 explicit WebGLRenderbufferAttachment(WebGLRenderbuffer*); 46 explicit WebGLRenderbufferAttachment(WebGLRenderbuffer*);
47 WebGLRenderbufferAttachment() { } 47 WebGLRenderbufferAttachment() { }
48 48
49 GLsizei width() const override; 49 GLsizei width() const override;
50 GLsizei height() const override; 50 GLsizei height() const override;
51 GLenum format() const override; 51 GLenum format() const override;
52 GLenum type() const override; 52 GLenum type() const override;
53 WebGLSharedObject* object() const override; 53 WebGLSharedObject* object() const override;
54 bool isSharedObject(WebGLSharedObject*) const override; 54 bool isSharedObject(WebGLSharedObject*) const override;
55 bool valid() const override; 55 bool valid() const override;
56 void onDetached(WebGraphicsContext3D*) override; 56 void onDetached(WebGraphicsContext3D*) override;
57 void attach(WebGraphicsContext3D*, GLenum target, GLenum attachment) ove rride; 57 void attach(WebGraphicsContext3D*, GLenum target, GLenum attachment) overrid e;
58 void unattach(WebGraphicsContext3D*, GLenum target, GLenum attachment) o verride; 58 void unattach(WebGraphicsContext3D*, GLenum target, GLenum attachment) overr ide;
59 59
60 RefPtrWillBeMember<WebGLRenderbuffer> m_renderbuffer; 60 Member<WebGLRenderbuffer> m_renderbuffer;
61 }; 61 };
62 62
63 PassRefPtrWillBeRawPtr<WebGLFramebuffer::WebGLAttachment> WebGLRenderbufferA ttachment::create(WebGLRenderbuffer* renderbuffer) 63 WebGLFramebuffer::WebGLAttachment* WebGLRenderbufferAttachment::create(WebGLRend erbuffer* renderbuffer)
64 { 64 {
65 return adoptRefWillBeNoop(new WebGLRenderbufferAttachment(renderbuffer)) ; 65 return new WebGLRenderbufferAttachment(renderbuffer);
66 } 66 }
67 67
68 DEFINE_TRACE(WebGLRenderbufferAttachment) 68 DEFINE_TRACE(WebGLRenderbufferAttachment)
69 { 69 {
70 visitor->trace(m_renderbuffer); 70 visitor->trace(m_renderbuffer);
71 WebGLFramebuffer::WebGLAttachment::trace(visitor); 71 WebGLFramebuffer::WebGLAttachment::trace(visitor);
72 } 72 }
73 73
74 WebGLRenderbufferAttachment::WebGLRenderbufferAttachment(WebGLRenderbuffer* renderbuffer) 74 WebGLRenderbufferAttachment::WebGLRenderbufferAttachment(WebGLRenderbuffer* rend erbuffer)
75 : m_renderbuffer(renderbuffer) 75 : m_renderbuffer(renderbuffer)
76 { 76 {
77 } 77 }
78 78
79 GLsizei WebGLRenderbufferAttachment::width() const 79 GLsizei WebGLRenderbufferAttachment::width() const
80 { 80 {
81 return m_renderbuffer->width(); 81 return m_renderbuffer->width();
82 } 82 }
83 83
84 GLsizei WebGLRenderbufferAttachment::height() const 84 GLsizei WebGLRenderbufferAttachment::height() const
85 { 85 {
86 return m_renderbuffer->height(); 86 return m_renderbuffer->height();
87 } 87 }
88 88
89 GLenum WebGLRenderbufferAttachment::format() const 89 GLenum WebGLRenderbufferAttachment::format() const
90 { 90 {
91 GLenum format = m_renderbuffer->internalFormat(); 91 GLenum format = m_renderbuffer->internalFormat();
92 if (format == GL_DEPTH_STENCIL_OES 92 if (format == GL_DEPTH_STENCIL_OES
93 && m_renderbuffer->emulatedStencilBuffer() 93 && m_renderbuffer->emulatedStencilBuffer()
94 && m_renderbuffer->emulatedStencilBuffer()->internalFormat() != GL_S TENCIL_INDEX8) { 94 && m_renderbuffer->emulatedStencilBuffer()->internalFormat() != GL_STENC IL_INDEX8) {
95 return 0;
96 }
97 return format;
98 }
99
100 WebGLSharedObject* WebGLRenderbufferAttachment::object() const
101 {
102 return m_renderbuffer->object() ? m_renderbuffer.get() : 0;
103 }
104
105 bool WebGLRenderbufferAttachment::isSharedObject(WebGLSharedObject* object) const
106 {
107 return object == m_renderbuffer;
108 }
109
110 bool WebGLRenderbufferAttachment::valid() const
111 {
112 return m_renderbuffer->object();
113 }
114
115 void WebGLRenderbufferAttachment::onDetached(WebGraphicsContext3D* context)
116 {
117 m_renderbuffer->onDetached(context);
118 }
119
120 void WebGLRenderbufferAttachment::attach(WebGraphicsContext3D* context, GLen um target, GLenum attachment)
121 {
122 Platform3DObject object = objectOrZero(m_renderbuffer.get());
123 if (attachment == GL_DEPTH_STENCIL_ATTACHMENT && m_renderbuffer->emulate dStencilBuffer()) {
124 context->framebufferRenderbuffer(target, GL_DEPTH_ATTACHMENT, GL_REN DERBUFFER, object);
125 context->framebufferRenderbuffer(target, GL_STENCIL_ATTACHMENT, GL_R ENDERBUFFER, objectOrZero(m_renderbuffer->emulatedStencilBuffer()));
126 } else {
127 context->framebufferRenderbuffer(target, attachment, GL_RENDERBUFFER , object);
128 }
129 }
130
131 void WebGLRenderbufferAttachment::unattach(WebGraphicsContext3D* context, GL enum target, GLenum attachment)
132 {
133 if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) {
134 context->framebufferRenderbuffer(target, GL_DEPTH_ATTACHMENT, GL_REN DERBUFFER, 0);
135 context->framebufferRenderbuffer(target, GL_STENCIL_ATTACHMENT, GL_R ENDERBUFFER, 0);
136 } else {
137 context->framebufferRenderbuffer(target, attachment, GL_RENDERBUFFER , 0);
138 }
139 }
140
141 GLenum WebGLRenderbufferAttachment::type() const
142 {
143 return 0; 95 return 0;
144 } 96 }
145 97 return format;
146 class WebGLTextureAttachment final : public WebGLFramebuffer::WebGLAttachmen t { 98 }
147 public: 99
148 static PassRefPtrWillBeRawPtr<WebGLFramebuffer::WebGLAttachment> create( WebGLTexture*, GLenum target, GLint level); 100 WebGLSharedObject* WebGLRenderbufferAttachment::object() const
149 101 {
150 DECLARE_VIRTUAL_TRACE(); 102 return m_renderbuffer->object() ? m_renderbuffer.get() : 0;
151 103 }
152 private: 104
153 WebGLTextureAttachment(WebGLTexture*, GLenum target, GLint level); 105 bool WebGLRenderbufferAttachment::isSharedObject(WebGLSharedObject* object) cons t
154 WebGLTextureAttachment() { } 106 {
155 107 return object == m_renderbuffer;
156 GLsizei width() const override; 108 }
157 GLsizei height() const override; 109
158 GLenum format() const override; 110 bool WebGLRenderbufferAttachment::valid() const
159 GLenum type() const override; 111 {
160 WebGLSharedObject* object() const override; 112 return m_renderbuffer->object();
161 bool isSharedObject(WebGLSharedObject*) const override; 113 }
162 bool valid() const override; 114
163 void onDetached(WebGraphicsContext3D*) override; 115 void WebGLRenderbufferAttachment::onDetached(WebGraphicsContext3D* context)
164 void attach(WebGraphicsContext3D*, GLenum target, GLenum attachment) ove rride; 116 {
165 void unattach(WebGraphicsContext3D*, GLenum target, GLenum attachment) o verride; 117 m_renderbuffer->onDetached(context);
166 118 }
167 RefPtrWillBeMember<WebGLTexture> m_texture; 119
168 GLenum m_target; 120 void WebGLRenderbufferAttachment::attach(WebGraphicsContext3D* context, GLenum t arget, GLenum attachment)
169 GLint m_level; 121 {
170 }; 122 Platform3DObject object = objectOrZero(m_renderbuffer.get());
171 123 if (attachment == GL_DEPTH_STENCIL_ATTACHMENT && m_renderbuffer->emulatedSte ncilBuffer()) {
172 PassRefPtrWillBeRawPtr<WebGLFramebuffer::WebGLAttachment> WebGLTextureAttach ment::create(WebGLTexture* texture, GLenum target, GLint level) 124 context->framebufferRenderbuffer(target, GL_DEPTH_ATTACHMENT, GL_RENDERB UFFER, object);
173 { 125 context->framebufferRenderbuffer(target, GL_STENCIL_ATTACHMENT, GL_RENDE RBUFFER, objectOrZero(m_renderbuffer->emulatedStencilBuffer()));
174 return adoptRefWillBeNoop(new WebGLTextureAttachment(texture, target, le vel)); 126 } else {
175 } 127 context->framebufferRenderbuffer(target, attachment, GL_RENDERBUFFER, ob ject);
176 128 }
177 DEFINE_TRACE(WebGLTextureAttachment) 129 }
178 { 130
179 visitor->trace(m_texture); 131 void WebGLRenderbufferAttachment::unattach(WebGraphicsContext3D* context, GLenum target, GLenum attachment)
180 WebGLFramebuffer::WebGLAttachment::trace(visitor); 132 {
181 } 133 if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) {
182 134 context->framebufferRenderbuffer(target, GL_DEPTH_ATTACHMENT, GL_RENDERB UFFER, 0);
183 WebGLTextureAttachment::WebGLTextureAttachment(WebGLTexture* texture, GLenum target, GLint level) 135 context->framebufferRenderbuffer(target, GL_STENCIL_ATTACHMENT, GL_RENDE RBUFFER, 0);
136 } else {
137 context->framebufferRenderbuffer(target, attachment, GL_RENDERBUFFER, 0) ;
138 }
139 }
140
141 GLenum WebGLRenderbufferAttachment::type() const
142 {
143 notImplemented();
144 return 0;
145 }
146
147 class WebGLTextureAttachment final : public WebGLFramebuffer::WebGLAttachment {
148 public:
149 static WebGLFramebuffer::WebGLAttachment* create(WebGLTexture*, GLenum targe t, GLint level);
150
151 DECLARE_VIRTUAL_TRACE();
152
153 private:
154 WebGLTextureAttachment(WebGLTexture*, GLenum target, GLint level);
155 WebGLTextureAttachment() { }
156
157 GLsizei width() const override;
158 GLsizei height() const override;
159 GLenum format() const override;
160 GLenum type() const override;
161 WebGLSharedObject* object() const override;
162 bool isSharedObject(WebGLSharedObject*) const override;
163 bool valid() const override;
164 void onDetached(WebGraphicsContext3D*) override;
165 void attach(WebGraphicsContext3D*, GLenum target, GLenum attachment) overrid e;
166 void unattach(WebGraphicsContext3D*, GLenum target, GLenum attachment) overr ide;
167
168 Member<WebGLTexture> m_texture;
169 GLenum m_target;
170 GLint m_level;
171 };
172
173 WebGLFramebuffer::WebGLAttachment* WebGLTextureAttachment::create(WebGLTexture* texture, GLenum target, GLint level)
174 {
175 return new WebGLTextureAttachment(texture, target, level);
176 }
177
178 DEFINE_TRACE(WebGLTextureAttachment)
179 {
180 visitor->trace(m_texture);
181 WebGLFramebuffer::WebGLAttachment::trace(visitor);
182 }
183
184 WebGLTextureAttachment::WebGLTextureAttachment(WebGLTexture* texture, GLenum tar get, GLint level)
184 : m_texture(texture) 185 : m_texture(texture)
185 , m_target(target) 186 , m_target(target)
186 , m_level(level) 187 , m_level(level)
187 { 188 {
188 } 189 }
189 190
190 GLsizei WebGLTextureAttachment::width() const 191 GLsizei WebGLTextureAttachment::width() const
191 { 192 {
192 return m_texture->getWidth(m_target, m_level); 193 return m_texture->getWidth(m_target, m_level);
193 } 194 }
194 195
195 GLsizei WebGLTextureAttachment::height() const 196 GLsizei WebGLTextureAttachment::height() const
196 { 197 {
197 return m_texture->getHeight(m_target, m_level); 198 return m_texture->getHeight(m_target, m_level);
198 } 199 }
199 200
200 GLenum WebGLTextureAttachment::format() const 201 GLenum WebGLTextureAttachment::format() const
201 { 202 {
202 return m_texture->getInternalFormat(m_target, m_level); 203 return m_texture->getInternalFormat(m_target, m_level);
203 } 204 }
204 205
205 WebGLSharedObject* WebGLTextureAttachment::object() const 206 WebGLSharedObject* WebGLTextureAttachment::object() const
206 { 207 {
207 return m_texture->object() ? m_texture.get() : 0; 208 return m_texture->object() ? m_texture.get() : 0;
208 } 209 }
209 210
210 bool WebGLTextureAttachment::isSharedObject(WebGLSharedObject* object) const 211 bool WebGLTextureAttachment::isSharedObject(WebGLSharedObject* object) const
211 { 212 {
212 return object == m_texture; 213 return object == m_texture;
213 } 214 }
214 215
215 bool WebGLTextureAttachment::valid() const 216 bool WebGLTextureAttachment::valid() const
216 { 217 {
217 return m_texture->object(); 218 return m_texture->object();
218 } 219 }
219 220
220 void WebGLTextureAttachment::onDetached(WebGraphicsContext3D* context) 221 void WebGLTextureAttachment::onDetached(WebGraphicsContext3D* context)
221 { 222 {
222 m_texture->onDetached(context); 223 m_texture->onDetached(context);
223 } 224 }
224 225
225 void WebGLTextureAttachment::attach(WebGraphicsContext3D* context, GLenum ta rget, GLenum attachment) 226 void WebGLTextureAttachment::attach(WebGraphicsContext3D* context, GLenum target , GLenum attachment)
226 { 227 {
227 Platform3DObject object = objectOrZero(m_texture.get()); 228 Platform3DObject object = objectOrZero(m_texture.get());
228 context->framebufferTexture2D(target, attachment, m_target, object, m_le vel); 229 context->framebufferTexture2D(target, attachment, m_target, object, m_level) ;
229 } 230 }
230 231
231 void WebGLTextureAttachment::unattach(WebGraphicsContext3D* context, GLenum target, GLenum attachment) 232 void WebGLTextureAttachment::unattach(WebGraphicsContext3D* context, GLenum targ et, GLenum attachment)
232 { 233 {
233 if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) { 234 if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) {
234 context->framebufferTexture2D(target, GL_DEPTH_ATTACHMENT, m_target, 0, m_level); 235 context->framebufferTexture2D(target, GL_DEPTH_ATTACHMENT, m_target, 0, m_level);
235 context->framebufferTexture2D(target, GL_STENCIL_ATTACHMENT, m_targe t, 0, m_level); 236 context->framebufferTexture2D(target, GL_STENCIL_ATTACHMENT, m_target, 0 , m_level);
236 } else { 237 } else {
237 context->framebufferTexture2D(target, attachment, m_target, 0, m_lev el); 238 context->framebufferTexture2D(target, attachment, m_target, 0, m_level);
238 } 239 }
239 } 240 }
240 241
241 GLenum WebGLTextureAttachment::type() const 242 GLenum WebGLTextureAttachment::type() const
242 { 243 {
243 return m_texture->getType(m_target, m_level); 244 return m_texture->getType(m_target, m_level);
244 } 245 }
245 246
246 bool isColorRenderable(GLenum internalformat) 247 bool isColorRenderable(GLenum internalformat)
247 { 248 {
248 switch (internalformat) { 249 switch (internalformat) {
249 case GL_RGB: 250 case GL_RGB:
250 case GL_RGBA: 251 case GL_RGBA:
251 case GL_SRGB_ALPHA_EXT: 252 case GL_SRGB_ALPHA_EXT:
252 case GL_R8: 253 case GL_R8:
253 case GL_R8UI: 254 case GL_R8UI:
254 case GL_R8I: 255 case GL_R8I:
255 case GL_R16UI: 256 case GL_R16UI:
256 case GL_R16I: 257 case GL_R16I:
257 case GL_R32UI: 258 case GL_R32UI:
258 case GL_R32I: 259 case GL_R32I:
(...skipping 14 matching lines...) Expand all
273 case GL_RGBA8UI: 274 case GL_RGBA8UI:
274 case GL_RGBA8I: 275 case GL_RGBA8I:
275 case GL_RGB10_A2UI: 276 case GL_RGB10_A2UI:
276 case GL_RGBA16UI: 277 case GL_RGBA16UI:
277 case GL_RGBA16I: 278 case GL_RGBA16I:
278 case GL_RGBA32UI: 279 case GL_RGBA32UI:
279 case GL_RGBA32I: 280 case GL_RGBA32I:
280 return true; 281 return true;
281 default: 282 default:
282 return false; 283 return false;
283 }
284 } 284 }
285 }
285 286
286 bool isDepthRenderable(GLenum internalformat, bool includesDepthStencil) 287 bool isDepthRenderable(GLenum internalformat, bool includesDepthStencil)
287 { 288 {
288 switch (internalformat) { 289 switch (internalformat) {
289 case GL_DEPTH_COMPONENT: 290 case GL_DEPTH_COMPONENT:
290 case GL_DEPTH_COMPONENT16: 291 case GL_DEPTH_COMPONENT16:
291 case GL_DEPTH_COMPONENT24: 292 case GL_DEPTH_COMPONENT24:
292 case GL_DEPTH_COMPONENT32F: 293 case GL_DEPTH_COMPONENT32F:
293 return true; 294 return true;
294 case GL_DEPTH_STENCIL: 295 case GL_DEPTH_STENCIL:
295 case GL_DEPTH24_STENCIL8: 296 case GL_DEPTH24_STENCIL8:
296 case GL_DEPTH32F_STENCIL8: 297 case GL_DEPTH32F_STENCIL8:
297 return includesDepthStencil; 298 return includesDepthStencil;
298 default: 299 default:
299 return false; 300 return false;
300 }
301 } 301 }
302 }
302 303
303 bool isStencilRenderable(GLenum internalformat, bool includesDepthStencil) 304 bool isStencilRenderable(GLenum internalformat, bool includesDepthStencil)
304 { 305 {
305 switch (internalformat) { 306 switch (internalformat) {
306 case GL_STENCIL_INDEX8: 307 case GL_STENCIL_INDEX8:
307 return true; 308 return true;
308 case GL_DEPTH_STENCIL: 309 case GL_DEPTH_STENCIL:
309 case GL_DEPTH24_STENCIL8: 310 case GL_DEPTH24_STENCIL8:
310 case GL_DEPTH32F_STENCIL8: 311 case GL_DEPTH32F_STENCIL8:
311 return includesDepthStencil; 312 return includesDepthStencil;
312 default: 313 default:
313 return false; 314 return false;
314 }
315 } 315 }
316 }
316 317
317 } // anonymous namespace 318 } // anonymous namespace
318 319
319 WebGLFramebuffer::WebGLAttachment::WebGLAttachment() 320 WebGLFramebuffer::WebGLAttachment::WebGLAttachment()
320 { 321 {
321 } 322 }
322 323
323 WebGLFramebuffer::WebGLAttachment::~WebGLAttachment() 324 WebGLFramebuffer::WebGLAttachment::~WebGLAttachment()
324 { 325 {
325 } 326 }
326 327
327 PassRefPtrWillBeRawPtr<WebGLFramebuffer> WebGLFramebuffer::create(WebGLRendering ContextBase* ctx) 328 WebGLFramebuffer* WebGLFramebuffer::create(WebGLRenderingContextBase* ctx)
328 { 329 {
329 return adoptRefWillBeNoop(new WebGLFramebuffer(ctx)); 330 return new WebGLFramebuffer(ctx);
330 } 331 }
331 332
332 WebGLFramebuffer::WebGLFramebuffer(WebGLRenderingContextBase* ctx) 333 WebGLFramebuffer::WebGLFramebuffer(WebGLRenderingContextBase* ctx)
333 : WebGLContextObject(ctx) 334 : WebGLContextObject(ctx)
334 , m_object(ctx->webContext()->createFramebuffer()) 335 , m_object(ctx->webContext()->createFramebuffer())
335 , m_hasEverBeenBound(false) 336 , m_hasEverBeenBound(false)
336 , m_readBuffer(GL_COLOR_ATTACHMENT0) 337 , m_readBuffer(GL_COLOR_ATTACHMENT0)
337 { 338 {
338 } 339 }
339 340
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 return false; 657 return false;
657 if (format) 658 if (format)
658 *format = image->format(); 659 *format = image->format();
659 if (type) 660 if (type)
660 *type = image->type(); 661 *type = image->type();
661 return true; 662 return true;
662 } 663 }
663 664
664 DEFINE_TRACE(WebGLFramebuffer) 665 DEFINE_TRACE(WebGLFramebuffer)
665 { 666 {
666 #if ENABLE(OILPAN)
667 visitor->trace(m_attachments); 667 visitor->trace(m_attachments);
668 #endif
669 WebGLContextObject::trace(visitor); 668 WebGLContextObject::trace(visitor);
670 } 669 }
671 670
672 } 671 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698