| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google 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 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 if (n != 1) { | 74 if (n != 1) { |
| 75 scoped.context()->synthesizeGLError(GL_INVALID_OPERATION, "drawBuffe
rsWEBGL", "must provide exactly one buffer"); | 75 scoped.context()->synthesizeGLError(GL_INVALID_OPERATION, "drawBuffe
rsWEBGL", "must provide exactly one buffer"); |
| 76 return; | 76 return; |
| 77 } | 77 } |
| 78 if (bufs[0] != GL_BACK && bufs[0] != GL_NONE) { | 78 if (bufs[0] != GL_BACK && bufs[0] != GL_NONE) { |
| 79 scoped.context()->synthesizeGLError(GL_INVALID_OPERATION, "drawBuffe
rsWEBGL", "BACK or NONE"); | 79 scoped.context()->synthesizeGLError(GL_INVALID_OPERATION, "drawBuffe
rsWEBGL", "BACK or NONE"); |
| 80 return; | 80 return; |
| 81 } | 81 } |
| 82 // Because the backbuffer is simulated on all current WebKit ports, we n
eed to change BACK to COLOR_ATTACHMENT0. | 82 // Because the backbuffer is simulated on all current WebKit ports, we n
eed to change BACK to COLOR_ATTACHMENT0. |
| 83 GLenum value = (bufs[0] == GL_BACK) ? GL_COLOR_ATTACHMENT0 : GL_NONE; | 83 GLenum value = (bufs[0] == GL_BACK) ? GL_COLOR_ATTACHMENT0 : GL_NONE; |
| 84 scoped.context()->webContext()->drawBuffersEXT(1, &value); | 84 scoped.context()->contextGL()->DrawBuffersEXT(1, &value); |
| 85 scoped.context()->setBackDrawBuffer(bufs[0]); | 85 scoped.context()->setBackDrawBuffer(bufs[0]); |
| 86 } else { | 86 } else { |
| 87 if (n > scoped.context()->maxDrawBuffers()) { | 87 if (n > scoped.context()->maxDrawBuffers()) { |
| 88 scoped.context()->synthesizeGLError(GL_INVALID_VALUE, "drawBuffersWE
BGL", "more than max draw buffers"); | 88 scoped.context()->synthesizeGLError(GL_INVALID_VALUE, "drawBuffersWE
BGL", "more than max draw buffers"); |
| 89 return; | 89 return; |
| 90 } | 90 } |
| 91 for (GLsizei i = 0; i < n; ++i) { | 91 for (GLsizei i = 0; i < n; ++i) { |
| 92 if (bufs[i] != GL_NONE && bufs[i] != static_cast<GLenum>(GL_COLOR_AT
TACHMENT0_EXT + i)) { | 92 if (bufs[i] != GL_NONE && bufs[i] != static_cast<GLenum>(GL_COLOR_AT
TACHMENT0_EXT + i)) { |
| 93 scoped.context()->synthesizeGLError(GL_INVALID_OPERATION, "drawB
uffersWEBGL", "COLOR_ATTACHMENTi_EXT or NONE"); | 93 scoped.context()->synthesizeGLError(GL_INVALID_OPERATION, "drawB
uffersWEBGL", "COLOR_ATTACHMENTi_EXT or NONE"); |
| 94 return; | 94 return; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 119 const unsigned char* buffer = 0; // Chromium doesn't allow init data for dep
th/stencil tetxures. | 119 const unsigned char* buffer = 0; // Chromium doesn't allow init data for dep
th/stencil tetxures. |
| 120 bool supportsDepth = (extensionsUtil->supportsExtension("GL_CHROMIUM_depth_t
exture") | 120 bool supportsDepth = (extensionsUtil->supportsExtension("GL_CHROMIUM_depth_t
exture") |
| 121 || extensionsUtil->supportsExtension("GL_OES_depth_texture") | 121 || extensionsUtil->supportsExtension("GL_OES_depth_texture") |
| 122 || extensionsUtil->supportsExtension("GL_ARB_depth_texture")); | 122 || extensionsUtil->supportsExtension("GL_ARB_depth_texture")); |
| 123 bool supportsDepthStencil = (extensionsUtil->supportsExtension("GL_EXT_packe
d_depth_stencil") | 123 bool supportsDepthStencil = (extensionsUtil->supportsExtension("GL_EXT_packe
d_depth_stencil") |
| 124 || extensionsUtil->supportsExtension("GL_OES_packed_depth_stencil")); | 124 || extensionsUtil->supportsExtension("GL_OES_packed_depth_stencil")); |
| 125 Platform3DObject depthStencil = 0; | 125 Platform3DObject depthStencil = 0; |
| 126 if (supportsDepthStencil) { | 126 if (supportsDepthStencil) { |
| 127 depthStencil = context->createTexture(); | 127 depthStencil = context->createTexture(); |
| 128 gl->BindTexture(GL_TEXTURE_2D, depthStencil); | 128 gl->BindTexture(GL_TEXTURE_2D, depthStencil); |
| 129 context->texImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_STENCIL_OES, 1, 1, 0, GL_
DEPTH_STENCIL_OES, GL_UNSIGNED_INT_24_8_OES, buffer); | 129 gl->TexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_STENCIL_OES, 1, 1, 0, GL_DEPTH
_STENCIL_OES, GL_UNSIGNED_INT_24_8_OES, buffer); |
| 130 } | 130 } |
| 131 Platform3DObject depth = 0; | 131 Platform3DObject depth = 0; |
| 132 if (supportsDepth) { | 132 if (supportsDepth) { |
| 133 depth = context->createTexture(); | 133 depth = context->createTexture(); |
| 134 gl->BindTexture(GL_TEXTURE_2D, depth); | 134 gl->BindTexture(GL_TEXTURE_2D, depth); |
| 135 context->texImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, 1, 1, 0, GL_DE
PTH_COMPONENT, GL_UNSIGNED_INT, buffer); | 135 gl->TexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, 1, 1, 0, GL_DEPTH_C
OMPONENT, GL_UNSIGNED_INT, buffer); |
| 136 } | 136 } |
| 137 | 137 |
| 138 Vector<Platform3DObject> colors; | 138 Vector<Platform3DObject> colors; |
| 139 bool ok = true; | 139 bool ok = true; |
| 140 GLint maxAllowedBuffers = std::min(maxDrawBuffers, maxColorAttachments); | 140 GLint maxAllowedBuffers = std::min(maxDrawBuffers, maxColorAttachments); |
| 141 for (GLint i = 0; i < maxAllowedBuffers; ++i) { | 141 for (GLint i = 0; i < maxAllowedBuffers; ++i) { |
| 142 Platform3DObject color = context->createTexture(); | 142 Platform3DObject color = context->createTexture(); |
| 143 colors.append(color); | 143 colors.append(color); |
| 144 gl->BindTexture(GL_TEXTURE_2D, color); | 144 gl->BindTexture(GL_TEXTURE_2D, color); |
| 145 context->texImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSI
GNED_BYTE, buffer); | 145 gl->TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_
BYTE, buffer); |
| 146 gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, GL_TE
XTURE_2D, color, 0); | 146 gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, GL_TE
XTURE_2D, color, 0); |
| 147 if (gl->CheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLET
E) { | 147 if (gl->CheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLET
E) { |
| 148 ok = false; | 148 ok = false; |
| 149 break; | 149 break; |
| 150 } | 150 } |
| 151 if (supportsDepth) { | 151 if (supportsDepth) { |
| 152 gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEX
TURE_2D, depth, 0); | 152 gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEX
TURE_2D, depth, 0); |
| 153 if (gl->CheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COM
PLETE) { | 153 if (gl->CheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COM
PLETE) { |
| 154 ok = false; | 154 ok = false; |
| 155 break; | 155 break; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 174 if (supportsDepth) | 174 if (supportsDepth) |
| 175 context->deleteTexture(depth); | 175 context->deleteTexture(depth); |
| 176 if (supportsDepthStencil) | 176 if (supportsDepthStencil) |
| 177 context->deleteTexture(depthStencil); | 177 context->deleteTexture(depthStencil); |
| 178 for (size_t i = 0; i < colors.size(); ++i) | 178 for (size_t i = 0; i < colors.size(); ++i) |
| 179 context->deleteTexture(colors[i]); | 179 context->deleteTexture(colors[i]); |
| 180 return ok; | 180 return ok; |
| 181 } | 181 } |
| 182 | 182 |
| 183 } // namespace blink | 183 } // namespace blink |
| OLD | NEW |