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

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

Issue 1815803003: Move simple methods [T-Z] from WebGraphicsContext3D to GLES2Interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@simples-fplus
Patch Set: simples-tplus: fixed Created 4 years, 9 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 30 matching lines...) Expand all
41 41
42 DECLARE_VIRTUAL_TRACE(); 42 DECLARE_VIRTUAL_TRACE();
43 43
44 private: 44 private:
45 explicit WebGLRenderbufferAttachment(WebGLRenderbuffer*); 45 explicit WebGLRenderbufferAttachment(WebGLRenderbuffer*);
46 WebGLRenderbufferAttachment() { } 46 WebGLRenderbufferAttachment() { }
47 47
48 WebGLSharedObject* object() const override; 48 WebGLSharedObject* object() const override;
49 bool isSharedObject(WebGLSharedObject*) const override; 49 bool isSharedObject(WebGLSharedObject*) const override;
50 bool valid() const override; 50 bool valid() const override;
51 void onDetached(WebGraphicsContext3D*) override; 51 void onDetached(WebGraphicsContext3D*, gpu::gles2::GLES2Interface*) override ;
52 void attach(gpu::gles2::GLES2Interface*, GLenum target, GLenum attachment) o verride; 52 void attach(gpu::gles2::GLES2Interface*, GLenum target, GLenum attachment) o verride;
53 void unattach(gpu::gles2::GLES2Interface*, GLenum target, GLenum attachment) override; 53 void unattach(gpu::gles2::GLES2Interface*, GLenum target, GLenum attachment) override;
54 54
55 Member<WebGLRenderbuffer> m_renderbuffer; 55 Member<WebGLRenderbuffer> m_renderbuffer;
56 }; 56 };
57 57
58 WebGLFramebuffer::WebGLAttachment* WebGLRenderbufferAttachment::create(WebGLRend erbuffer* renderbuffer) 58 WebGLFramebuffer::WebGLAttachment* WebGLRenderbufferAttachment::create(WebGLRend erbuffer* renderbuffer)
59 { 59 {
60 return new WebGLRenderbufferAttachment(renderbuffer); 60 return new WebGLRenderbufferAttachment(renderbuffer);
61 } 61 }
(...skipping 17 matching lines...) Expand all
79 bool WebGLRenderbufferAttachment::isSharedObject(WebGLSharedObject* object) cons t 79 bool WebGLRenderbufferAttachment::isSharedObject(WebGLSharedObject* object) cons t
80 { 80 {
81 return object == m_renderbuffer; 81 return object == m_renderbuffer;
82 } 82 }
83 83
84 bool WebGLRenderbufferAttachment::valid() const 84 bool WebGLRenderbufferAttachment::valid() const
85 { 85 {
86 return m_renderbuffer->object(); 86 return m_renderbuffer->object();
87 } 87 }
88 88
89 void WebGLRenderbufferAttachment::onDetached(WebGraphicsContext3D* context) 89 void WebGLRenderbufferAttachment::onDetached(WebGraphicsContext3D* context, gpu: :gles2::GLES2Interface* gl)
90 { 90 {
91 m_renderbuffer->onDetached(context); 91 m_renderbuffer->onDetached(context, gl);
92 } 92 }
93 93
94 void WebGLRenderbufferAttachment::attach(gpu::gles2::GLES2Interface* gl, GLenum target, GLenum attachment) 94 void WebGLRenderbufferAttachment::attach(gpu::gles2::GLES2Interface* gl, GLenum target, GLenum attachment)
95 { 95 {
96 Platform3DObject object = objectOrZero(m_renderbuffer.get()); 96 Platform3DObject object = objectOrZero(m_renderbuffer.get());
97 gl->FramebufferRenderbuffer(target, attachment, GL_RENDERBUFFER, object); 97 gl->FramebufferRenderbuffer(target, attachment, GL_RENDERBUFFER, object);
98 } 98 }
99 99
100 void WebGLRenderbufferAttachment::unattach(gpu::gles2::GLES2Interface* gl, GLenu m target, GLenum attachment) 100 void WebGLRenderbufferAttachment::unattach(gpu::gles2::GLES2Interface* gl, GLenu m target, GLenum attachment)
101 { 101 {
102 gl->FramebufferRenderbuffer(target, attachment, GL_RENDERBUFFER, 0); 102 gl->FramebufferRenderbuffer(target, attachment, GL_RENDERBUFFER, 0);
103 } 103 }
104 104
105 class WebGLTextureAttachment final : public WebGLFramebuffer::WebGLAttachment { 105 class WebGLTextureAttachment final : public WebGLFramebuffer::WebGLAttachment {
106 public: 106 public:
107 static WebGLFramebuffer::WebGLAttachment* create(WebGLTexture*, GLenum targe t, GLint level, GLint layer); 107 static WebGLFramebuffer::WebGLAttachment* create(WebGLTexture*, GLenum targe t, GLint level, GLint layer);
108 108
109 DECLARE_VIRTUAL_TRACE(); 109 DECLARE_VIRTUAL_TRACE();
110 110
111 private: 111 private:
112 WebGLTextureAttachment(WebGLTexture*, GLenum target, GLint level, GLint laye r); 112 WebGLTextureAttachment(WebGLTexture*, GLenum target, GLint level, GLint laye r);
113 WebGLTextureAttachment() { } 113 WebGLTextureAttachment() { }
114 114
115 WebGLSharedObject* object() const override; 115 WebGLSharedObject* object() const override;
116 bool isSharedObject(WebGLSharedObject*) const override; 116 bool isSharedObject(WebGLSharedObject*) const override;
117 bool valid() const override; 117 bool valid() const override;
118 void onDetached(WebGraphicsContext3D*) override; 118 void onDetached(WebGraphicsContext3D*, gpu::gles2::GLES2Interface*) override ;
119 void attach(gpu::gles2::GLES2Interface*, GLenum target, GLenum attachment) o verride; 119 void attach(gpu::gles2::GLES2Interface*, GLenum target, GLenum attachment) o verride;
120 void unattach(gpu::gles2::GLES2Interface*, GLenum target, GLenum attachment) override; 120 void unattach(gpu::gles2::GLES2Interface*, GLenum target, GLenum attachment) override;
121 121
122 Member<WebGLTexture> m_texture; 122 Member<WebGLTexture> m_texture;
123 GLenum m_target; 123 GLenum m_target;
124 GLint m_level; 124 GLint m_level;
125 GLint m_layer; 125 GLint m_layer;
126 }; 126 };
127 127
128 WebGLFramebuffer::WebGLAttachment* WebGLTextureAttachment::create(WebGLTexture* texture, GLenum target, GLint level, GLint layer) 128 WebGLFramebuffer::WebGLAttachment* WebGLTextureAttachment::create(WebGLTexture* texture, GLenum target, GLint level, GLint layer)
(...skipping 23 matching lines...) Expand all
152 bool WebGLTextureAttachment::isSharedObject(WebGLSharedObject* object) const 152 bool WebGLTextureAttachment::isSharedObject(WebGLSharedObject* object) const
153 { 153 {
154 return object == m_texture; 154 return object == m_texture;
155 } 155 }
156 156
157 bool WebGLTextureAttachment::valid() const 157 bool WebGLTextureAttachment::valid() const
158 { 158 {
159 return m_texture->object(); 159 return m_texture->object();
160 } 160 }
161 161
162 void WebGLTextureAttachment::onDetached(WebGraphicsContext3D* context) 162 void WebGLTextureAttachment::onDetached(WebGraphicsContext3D* context, gpu::gles 2::GLES2Interface* gl)
163 { 163 {
164 m_texture->onDetached(context); 164 m_texture->onDetached(context, gl);
165 } 165 }
166 166
167 void WebGLTextureAttachment::attach(gpu::gles2::GLES2Interface* gl, GLenum targe t, GLenum attachment) 167 void WebGLTextureAttachment::attach(gpu::gles2::GLES2Interface* gl, GLenum targe t, GLenum attachment)
168 { 168 {
169 Platform3DObject object = objectOrZero(m_texture.get()); 169 Platform3DObject object = objectOrZero(m_texture.get());
170 if (m_target == GL_TEXTURE_3D || m_target == GL_TEXTURE_2D_ARRAY) { 170 if (m_target == GL_TEXTURE_3D || m_target == GL_TEXTURE_2D_ARRAY) {
171 gl->FramebufferTextureLayer(target, attachment, object, m_level, m_layer ); 171 gl->FramebufferTextureLayer(target, attachment, object, m_level, m_layer );
172 } else { 172 } else {
173 gl->FramebufferTexture2D(target, attachment, m_target, object, m_level); 173 gl->FramebufferTexture2D(target, attachment, m_target, object, m_level);
174 } 174 }
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 } 268 }
269 269
270 void WebGLFramebuffer::removeAttachmentFromBoundFramebuffer(GLenum target, GLenu m attachment) 270 void WebGLFramebuffer::removeAttachmentFromBoundFramebuffer(GLenum target, GLenu m attachment)
271 { 271 {
272 ASSERT(isBound(target)); 272 ASSERT(isBound(target));
273 if (!m_object) 273 if (!m_object)
274 return; 274 return;
275 275
276 WebGLAttachment* attachmentObject = getAttachment(attachment); 276 WebGLAttachment* attachmentObject = getAttachment(attachment);
277 if (attachmentObject) { 277 if (attachmentObject) {
278 attachmentObject->onDetached(context()->webContext()); 278 attachmentObject->onDetached(context()->webContext(), context()->context GL());
279 m_attachments.remove(attachment); 279 m_attachments.remove(attachment);
280 drawBuffersIfNecessary(false); 280 drawBuffersIfNecessary(false);
281 switch (attachment) { 281 switch (attachment) {
282 case GL_DEPTH_STENCIL_ATTACHMENT: 282 case GL_DEPTH_STENCIL_ATTACHMENT:
283 attach(target, GL_DEPTH_ATTACHMENT, GL_DEPTH_ATTACHMENT); 283 attach(target, GL_DEPTH_ATTACHMENT, GL_DEPTH_ATTACHMENT);
284 attach(target, GL_STENCIL_ATTACHMENT, GL_STENCIL_ATTACHMENT); 284 attach(target, GL_STENCIL_ATTACHMENT, GL_STENCIL_ATTACHMENT);
285 break; 285 break;
286 case GL_DEPTH_ATTACHMENT: 286 case GL_DEPTH_ATTACHMENT:
287 case GL_STENCIL_ATTACHMENT: 287 case GL_STENCIL_ATTACHMENT:
288 attach(target, GL_DEPTH_STENCIL_ATTACHMENT, GL_DEPTH_STENCIL_ATTACHM ENT); 288 attach(target, GL_DEPTH_STENCIL_ATTACHMENT, GL_DEPTH_STENCIL_ATTACHM ENT);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 } 348 }
349 349
350 bool WebGLFramebuffer::hasStencilBuffer() const 350 bool WebGLFramebuffer::hasStencilBuffer() const
351 { 351 {
352 WebGLAttachment* attachment = getAttachment(GL_STENCIL_ATTACHMENT); 352 WebGLAttachment* attachment = getAttachment(GL_STENCIL_ATTACHMENT);
353 if (!attachment) 353 if (!attachment)
354 attachment = getAttachment(GL_DEPTH_STENCIL_ATTACHMENT); 354 attachment = getAttachment(GL_DEPTH_STENCIL_ATTACHMENT);
355 return attachment && attachment->valid(); 355 return attachment && attachment->valid();
356 } 356 }
357 357
358 void WebGLFramebuffer::deleteObjectImpl(WebGraphicsContext3D* context3d) 358 void WebGLFramebuffer::deleteObjectImpl(WebGraphicsContext3D* context3d, gpu::gl es2::GLES2Interface* gl)
359 { 359 {
360 // Both the AttachmentMap and its WebGLAttachment objects are GCed 360 // Both the AttachmentMap and its WebGLAttachment objects are GCed
361 // objects and cannot be accessed after the destructor has been 361 // objects and cannot be accessed after the destructor has been
362 // entered, as they may have been finalized already during the 362 // entered, as they may have been finalized already during the
363 // same GC sweep. These attachments' OpenGL objects will be fully 363 // same GC sweep. These attachments' OpenGL objects will be fully
364 // destroyed once their JavaScript wrappers are collected. 364 // destroyed once their JavaScript wrappers are collected.
365 if (!m_destructionInProgress) { 365 if (!m_destructionInProgress) {
366 for (const auto& attachment : m_attachments) 366 for (const auto& attachment : m_attachments)
367 attachment.value->onDetached(context3d); 367 attachment.value->onDetached(context3d, gl);
368 } 368 }
369 369
370 context3d->deleteFramebuffer(m_object); 370 context3d->deleteFramebuffer(m_object);
371 m_object = 0; 371 m_object = 0;
372 } 372 }
373 373
374 bool WebGLFramebuffer::isBound(GLenum target) const 374 bool WebGLFramebuffer::isBound(GLenum target) const
375 { 375 {
376 return (context()->getFramebufferBinding(target) == this); 376 return (context()->getFramebufferBinding(target) == this);
377 } 377 }
(...skipping 20 matching lines...) Expand all
398 reset = true; 398 reset = true;
399 } 399 }
400 } else { 400 } else {
401 if (m_filteredDrawBuffers[i] != GL_NONE) { 401 if (m_filteredDrawBuffers[i] != GL_NONE) {
402 m_filteredDrawBuffers[i] = GL_NONE; 402 m_filteredDrawBuffers[i] = GL_NONE;
403 reset = true; 403 reset = true;
404 } 404 }
405 } 405 }
406 } 406 }
407 if (reset) { 407 if (reset) {
408 context()->webContext()->drawBuffersEXT( 408 context()->contextGL()->DrawBuffersEXT(
409 m_filteredDrawBuffers.size(), m_filteredDrawBuffers.data()); 409 m_filteredDrawBuffers.size(), m_filteredDrawBuffers.data());
410 } 410 }
411 } 411 }
412 } 412 }
413 413
414 GLenum WebGLFramebuffer::getDrawBuffer(GLenum drawBuffer) 414 GLenum WebGLFramebuffer::getDrawBuffer(GLenum drawBuffer)
415 { 415 {
416 int index = static_cast<int>(drawBuffer - GL_DRAW_BUFFER0_EXT); 416 int index = static_cast<int>(drawBuffer - GL_DRAW_BUFFER0_EXT);
417 ASSERT(index >= 0); 417 ASSERT(index >= 0);
418 if (index < static_cast<int>(m_drawBuffers.size())) 418 if (index < static_cast<int>(m_drawBuffers.size()))
419 return m_drawBuffers[index]; 419 return m_drawBuffers[index];
420 if (drawBuffer == GL_DRAW_BUFFER0_EXT) 420 if (drawBuffer == GL_DRAW_BUFFER0_EXT)
421 return GL_COLOR_ATTACHMENT0; 421 return GL_COLOR_ATTACHMENT0;
422 return GL_NONE; 422 return GL_NONE;
423 } 423 }
424 424
425 DEFINE_TRACE(WebGLFramebuffer) 425 DEFINE_TRACE(WebGLFramebuffer)
426 { 426 {
427 visitor->trace(m_attachments); 427 visitor->trace(m_attachments);
428 WebGLContextObject::trace(visitor); 428 WebGLContextObject::trace(visitor);
429 } 429 }
430 430
431 } // namespace blink 431 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/webgl/WebGLFramebuffer.h ('k') | third_party/WebKit/Source/modules/webgl/WebGLObject.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698