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

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

Issue 1465173002: Check framebuffer texture attachments are cube complete (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 bool isCubeComplete() const override;
53 WebGLSharedObject* object() const override; 54 WebGLSharedObject* object() const override;
54 bool isSharedObject(WebGLSharedObject*) const override; 55 bool isSharedObject(WebGLSharedObject*) const override;
55 bool valid() const override; 56 bool valid() const override;
56 void onDetached(WebGraphicsContext3D*) override; 57 void onDetached(WebGraphicsContext3D*) override;
57 void attach(WebGraphicsContext3D*, GLenum target, GLenum attachment) overrid e; 58 void attach(WebGraphicsContext3D*, GLenum target, GLenum attachment) overrid e;
58 void unattach(WebGraphicsContext3D*, GLenum target, GLenum attachment) overr ide; 59 void unattach(WebGraphicsContext3D*, GLenum target, GLenum attachment) overr ide;
59 60
60 Member<WebGLRenderbuffer> m_renderbuffer; 61 Member<WebGLRenderbuffer> m_renderbuffer;
61 }; 62 };
62 63
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 } else { 137 } else {
137 context->framebufferRenderbuffer(target, attachment, GL_RENDERBUFFER, 0) ; 138 context->framebufferRenderbuffer(target, attachment, GL_RENDERBUFFER, 0) ;
138 } 139 }
139 } 140 }
140 141
141 GLenum WebGLRenderbufferAttachment::type() const 142 GLenum WebGLRenderbufferAttachment::type() const
142 { 143 {
143 return WebGLTexture::getValidTypeForInternalFormat(m_renderbuffer->internalF ormat()); 144 return WebGLTexture::getValidTypeForInternalFormat(m_renderbuffer->internalF ormat());
144 } 145 }
145 146
147 bool WebGLRenderbufferAttachment::isCubeComplete() const
148 {
149 return false;
zmo 2015/11/23 19:40:44 Maybe ASSERT_NOT_REACHED() here?
qiankun 2015/11/24 04:11:42 Done.
150 }
151
146 class WebGLTextureAttachment final : public WebGLFramebuffer::WebGLAttachment { 152 class WebGLTextureAttachment final : public WebGLFramebuffer::WebGLAttachment {
147 public: 153 public:
148 static WebGLFramebuffer::WebGLAttachment* create(WebGLTexture*, GLenum targe t, GLint level, GLint layer); 154 static WebGLFramebuffer::WebGLAttachment* create(WebGLTexture*, GLenum targe t, GLint level, GLint layer);
149 155
150 DECLARE_VIRTUAL_TRACE(); 156 DECLARE_VIRTUAL_TRACE();
151 157
152 private: 158 private:
153 WebGLTextureAttachment(WebGLTexture*, GLenum target, GLint level, GLint laye r); 159 WebGLTextureAttachment(WebGLTexture*, GLenum target, GLint level, GLint laye r);
154 WebGLTextureAttachment() { } 160 WebGLTextureAttachment() { }
155 161
156 GLsizei width() const override; 162 GLsizei width() const override;
157 GLsizei height() const override; 163 GLsizei height() const override;
158 GLenum format() const override; 164 GLenum format() const override;
159 GLenum type() const override; 165 GLenum type() const override;
166 bool isCubeComplete() const override;
160 WebGLSharedObject* object() const override; 167 WebGLSharedObject* object() const override;
161 bool isSharedObject(WebGLSharedObject*) const override; 168 bool isSharedObject(WebGLSharedObject*) const override;
162 bool valid() const override; 169 bool valid() const override;
163 void onDetached(WebGraphicsContext3D*) override; 170 void onDetached(WebGraphicsContext3D*) override;
164 void attach(WebGraphicsContext3D*, GLenum target, GLenum attachment) overrid e; 171 void attach(WebGraphicsContext3D*, GLenum target, GLenum attachment) overrid e;
165 void unattach(WebGraphicsContext3D*, GLenum target, GLenum attachment) overr ide; 172 void unattach(WebGraphicsContext3D*, GLenum target, GLenum attachment) overr ide;
166 173
167 Member<WebGLTexture> m_texture; 174 Member<WebGLTexture> m_texture;
168 GLenum m_target; 175 GLenum m_target;
169 GLint m_level; 176 GLint m_level;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 context->framebufferTexture2D(target, attachment, m_target, 0, m_lev el); 254 context->framebufferTexture2D(target, attachment, m_target, 0, m_lev el);
248 } 255 }
249 } 256 }
250 } 257 }
251 258
252 GLenum WebGLTextureAttachment::type() const 259 GLenum WebGLTextureAttachment::type() const
253 { 260 {
254 return m_texture->getType(m_target, m_level); 261 return m_texture->getType(m_target, m_level);
255 } 262 }
256 263
264 bool WebGLTextureAttachment::isCubeComplete() const
265 {
266 return m_texture->isCubeComplete();
267 }
268
257 bool isColorRenderable(GLenum internalformat, bool includesFloat) 269 bool isColorRenderable(GLenum internalformat, bool includesFloat)
258 { 270 {
259 switch (internalformat) { 271 switch (internalformat) {
260 case GL_RGB: 272 case GL_RGB:
261 case GL_RGBA: 273 case GL_RGBA:
262 case GL_SRGB_ALPHA_EXT: 274 case GL_SRGB_ALPHA_EXT:
263 case GL_R8: 275 case GL_R8:
264 case GL_R8UI: 276 case GL_R8UI:
265 case GL_R8I: 277 case GL_R8I:
266 case GL_R16UI: 278 case GL_R16UI:
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 *reason = "the internalformat of the attached image is not color-ren derable"; 455 *reason = "the internalformat of the attached image is not color-ren derable";
444 return false; 456 return false;
445 } 457 }
446 break; 458 break;
447 } 459 }
448 460
449 if (!attachedObject->width() || !attachedObject->height()) { 461 if (!attachedObject->width() || !attachedObject->height()) {
450 *reason = "attachment has a 0 dimension"; 462 *reason = "attachment has a 0 dimension";
451 return false; 463 return false;
452 } 464 }
465
466 if (attachedObject->object()->isTexture() && !attachedObject->isCubeComplete ()) {
467 *reason ="attachment is not cube complete";
Ken Russell (switch to Gerrit) 2015/11/24 00:37:03 Add space after =.
qiankun 2015/11/24 04:11:43 Done.
468 return false;
469 }
470
453 return true; 471 return true;
454 } 472 }
455 473
456 WebGLFramebuffer::WebGLAttachment* WebGLFramebuffer::getAttachment(GLenum attach ment) const 474 WebGLFramebuffer::WebGLAttachment* WebGLFramebuffer::getAttachment(GLenum attach ment) const
457 { 475 {
458 const AttachmentMap::const_iterator it = m_attachments.find(attachment); 476 const AttachmentMap::const_iterator it = m_attachments.find(attachment);
459 return (it != m_attachments.end()) ? it->value.get() : 0; 477 return (it != m_attachments.end()) ? it->value.get() : 0;
460 } 478 }
461 479
462 void WebGLFramebuffer::removeAttachmentFromBoundFramebuffer(GLenum target, GLenu m attachment) 480 void WebGLFramebuffer::removeAttachmentFromBoundFramebuffer(GLenum target, GLenu m attachment)
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 return true; 696 return true;
679 } 697 }
680 698
681 DEFINE_TRACE(WebGLFramebuffer) 699 DEFINE_TRACE(WebGLFramebuffer)
682 { 700 {
683 visitor->trace(m_attachments); 701 visitor->trace(m_attachments);
684 WebGLContextObject::trace(visitor); 702 WebGLContextObject::trace(visitor);
685 } 703 }
686 704
687 } 705 }
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/webgl/WebGLFramebuffer.h ('k') | third_party/WebKit/Source/modules/webgl/WebGLTexture.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698