OLD | NEW |
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 2201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2212 // FBO. | 2212 // FBO. |
2213 WebGLFramebuffer* framebufferBinding = getFramebufferBinding(target); | 2213 WebGLFramebuffer* framebufferBinding = getFramebufferBinding(target); |
2214 if (!framebufferBinding || !framebufferBinding->object()) { | 2214 if (!framebufferBinding || !framebufferBinding->object()) { |
2215 synthesizeGLError(GL_INVALID_OPERATION, "framebufferRenderbuffer", "no f
ramebuffer bound"); | 2215 synthesizeGLError(GL_INVALID_OPERATION, "framebufferRenderbuffer", "no f
ramebuffer bound"); |
2216 return; | 2216 return; |
2217 } | 2217 } |
2218 Platform3DObject bufferObject = objectOrZero(buffer); | 2218 Platform3DObject bufferObject = objectOrZero(buffer); |
2219 if (isWebGL2OrHigher() && attachment == GL_DEPTH_STENCIL_ATTACHMENT) { | 2219 if (isWebGL2OrHigher() && attachment == GL_DEPTH_STENCIL_ATTACHMENT) { |
2220 // On ES3, DEPTH_STENCIL_ATTACHMENT is like an alias for DEPTH_ATTACHMEN
T + STENCIL_ATTACHMENT. | 2220 // On ES3, DEPTH_STENCIL_ATTACHMENT is like an alias for DEPTH_ATTACHMEN
T + STENCIL_ATTACHMENT. |
2221 // We divide it here so in WebGLFramebuffer, we don't have to handle DEP
TH_STENCIL_ATTACHMENT in WebGL 2. | 2221 // We divide it here so in WebGLFramebuffer, we don't have to handle DEP
TH_STENCIL_ATTACHMENT in WebGL 2. |
2222 webContext()->framebufferRenderbuffer(target, GL_DEPTH_ATTACHMENT, rende
rbuffertarget, bufferObject); | 2222 contextGL()->FramebufferRenderbuffer(target, GL_DEPTH_ATTACHMENT, render
buffertarget, bufferObject); |
2223 webContext()->framebufferRenderbuffer(target, GL_STENCIL_ATTACHMENT, ren
derbuffertarget, bufferObject); | 2223 contextGL()->FramebufferRenderbuffer(target, GL_STENCIL_ATTACHMENT, rend
erbuffertarget, bufferObject); |
2224 framebufferBinding->setAttachmentForBoundFramebuffer(target, GL_DEPTH_AT
TACHMENT, buffer); | 2224 framebufferBinding->setAttachmentForBoundFramebuffer(target, GL_DEPTH_AT
TACHMENT, buffer); |
2225 framebufferBinding->setAttachmentForBoundFramebuffer(target, GL_STENCIL_
ATTACHMENT, buffer); | 2225 framebufferBinding->setAttachmentForBoundFramebuffer(target, GL_STENCIL_
ATTACHMENT, buffer); |
2226 preserveObjectWrapper(scriptState, framebufferBinding, "attachment", GL_
DEPTH_ATTACHMENT, buffer); | 2226 preserveObjectWrapper(scriptState, framebufferBinding, "attachment", GL_
DEPTH_ATTACHMENT, buffer); |
2227 preserveObjectWrapper(scriptState, framebufferBinding, "attachment", GL_
STENCIL_ATTACHMENT, buffer); | 2227 preserveObjectWrapper(scriptState, framebufferBinding, "attachment", GL_
STENCIL_ATTACHMENT, buffer); |
2228 } else { | 2228 } else { |
2229 webContext()->framebufferRenderbuffer(target, attachment, renderbufferta
rget, bufferObject); | 2229 contextGL()->FramebufferRenderbuffer(target, attachment, renderbuffertar
get, bufferObject); |
2230 framebufferBinding->setAttachmentForBoundFramebuffer(target, attachment,
buffer); | 2230 framebufferBinding->setAttachmentForBoundFramebuffer(target, attachment,
buffer); |
2231 preserveObjectWrapper(scriptState, framebufferBinding, "attachment", att
achment, buffer); | 2231 preserveObjectWrapper(scriptState, framebufferBinding, "attachment", att
achment, buffer); |
2232 } | 2232 } |
2233 applyStencilTest(); | 2233 applyStencilTest(); |
2234 } | 2234 } |
2235 | 2235 |
2236 void WebGLRenderingContextBase::framebufferTexture2D(ScriptState* scriptState, G
Lenum target, GLenum attachment, GLenum textarget, WebGLTexture* texture, GLint
level) | 2236 void WebGLRenderingContextBase::framebufferTexture2D(ScriptState* scriptState, G
Lenum target, GLenum attachment, GLenum textarget, WebGLTexture* texture, GLint
level) |
2237 { | 2237 { |
2238 if (isContextLost() || !validateFramebufferFuncParameters("framebufferTextur
e2D", target, attachment)) | 2238 if (isContextLost() || !validateFramebufferFuncParameters("framebufferTextur
e2D", target, attachment)) |
2239 return; | 2239 return; |
2240 if (texture && !texture->validate(contextGroup(), this)) { | 2240 if (texture && !texture->validate(contextGroup(), this)) { |
2241 synthesizeGLError(GL_INVALID_OPERATION, "framebufferTexture2D", "no text
ure or texture not from this context"); | 2241 synthesizeGLError(GL_INVALID_OPERATION, "framebufferTexture2D", "no text
ure or texture not from this context"); |
2242 return; | 2242 return; |
2243 } | 2243 } |
2244 // Don't allow the default framebuffer to be mutated; all current | 2244 // Don't allow the default framebuffer to be mutated; all current |
2245 // implementations use an FBO internally in place of the default | 2245 // implementations use an FBO internally in place of the default |
2246 // FBO. | 2246 // FBO. |
2247 WebGLFramebuffer* framebufferBinding = getFramebufferBinding(target); | 2247 WebGLFramebuffer* framebufferBinding = getFramebufferBinding(target); |
2248 if (!framebufferBinding || !framebufferBinding->object()) { | 2248 if (!framebufferBinding || !framebufferBinding->object()) { |
2249 synthesizeGLError(GL_INVALID_OPERATION, "framebufferTexture2D", "no fram
ebuffer bound"); | 2249 synthesizeGLError(GL_INVALID_OPERATION, "framebufferTexture2D", "no fram
ebuffer bound"); |
2250 return; | 2250 return; |
2251 } | 2251 } |
2252 Platform3DObject textureObject = objectOrZero(texture); | 2252 Platform3DObject textureObject = objectOrZero(texture); |
2253 if (isWebGL2OrHigher() && attachment == GL_DEPTH_STENCIL_ATTACHMENT) { | 2253 if (isWebGL2OrHigher() && attachment == GL_DEPTH_STENCIL_ATTACHMENT) { |
2254 // On ES3, DEPTH_STENCIL_ATTACHMENT is like an alias for DEPTH_ATTACHMEN
T + STENCIL_ATTACHMENT. | 2254 // On ES3, DEPTH_STENCIL_ATTACHMENT is like an alias for DEPTH_ATTACHMEN
T + STENCIL_ATTACHMENT. |
2255 // We divide it here so in WebGLFramebuffer, we don't have to handle DEP
TH_STENCIL_ATTACHMENT in WebGL 2. | 2255 // We divide it here so in WebGLFramebuffer, we don't have to handle DEP
TH_STENCIL_ATTACHMENT in WebGL 2. |
2256 webContext()->framebufferTexture2D(target, GL_DEPTH_ATTACHMENT, textarge
t, textureObject, level); | 2256 contextGL()->FramebufferTexture2D(target, GL_DEPTH_ATTACHMENT, textarget
, textureObject, level); |
2257 webContext()->framebufferTexture2D(target, GL_STENCIL_ATTACHMENT, textar
get, textureObject, level); | 2257 contextGL()->FramebufferTexture2D(target, GL_STENCIL_ATTACHMENT, textarg
et, textureObject, level); |
2258 framebufferBinding->setAttachmentForBoundFramebuffer(target, GL_DEPTH_AT
TACHMENT, textarget, texture, level, 0); | 2258 framebufferBinding->setAttachmentForBoundFramebuffer(target, GL_DEPTH_AT
TACHMENT, textarget, texture, level, 0); |
2259 framebufferBinding->setAttachmentForBoundFramebuffer(target, GL_STENCIL_
ATTACHMENT, textarget, texture, level, 0); | 2259 framebufferBinding->setAttachmentForBoundFramebuffer(target, GL_STENCIL_
ATTACHMENT, textarget, texture, level, 0); |
2260 preserveObjectWrapper(scriptState, framebufferBinding, "attachment", GL_
DEPTH_ATTACHMENT, texture); | 2260 preserveObjectWrapper(scriptState, framebufferBinding, "attachment", GL_
DEPTH_ATTACHMENT, texture); |
2261 preserveObjectWrapper(scriptState, framebufferBinding, "attachment", GL_
STENCIL_ATTACHMENT, texture); | 2261 preserveObjectWrapper(scriptState, framebufferBinding, "attachment", GL_
STENCIL_ATTACHMENT, texture); |
2262 } else { | 2262 } else { |
2263 webContext()->framebufferTexture2D(target, attachment, textarget, textur
eObject, level); | 2263 contextGL()->FramebufferTexture2D(target, attachment, textarget, texture
Object, level); |
2264 framebufferBinding->setAttachmentForBoundFramebuffer(target, attachment,
textarget, texture, level, 0); | 2264 framebufferBinding->setAttachmentForBoundFramebuffer(target, attachment,
textarget, texture, level, 0); |
2265 preserveObjectWrapper(scriptState, framebufferBinding, "attachment", att
achment, texture); | 2265 preserveObjectWrapper(scriptState, framebufferBinding, "attachment", att
achment, texture); |
2266 } | 2266 } |
2267 applyStencilTest(); | 2267 applyStencilTest(); |
2268 } | 2268 } |
2269 | 2269 |
2270 void WebGLRenderingContextBase::frontFace(GLenum mode) | 2270 void WebGLRenderingContextBase::frontFace(GLenum mode) |
2271 { | 2271 { |
2272 if (isContextLost()) | 2272 if (isContextLost()) |
2273 return; | 2273 return; |
(...skipping 1808 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4082 ScopedTexture2DRestorer restorer(gl); | 4082 ScopedTexture2DRestorer restorer(gl); |
4083 if (!gl->drawingBuffer()->copyToPlatformTexture(webContext(), targetText
ure, targetInternalformat, targetType, | 4083 if (!gl->drawingBuffer()->copyToPlatformTexture(webContext(), targetText
ure, targetInternalformat, targetType, |
4084 targetLevel, m_unpackPremultiplyAlpha, !m_unpackFlipY, BackBuffer))
{ | 4084 targetLevel, m_unpackPremultiplyAlpha, !m_unpackFlipY, BackBuffer))
{ |
4085 ASSERT_NOT_REACHED(); | 4085 ASSERT_NOT_REACHED(); |
4086 } | 4086 } |
4087 } | 4087 } |
4088 | 4088 |
4089 if (!possibleDirectCopy) { | 4089 if (!possibleDirectCopy) { |
4090 WebGLId tmpFBO = webContext()->createFramebuffer(); | 4090 WebGLId tmpFBO = webContext()->createFramebuffer(); |
4091 webContext()->bindFramebuffer(GL_FRAMEBUFFER, tmpFBO); | 4091 webContext()->bindFramebuffer(GL_FRAMEBUFFER, tmpFBO); |
4092 webContext()->framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
GL_TEXTURE_2D, targetTexture, 0); | 4092 contextGL()->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
GL_TEXTURE_2D, targetTexture, 0); |
4093 webContext()->bindTexture(texture->getTarget(), texture->object()); | 4093 webContext()->bindTexture(texture->getTarget(), texture->object()); |
4094 if (functionType == TexImage2DByGPU) { | 4094 if (functionType == TexImage2DByGPU) { |
4095 webContext()->copyTexSubImage2D(target, level, 0, 0, 0, 0, canvas->w
idth(), canvas->height()); | 4095 webContext()->copyTexSubImage2D(target, level, 0, 0, 0, 0, canvas->w
idth(), canvas->height()); |
4096 } else if (functionType == TexSubImage2DByGPU) { | 4096 } else if (functionType == TexSubImage2DByGPU) { |
4097 webContext()->copyTexSubImage2D(target, level, xoffset, yoffset, 0,
0, canvas->width(), canvas->height()); | 4097 webContext()->copyTexSubImage2D(target, level, xoffset, yoffset, 0,
0, canvas->width(), canvas->height()); |
4098 } else if (functionType == TexSubImage3DByGPU) { | 4098 } else if (functionType == TexSubImage3DByGPU) { |
4099 webContext()->copyTexSubImage3D(target, level, xoffset, yoffset, zof
fset, 0, 0, canvas->width(), canvas->height()); | 4099 webContext()->copyTexSubImage3D(target, level, xoffset, yoffset, zof
fset, 0, 0, canvas->width(), canvas->height()); |
4100 } | 4100 } |
4101 webContext()->framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
GL_TEXTURE_2D, 0, 0); | 4101 contextGL()->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
GL_TEXTURE_2D, 0, 0); |
4102 restoreCurrentFramebuffer(); | 4102 restoreCurrentFramebuffer(); |
4103 webContext()->deleteFramebuffer(tmpFBO); | 4103 webContext()->deleteFramebuffer(tmpFBO); |
4104 webContext()->deleteTexture(targetTexture); | 4104 webContext()->deleteTexture(targetTexture); |
4105 } | 4105 } |
4106 } | 4106 } |
4107 | 4107 |
4108 void WebGLRenderingContextBase::texImage2D(GLenum target, GLint level, GLint int
ernalformat, | 4108 void WebGLRenderingContextBase::texImage2D(GLenum target, GLint level, GLint int
ernalformat, |
4109 GLenum format, GLenum type, HTMLCanvasElement* canvas, ExceptionState& excep
tionState) | 4109 GLenum format, GLenum type, HTMLCanvasElement* canvas, ExceptionState& excep
tionState) |
4110 { | 4110 { |
4111 if (isContextLost()) | 4111 if (isContextLost()) |
(...skipping 2176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6288 webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, 1); | 6288 webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, 1); |
6289 } | 6289 } |
6290 | 6290 |
6291 void WebGLRenderingContextBase::restoreUnpackParameters() | 6291 void WebGLRenderingContextBase::restoreUnpackParameters() |
6292 { | 6292 { |
6293 if (m_unpackAlignment != 1) | 6293 if (m_unpackAlignment != 1) |
6294 webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); | 6294 webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); |
6295 } | 6295 } |
6296 | 6296 |
6297 } // namespace blink | 6297 } // namespace blink |
OLD | NEW |