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

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

Issue 1412613004: Set attachment for bound framebuffer in FramebufferTextureLayer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add zero texure support and fix conformance test Created 5 years, 1 month 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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 } 139 }
140 140
141 GLenum WebGLRenderbufferAttachment::type() const 141 GLenum WebGLRenderbufferAttachment::type() const
142 { 142 {
143 notImplemented(); 143 notImplemented();
144 return 0; 144 return 0;
145 } 145 }
146 146
147 class WebGLTextureAttachment final : public WebGLFramebuffer::WebGLAttachment { 147 class WebGLTextureAttachment final : public WebGLFramebuffer::WebGLAttachment {
148 public: 148 public:
149 static WebGLFramebuffer::WebGLAttachment* create(WebGLTexture*, GLenum targe t, GLint level); 149 static WebGLFramebuffer::WebGLAttachment* create(WebGLTexture*, GLenum targe t, GLint level, GLint layer);
150 150
151 DECLARE_VIRTUAL_TRACE(); 151 DECLARE_VIRTUAL_TRACE();
152 152
153 private: 153 private:
154 WebGLTextureAttachment(WebGLTexture*, GLenum target, GLint level); 154 WebGLTextureAttachment(WebGLTexture*, GLenum target, GLint level, GLint laye r);
155 WebGLTextureAttachment() { } 155 WebGLTextureAttachment() { }
156 156
157 GLsizei width() const override; 157 GLsizei width() const override;
158 GLsizei height() const override; 158 GLsizei height() const override;
159 GLenum format() const override; 159 GLenum format() const override;
160 GLenum type() const override; 160 GLenum type() const override;
161 WebGLSharedObject* object() const override; 161 WebGLSharedObject* object() const override;
162 bool isSharedObject(WebGLSharedObject*) const override; 162 bool isSharedObject(WebGLSharedObject*) const override;
163 bool valid() const override; 163 bool valid() const override;
164 void onDetached(WebGraphicsContext3D*) override; 164 void onDetached(WebGraphicsContext3D*) override;
165 void attach(WebGraphicsContext3D*, GLenum target, GLenum attachment) overrid e; 165 void attach(WebGraphicsContext3D*, GLenum target, GLenum attachment) overrid e;
166 void unattach(WebGraphicsContext3D*, GLenum target, GLenum attachment) overr ide; 166 void unattach(WebGraphicsContext3D*, GLenum target, GLenum attachment) overr ide;
167 167
168 Member<WebGLTexture> m_texture; 168 Member<WebGLTexture> m_texture;
169 GLenum m_target; 169 GLenum m_target;
170 GLint m_level; 170 GLint m_level;
171 GLint m_layer;
171 }; 172 };
172 173
173 WebGLFramebuffer::WebGLAttachment* WebGLTextureAttachment::create(WebGLTexture* texture, GLenum target, GLint level) 174 WebGLFramebuffer::WebGLAttachment* WebGLTextureAttachment::create(WebGLTexture* texture, GLenum target, GLint level, GLint layer)
174 { 175 {
175 return new WebGLTextureAttachment(texture, target, level); 176 return new WebGLTextureAttachment(texture, target, level, layer);
176 } 177 }
177 178
178 DEFINE_TRACE(WebGLTextureAttachment) 179 DEFINE_TRACE(WebGLTextureAttachment)
179 { 180 {
180 visitor->trace(m_texture); 181 visitor->trace(m_texture);
181 WebGLFramebuffer::WebGLAttachment::trace(visitor); 182 WebGLFramebuffer::WebGLAttachment::trace(visitor);
182 } 183 }
183 184
184 WebGLTextureAttachment::WebGLTextureAttachment(WebGLTexture* texture, GLenum tar get, GLint level) 185 WebGLTextureAttachment::WebGLTextureAttachment(WebGLTexture* texture, GLenum tar get, GLint level, GLint layer)
185 : m_texture(texture) 186 : m_texture(texture)
186 , m_target(target) 187 , m_target(target)
187 , m_level(level) 188 , m_level(level)
189 , m_layer(layer)
188 { 190 {
189 } 191 }
190 192
191 GLsizei WebGLTextureAttachment::width() const 193 GLsizei WebGLTextureAttachment::width() const
192 { 194 {
193 return m_texture->getWidth(m_target, m_level); 195 return m_texture->getWidth(m_target, m_level);
194 } 196 }
195 197
196 GLsizei WebGLTextureAttachment::height() const 198 GLsizei WebGLTextureAttachment::height() const
197 { 199 {
(...skipping 21 matching lines...) Expand all
219 } 221 }
220 222
221 void WebGLTextureAttachment::onDetached(WebGraphicsContext3D* context) 223 void WebGLTextureAttachment::onDetached(WebGraphicsContext3D* context)
222 { 224 {
223 m_texture->onDetached(context); 225 m_texture->onDetached(context);
224 } 226 }
225 227
226 void WebGLTextureAttachment::attach(WebGraphicsContext3D* context, GLenum target , GLenum attachment) 228 void WebGLTextureAttachment::attach(WebGraphicsContext3D* context, GLenum target , GLenum attachment)
227 { 229 {
228 Platform3DObject object = objectOrZero(m_texture.get()); 230 Platform3DObject object = objectOrZero(m_texture.get());
229 context->framebufferTexture2D(target, attachment, m_target, object, m_level) ; 231 if (target == GL_TEXTURE_3D || target == GL_TEXTURE_2D_ARRAY) {
232 context->framebufferTextureLayer(target, attachment, object, m_level, m_ layer);
233 } else {
234 context->framebufferTexture2D(target, attachment, m_target, object, m_le vel);
235 }
230 } 236 }
231 237
232 void WebGLTextureAttachment::unattach(WebGraphicsContext3D* context, GLenum targ et, GLenum attachment) 238 void WebGLTextureAttachment::unattach(WebGraphicsContext3D* context, GLenum targ et, GLenum attachment)
233 { 239 {
234 if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) { 240 // GL_DEPTH_STENCIL_ATTACHMENT attachment is valid in ES3.
235 context->framebufferTexture2D(target, GL_DEPTH_ATTACHMENT, m_target, 0, m_level); 241 if (m_target == GL_TEXTURE_3D || m_target == GL_TEXTURE_2D_ARRAY) {
Ken Russell (switch to Gerrit) 2015/10/28 23:48:32 This changed to test "m_target" instead of "target
qiankun 2015/10/29 01:03:26 Done.
236 context->framebufferTexture2D(target, GL_STENCIL_ATTACHMENT, m_target, 0 , m_level); 242 context->framebufferTextureLayer(target, attachment, 0, m_level, m_layer );
237 } else { 243 } else {
238 context->framebufferTexture2D(target, attachment, m_target, 0, m_level); 244 if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) {
245 context->framebufferTexture2D(target, GL_DEPTH_ATTACHMENT, m_target, 0, m_level);
246 context->framebufferTexture2D(target, GL_STENCIL_ATTACHMENT, m_targe t, 0, m_level);
247 } else {
248 context->framebufferTexture2D(target, attachment, m_target, 0, m_lev el);
249 }
239 } 250 }
240 } 251 }
241 252
242 GLenum WebGLTextureAttachment::type() const 253 GLenum WebGLTextureAttachment::type() const
243 { 254 {
244 return m_texture->getType(m_target, m_level); 255 return m_texture->getType(m_target, m_level);
245 } 256 }
246 257
247 bool isColorRenderable(GLenum internalformat) 258 bool isColorRenderable(GLenum internalformat)
248 { 259 {
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 { 354 {
344 // Attachments in |m_attachments| will be deleted from other 355 // Attachments in |m_attachments| will be deleted from other
345 // places, and we must not touch that map in deleteObjectImpl once 356 // places, and we must not touch that map in deleteObjectImpl once
346 // the destructor has been entered. 357 // the destructor has been entered.
347 m_destructionInProgress = true; 358 m_destructionInProgress = true;
348 359
349 // See the comment in WebGLObject::detachAndDeleteObject(). 360 // See the comment in WebGLObject::detachAndDeleteObject().
350 detachAndDeleteObject(); 361 detachAndDeleteObject();
351 } 362 }
352 363
353 void WebGLFramebuffer::setAttachmentForBoundFramebuffer(GLenum target, GLenum at tachment, GLenum texTarget, WebGLTexture* texture, GLint level) 364 void WebGLFramebuffer::setAttachmentForBoundFramebuffer(GLenum target, GLenum at tachment, GLenum texTarget, WebGLTexture* texture, GLint level, GLint layer)
354 { 365 {
355 ASSERT(isBound(target)); 366 ASSERT(isBound(target));
356 removeAttachmentFromBoundFramebuffer(target, attachment); 367 removeAttachmentFromBoundFramebuffer(target, attachment);
357 if (!m_object) 368 if (!m_object)
358 return; 369 return;
359 if (texture && texture->object()) { 370 if (texture && texture->object()) {
360 m_attachments.add(attachment, WebGLTextureAttachment::create(texture, te xTarget, level)); 371 m_attachments.add(attachment, WebGLTextureAttachment::create(texture, te xTarget, level, 0));
361 drawBuffersIfNecessary(false); 372 drawBuffersIfNecessary(false);
362 texture->onAttached(); 373 texture->onAttached();
363 } 374 }
364 } 375 }
365 376
366 void WebGLFramebuffer::setAttachmentForBoundFramebuffer(GLenum target, GLenum at tachment, WebGLRenderbuffer* renderbuffer) 377 void WebGLFramebuffer::setAttachmentForBoundFramebuffer(GLenum target, GLenum at tachment, WebGLRenderbuffer* renderbuffer)
367 { 378 {
368 ASSERT(isBound(target)); 379 ASSERT(isBound(target));
369 removeAttachmentFromBoundFramebuffer(target, attachment); 380 removeAttachmentFromBoundFramebuffer(target, attachment);
370 if (!m_object) 381 if (!m_object)
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 return true; 671 return true;
661 } 672 }
662 673
663 DEFINE_TRACE(WebGLFramebuffer) 674 DEFINE_TRACE(WebGLFramebuffer)
664 { 675 {
665 visitor->trace(m_attachments); 676 visitor->trace(m_attachments);
666 WebGLContextObject::trace(visitor); 677 WebGLContextObject::trace(visitor);
667 } 678 }
668 679
669 } 680 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698