| 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" | |
| 29 #include "modules/webgl/WebGLRenderingContextBase.h" | 28 #include "modules/webgl/WebGLRenderingContextBase.h" |
| 30 | 29 |
| 31 namespace blink { | 30 namespace blink { |
| 32 | 31 |
| 33 WebGLTexture* WebGLTexture::create(WebGLRenderingContextBase* ctx) | 32 WebGLTexture* WebGLTexture::create(WebGLRenderingContextBase* ctx) |
| 34 { | 33 { |
| 35 return new WebGLTexture(ctx); | 34 return new WebGLTexture(ctx); |
| 36 } | 35 } |
| 37 | 36 |
| 38 WebGLTexture::WebGLTexture(WebGLRenderingContextBase* ctx) | 37 WebGLTexture::WebGLTexture(WebGLRenderingContextBase* ctx) |
| 39 : WebGLSharedPlatform3DObject(ctx) | 38 : WebGLSharedPlatform3DObject(ctx) |
| 40 , m_target(0) | 39 , m_target(0) |
| 41 { | 40 { |
| 42 GLuint texture; | 41 setObject(ctx->webContext()->createTexture()); |
| 43 ctx->contextGL()->GenTextures(1, &texture); | |
| 44 setObject(texture); | |
| 45 } | 42 } |
| 46 | 43 |
| 47 WebGLTexture::~WebGLTexture() | 44 WebGLTexture::~WebGLTexture() |
| 48 { | 45 { |
| 49 // See the comment in WebGLObject::detachAndDeleteObject(). | 46 // See the comment in WebGLObject::detachAndDeleteObject(). |
| 50 detachAndDeleteObject(); | 47 detachAndDeleteObject(); |
| 51 } | 48 } |
| 52 | 49 |
| 53 void WebGLTexture::setTarget(GLenum target) | 50 void WebGLTexture::setTarget(GLenum target) |
| 54 { | 51 { |
| 55 if (!object()) | 52 if (!object()) |
| 56 return; | 53 return; |
| 57 // Target is finalized the first time bindTexture() is called. | 54 // Target is finalized the first time bindTexture() is called. |
| 58 if (m_target) | 55 if (m_target) |
| 59 return; | 56 return; |
| 60 m_target = target; | 57 m_target = target; |
| 61 } | 58 } |
| 62 | 59 |
| 63 void WebGLTexture::deleteObjectImpl(WebGraphicsContext3D* context3d, gpu::gles2:
:GLES2Interface* gl) | 60 void WebGLTexture::deleteObjectImpl(WebGraphicsContext3D* context3d, gpu::gles2:
:GLES2Interface* gl) |
| 64 { | 61 { |
| 65 gl->DeleteTextures(1, &m_object); | 62 context3d->deleteTexture(m_object); |
| 66 m_object = 0; | 63 m_object = 0; |
| 67 } | 64 } |
| 68 | 65 |
| 69 int WebGLTexture::mapTargetToIndex(GLenum target) const | 66 int WebGLTexture::mapTargetToIndex(GLenum target) const |
| 70 { | 67 { |
| 71 if (m_target == GL_TEXTURE_2D) { | 68 if (m_target == GL_TEXTURE_2D) { |
| 72 if (target == GL_TEXTURE_2D) | 69 if (target == GL_TEXTURE_2D) |
| 73 return 0; | 70 return 0; |
| 74 } else if (m_target == GL_TEXTURE_CUBE_MAP) { | 71 } else if (m_target == GL_TEXTURE_CUBE_MAP) { |
| 75 switch (target) { | 72 switch (target) { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 if (x) { | 107 if (x) { |
| 111 value = x; | 108 value = x; |
| 112 log += shift; | 109 log += shift; |
| 113 } | 110 } |
| 114 } | 111 } |
| 115 ASSERT(value == 1); | 112 ASSERT(value == 1); |
| 116 return log + 1; | 113 return log + 1; |
| 117 } | 114 } |
| 118 | 115 |
| 119 } // namespace blink | 116 } // namespace blink |
| OLD | NEW |