| 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 |
| 11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
| 12 * | 12 * |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
| 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
| 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #include "modules/webgl/WebGLTexture.h" | 26 #include "modules/webgl/WebGLTexture.h" |
| 27 | 27 |
| 28 #include "gpu/command_buffer/client/gles2_interface.h" |
| 28 #include "modules/webgl/WebGLRenderingContextBase.h" | 29 #include "modules/webgl/WebGLRenderingContextBase.h" |
| 29 | 30 |
| 30 namespace blink { | 31 namespace blink { |
| 31 | 32 |
| 32 WebGLTexture* WebGLTexture::create(WebGLRenderingContextBase* ctx) | 33 WebGLTexture* WebGLTexture::create(WebGLRenderingContextBase* ctx) |
| 33 { | 34 { |
| 34 return new WebGLTexture(ctx); | 35 return new WebGLTexture(ctx); |
| 35 } | 36 } |
| 36 | 37 |
| 37 WebGLTexture::WebGLTexture(WebGLRenderingContextBase* ctx) | 38 WebGLTexture::WebGLTexture(WebGLRenderingContextBase* ctx) |
| 38 : WebGLSharedPlatform3DObject(ctx) | 39 : WebGLSharedPlatform3DObject(ctx) |
| 39 , m_target(0) | 40 , m_target(0) |
| 40 { | 41 { |
| 41 setObject(ctx->webContext()->createTexture()); | 42 GLuint texture; |
| 43 ctx->contextGL()->GenTextures(1, &texture); |
| 44 setObject(texture); |
| 42 } | 45 } |
| 43 | 46 |
| 44 WebGLTexture::~WebGLTexture() | 47 WebGLTexture::~WebGLTexture() |
| 45 { | 48 { |
| 46 // See the comment in WebGLObject::detachAndDeleteObject(). | 49 // See the comment in WebGLObject::detachAndDeleteObject(). |
| 47 detachAndDeleteObject(); | 50 detachAndDeleteObject(); |
| 48 } | 51 } |
| 49 | 52 |
| 50 void WebGLTexture::setTarget(GLenum target) | 53 void WebGLTexture::setTarget(GLenum target) |
| 51 { | 54 { |
| 52 if (!object()) | 55 if (!object()) |
| 53 return; | 56 return; |
| 54 // Target is finalized the first time bindTexture() is called. | 57 // Target is finalized the first time bindTexture() is called. |
| 55 if (m_target) | 58 if (m_target) |
| 56 return; | 59 return; |
| 57 m_target = target; | 60 m_target = target; |
| 58 } | 61 } |
| 59 | 62 |
| 60 void WebGLTexture::deleteObjectImpl(WebGraphicsContext3D* context3d, gpu::gles2:
:GLES2Interface* gl) | 63 void WebGLTexture::deleteObjectImpl(WebGraphicsContext3D* context3d, gpu::gles2:
:GLES2Interface* gl) |
| 61 { | 64 { |
| 62 context3d->deleteTexture(m_object); | 65 gl->DeleteTextures(1, &m_object); |
| 63 m_object = 0; | 66 m_object = 0; |
| 64 } | 67 } |
| 65 | 68 |
| 66 int WebGLTexture::mapTargetToIndex(GLenum target) const | 69 int WebGLTexture::mapTargetToIndex(GLenum target) const |
| 67 { | 70 { |
| 68 if (m_target == GL_TEXTURE_2D) { | 71 if (m_target == GL_TEXTURE_2D) { |
| 69 if (target == GL_TEXTURE_2D) | 72 if (target == GL_TEXTURE_2D) |
| 70 return 0; | 73 return 0; |
| 71 } else if (m_target == GL_TEXTURE_CUBE_MAP) { | 74 } else if (m_target == GL_TEXTURE_CUBE_MAP) { |
| 72 switch (target) { | 75 switch (target) { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 if (x) { | 110 if (x) { |
| 108 value = x; | 111 value = x; |
| 109 log += shift; | 112 log += shift; |
| 110 } | 113 } |
| 111 } | 114 } |
| 112 ASSERT(value == 1); | 115 ASSERT(value == 1); |
| 113 return log + 1; | 116 return log + 1; |
| 114 } | 117 } |
| 115 | 118 |
| 116 } // namespace blink | 119 } // namespace blink |
| OLD | NEW |