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

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: add assert_not_reached and add missing space 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 ASSERT_NOT_REACHED();
150 return false;
151 }
152
146 class WebGLTextureAttachment final : public WebGLFramebuffer::WebGLAttachment { 153 class WebGLTextureAttachment final : public WebGLFramebuffer::WebGLAttachment {
147 public: 154 public:
148 static WebGLFramebuffer::WebGLAttachment* create(WebGLTexture*, GLenum targe t, GLint level, GLint layer); 155 static WebGLFramebuffer::WebGLAttachment* create(WebGLTexture*, GLenum targe t, GLint level, GLint layer);
149 156
150 DECLARE_VIRTUAL_TRACE(); 157 DECLARE_VIRTUAL_TRACE();
151 158
152 private: 159 private:
153 WebGLTextureAttachment(WebGLTexture*, GLenum target, GLint level, GLint laye r); 160 WebGLTextureAttachment(WebGLTexture*, GLenum target, GLint level, GLint laye r);
154 WebGLTextureAttachment() { } 161 WebGLTextureAttachment() { }
155 162
156 GLsizei width() const override; 163 GLsizei width() const override;
157 GLsizei height() const override; 164 GLsizei height() const override;
158 GLenum format() const override; 165 GLenum format() const override;
159 GLenum type() const override; 166 GLenum type() const override;
167 bool isCubeComplete() const override;
160 WebGLSharedObject* object() const override; 168 WebGLSharedObject* object() const override;
161 bool isSharedObject(WebGLSharedObject*) const override; 169 bool isSharedObject(WebGLSharedObject*) const override;
162 bool valid() const override; 170 bool valid() const override;
163 void onDetached(WebGraphicsContext3D*) override; 171 void onDetached(WebGraphicsContext3D*) override;
164 void attach(WebGraphicsContext3D*, GLenum target, GLenum attachment) overrid e; 172 void attach(WebGraphicsContext3D*, GLenum target, GLenum attachment) overrid e;
165 void unattach(WebGraphicsContext3D*, GLenum target, GLenum attachment) overr ide; 173 void unattach(WebGraphicsContext3D*, GLenum target, GLenum attachment) overr ide;
166 174
167 Member<WebGLTexture> m_texture; 175 Member<WebGLTexture> m_texture;
168 GLenum m_target; 176 GLenum m_target;
169 GLint m_level; 177 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); 255 context->framebufferTexture2D(target, attachment, m_target, 0, m_lev el);
248 } 256 }
249 } 257 }
250 } 258 }
251 259
252 GLenum WebGLTextureAttachment::type() const 260 GLenum WebGLTextureAttachment::type() const
253 { 261 {
254 return m_texture->getType(m_target, m_level); 262 return m_texture->getType(m_target, m_level);
255 } 263 }
256 264
265 bool WebGLTextureAttachment::isCubeComplete() const
266 {
267 return m_texture->isCubeComplete();
268 }
269
257 bool isColorRenderable(GLenum internalformat, bool includesFloat) 270 bool isColorRenderable(GLenum internalformat, bool includesFloat)
258 { 271 {
259 switch (internalformat) { 272 switch (internalformat) {
260 case GL_RGB: 273 case GL_RGB:
261 case GL_RGBA: 274 case GL_RGBA:
262 case GL_SRGB_ALPHA_EXT: 275 case GL_SRGB_ALPHA_EXT:
263 case GL_R8: 276 case GL_R8:
264 case GL_R8UI: 277 case GL_R8UI:
265 case GL_R8I: 278 case GL_R8I:
266 case GL_R16UI: 279 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"; 456 *reason = "the internalformat of the attached image is not color-ren derable";
444 return false; 457 return false;
445 } 458 }
446 break; 459 break;
447 } 460 }
448 461
449 if (!attachedObject->width() || !attachedObject->height()) { 462 if (!attachedObject->width() || !attachedObject->height()) {
450 *reason = "attachment has a 0 dimension"; 463 *reason = "attachment has a 0 dimension";
451 return false; 464 return false;
452 } 465 }
466
467 if (attachedObject->object()->isTexture() && !attachedObject->isCubeComplete ()) {
468 *reason = "attachment is not cube complete";
469 return false;
470 }
471
453 return true; 472 return true;
454 } 473 }
455 474
456 WebGLFramebuffer::WebGLAttachment* WebGLFramebuffer::getAttachment(GLenum attach ment) const 475 WebGLFramebuffer::WebGLAttachment* WebGLFramebuffer::getAttachment(GLenum attach ment) const
457 { 476 {
458 const AttachmentMap::const_iterator it = m_attachments.find(attachment); 477 const AttachmentMap::const_iterator it = m_attachments.find(attachment);
459 return (it != m_attachments.end()) ? it->value.get() : 0; 478 return (it != m_attachments.end()) ? it->value.get() : 0;
460 } 479 }
461 480
462 void WebGLFramebuffer::removeAttachmentFromBoundFramebuffer(GLenum target, GLenu m attachment) 481 void WebGLFramebuffer::removeAttachmentFromBoundFramebuffer(GLenum target, GLenu m attachment)
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 return true; 697 return true;
679 } 698 }
680 699
681 DEFINE_TRACE(WebGLFramebuffer) 700 DEFINE_TRACE(WebGLFramebuffer)
682 { 701 {
683 visitor->trace(m_attachments); 702 visitor->trace(m_attachments);
684 WebGLContextObject::trace(visitor); 703 WebGLContextObject::trace(visitor);
685 } 704 }
686 705
687 } 706 }
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