| 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 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 namespace blink { | 31 namespace blink { |
| 32 | 32 |
| 33 WebGLTexture* WebGLTexture::create(WebGLRenderingContextBase* ctx) | 33 WebGLTexture* WebGLTexture::create(WebGLRenderingContextBase* ctx) |
| 34 { | 34 { |
| 35 return new WebGLTexture(ctx); | 35 return new WebGLTexture(ctx); |
| 36 } | 36 } |
| 37 | 37 |
| 38 WebGLTexture::WebGLTexture(WebGLRenderingContextBase* ctx) | 38 WebGLTexture::WebGLTexture(WebGLRenderingContextBase* ctx) |
| 39 : WebGLSharedPlatform3DObject(ctx) | 39 : WebGLSharedPlatform3DObject(ctx) |
| 40 , m_colorFormat(0) |
| 40 , m_target(0) | 41 , m_target(0) |
| 41 { | 42 { |
| 42 GLuint texture; | 43 GLuint texture; |
| 43 ctx->contextGL()->GenTextures(1, &texture); | 44 ctx->contextGL()->GenTextures(1, &texture); |
| 44 setObject(texture); | 45 setObject(texture); |
| 45 } | 46 } |
| 46 | 47 |
| 47 WebGLTexture::~WebGLTexture() | 48 WebGLTexture::~WebGLTexture() |
| 48 { | 49 { |
| 49 // See the comment in WebGLObject::detachAndDeleteObject(). | 50 // See the comment in WebGLObject::detachAndDeleteObject(). |
| 50 detachAndDeleteObject(); | 51 detachAndDeleteObject(); |
| 51 } | 52 } |
| 52 | 53 |
| 53 void WebGLTexture::setTarget(GLenum target) | 54 void WebGLTexture::setTarget(GLenum target) |
| 54 { | 55 { |
| 55 if (!object()) | 56 if (!object()) |
| 56 return; | 57 return; |
| 57 // Target is finalized the first time bindTexture() is called. | 58 // Target is finalized the first time bindTexture() is called. |
| 58 if (m_target) | 59 if (m_target) |
| 59 return; | 60 return; |
| 60 m_target = target; | 61 m_target = target; |
| 61 } | 62 } |
| 62 | 63 |
| 64 void WebGLTexture::setColorFormat(GLenum format) |
| 65 { |
| 66 if (!object()) |
| 67 return; |
| 68 m_colorFormat = format; |
| 69 } |
| 70 |
| 63 void WebGLTexture::deleteObjectImpl(gpu::gles2::GLES2Interface* gl) | 71 void WebGLTexture::deleteObjectImpl(gpu::gles2::GLES2Interface* gl) |
| 64 { | 72 { |
| 65 gl->DeleteTextures(1, &m_object); | 73 gl->DeleteTextures(1, &m_object); |
| 66 m_object = 0; | 74 m_object = 0; |
| 67 } | 75 } |
| 68 | 76 |
| 69 int WebGLTexture::mapTargetToIndex(GLenum target) const | 77 int WebGLTexture::mapTargetToIndex(GLenum target) const |
| 70 { | 78 { |
| 71 if (m_target == GL_TEXTURE_2D) { | 79 if (m_target == GL_TEXTURE_2D) { |
| 72 if (target == GL_TEXTURE_2D) | 80 if (target == GL_TEXTURE_2D) |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 if (x) { | 118 if (x) { |
| 111 value = x; | 119 value = x; |
| 112 log += shift; | 120 log += shift; |
| 113 } | 121 } |
| 114 } | 122 } |
| 115 ASSERT(value == 1); | 123 ASSERT(value == 1); |
| 116 return log + 1; | 124 return log + 1; |
| 117 } | 125 } |
| 118 | 126 |
| 119 } // namespace blink | 127 } // namespace blink |
| OLD | NEW |