| 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 13 matching lines...) Expand all Loading... |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #ifndef WebGLTexture_h | 26 #ifndef WebGLTexture_h |
| 27 #define WebGLTexture_h | 27 #define WebGLTexture_h |
| 28 | 28 |
| 29 #include "modules/webgl/WebGLSharedPlatform3DObject.h" | 29 #include "modules/webgl/WebGLSharedPlatform3DObject.h" |
| 30 #include "wtf/Vector.h" | 30 #include "wtf/Vector.h" |
| 31 | 31 |
| 32 namespace blink { | 32 namespace blink { |
| 33 | 33 |
| 34 struct WebGLSamplerState { |
| 35 WebGLSamplerState(); |
| 36 |
| 37 GLenum compreFunc; |
| 38 GLenum compreMode; |
| 39 GLenum magFilter; |
| 40 GLenum minFilter; |
| 41 GLenum wrapR; |
| 42 GLenum wrapS; |
| 43 GLenum wrapT; |
| 44 GLfloat maxLod; |
| 45 GLfloat minLod; |
| 46 }; |
| 47 |
| 34 class WebGLTexture final : public WebGLSharedPlatform3DObject { | 48 class WebGLTexture final : public WebGLSharedPlatform3DObject { |
| 35 DEFINE_WRAPPERTYPEINFO(); | 49 DEFINE_WRAPPERTYPEINFO(); |
| 36 public: | 50 public: |
| 37 enum TextureExtensionFlag { | 51 enum TextureExtensionFlag { |
| 38 NoTextureExtensionEnabled = 0, | 52 NoTextureExtensionEnabled = 0, |
| 39 TextureFloatLinearExtensionEnabled = 1 << 0, | 53 TextureFloatLinearExtensionEnabled = 1 << 0, |
| 40 TextureHalfFloatLinearExtensionEnabled = 1 << 1 | 54 TextureHalfFloatLinearExtensionEnabled = 1 << 1 |
| 41 }; | 55 }; |
| 42 ~WebGLTexture() override; | 56 ~WebGLTexture() override; |
| 43 | 57 |
| 44 static WebGLTexture* create(WebGLRenderingContextBase*); | 58 static WebGLTexture* create(WebGLRenderingContextBase*); |
| 45 | 59 |
| 46 void setTarget(GLenum target, GLint maxLevel); | 60 void setTarget(GLenum target, GLint maxLevel); |
| 47 void setParameteri(GLenum pname, GLint param); | 61 void setParameteri(GLenum pname, GLint param); |
| 48 void setParameterf(GLenum pname, GLfloat param); | 62 void setParameterf(GLenum pname, GLfloat param); |
| 49 | 63 |
| 50 GLenum getTarget() const { return m_target; } | 64 GLenum getTarget() const { return m_target; } |
| 51 | 65 |
| 52 int getMinFilter() const { return m_minFilter; } | 66 int getMinFilter() const { return m_samplerState.minFilter; } |
| 53 | 67 |
| 54 void setLevelInfo(GLenum target, GLint level, GLenum internalFormat, GLsizei
width, GLsizei height, GLsizei depth, GLenum type); | 68 void setLevelInfo(GLenum target, GLint level, GLenum internalFormat, GLsizei
width, GLsizei height, GLsizei depth, GLenum type); |
| 55 void setTexStorageInfo(GLenum target, GLint levels, GLenum internalFormat, G
Lsizei width, GLsizei height, GLsizei depth); | 69 void setTexStorageInfo(GLenum target, GLint levels, GLenum internalFormat, G
Lsizei width, GLsizei height, GLsizei depth); |
| 56 | 70 |
| 57 bool canGenerateMipmaps(); | 71 bool canGenerateMipmaps(); |
| 58 // Generate all level information. | 72 // Generate all level information. |
| 59 void generateMipmapLevelInfo(); | 73 void generateMipmapLevelInfo(); |
| 60 | 74 |
| 61 GLenum getInternalFormat(GLenum target, GLint level) const; | 75 GLenum getInternalFormat(GLenum target, GLint level) const; |
| 62 GLenum getType(GLenum target, GLint level) const; | 76 GLenum getType(GLenum target, GLint level) const; |
| 63 GLsizei getWidth(GLenum target, GLint level) const; | 77 GLsizei getWidth(GLenum target, GLint level) const; |
| 64 GLsizei getHeight(GLenum target, GLint level) const; | 78 GLsizei getHeight(GLenum target, GLint level) const; |
| 65 GLsizei getDepth(GLenum target, GLint level) const; | 79 GLsizei getDepth(GLenum target, GLint level) const; |
| 66 bool isValid(GLenum target, GLint level) const; | 80 bool isValid(GLenum target, GLint level) const; |
| 67 bool isImmutable() const { return m_immutable; } | 81 bool isImmutable() const { return m_immutable; } |
| 68 | 82 |
| 69 static GLenum getValidFormatForInternalFormat(GLenum); | 83 static GLenum getValidFormatForInternalFormat(GLenum); |
| 70 | 84 |
| 71 bool isCubeComplete() const { return m_isCubeComplete; } | 85 bool isCubeComplete() const { return m_isCubeComplete; } |
| 72 | 86 |
| 73 // Whether width/height is NotPowerOfTwo. | 87 // Whether width/height is NotPowerOfTwo. |
| 74 static bool isNPOT(GLsizei, GLsizei); | 88 static bool isNPOT(GLsizei, GLsizei); |
| 75 | 89 |
| 76 bool isNPOT() const; | 90 bool isNPOT() const; |
| 77 // Determine if texture sampling should always return [0, 0, 0, 1] (OpenGL E
S 2.0 Sec 3.8.2). | 91 // Determine if texture sampling should always return [0, 0, 0, 1] (OpenGL E
S 2.0 Sec 3.8.2). |
| 78 bool needToUseBlackTexture(TextureExtensionFlag) const; | 92 bool needToUseBlackTexture(TextureExtensionFlag, const WebGLSamplerState*) c
onst; |
| 79 | 93 |
| 80 bool hasEverBeenBound() const { return object() && m_target; } | 94 bool hasEverBeenBound() const { return object() && m_target; } |
| 81 | 95 |
| 82 static GLint computeLevelCount(GLsizei width, GLsizei height, GLsizei depth)
; | 96 static GLint computeLevelCount(GLsizei width, GLsizei height, GLsizei depth)
; |
| 83 static GLenum getValidTypeForInternalFormat(GLenum); | 97 static GLenum getValidTypeForInternalFormat(GLenum); |
| 84 | 98 |
| 99 const WebGLSamplerState* getSamplerState() const { return &m_samplerState; } |
| 100 |
| 85 private: | 101 private: |
| 86 explicit WebGLTexture(WebGLRenderingContextBase*); | 102 explicit WebGLTexture(WebGLRenderingContextBase*); |
| 87 | 103 |
| 88 void deleteObjectImpl(WebGraphicsContext3D*) override; | 104 void deleteObjectImpl(WebGraphicsContext3D*) override; |
| 89 | 105 |
| 90 class LevelInfo { | 106 class LevelInfo { |
| 91 public: | 107 public: |
| 92 LevelInfo() | 108 LevelInfo() |
| 93 : valid(false) | 109 : valid(false) |
| 94 , internalFormat(0) | 110 , internalFormat(0) |
| (...skipping 25 matching lines...) Expand all Loading... |
| 120 bool isTexture() const override { return true; } | 136 bool isTexture() const override { return true; } |
| 121 | 137 |
| 122 void update(); | 138 void update(); |
| 123 | 139 |
| 124 int mapTargetToIndex(GLenum) const; | 140 int mapTargetToIndex(GLenum) const; |
| 125 | 141 |
| 126 const LevelInfo* getLevelInfo(GLenum target, GLint level) const; | 142 const LevelInfo* getLevelInfo(GLenum target, GLint level) const; |
| 127 | 143 |
| 128 GLenum m_target; | 144 GLenum m_target; |
| 129 | 145 |
| 130 GLenum m_minFilter; | 146 WebGLSamplerState m_samplerState; |
| 131 GLenum m_magFilter; | |
| 132 GLenum m_wrapR; | |
| 133 GLenum m_wrapS; | |
| 134 GLenum m_wrapT; | |
| 135 | 147 |
| 136 Vector<Vector<LevelInfo>> m_info; | 148 Vector<Vector<LevelInfo>> m_info; |
| 137 | 149 |
| 138 bool m_isNPOT; | 150 bool m_isNPOT; |
| 139 bool m_isCubeComplete; | 151 bool m_isCubeComplete; |
| 140 bool m_isComplete; | 152 bool m_isComplete; |
| 141 bool m_needToUseBlackTexture; | 153 bool m_needToUseBlackTexture; |
| 142 bool m_isFloatType; | 154 bool m_isFloatType; |
| 143 bool m_isHalfFloatType; | 155 bool m_isHalfFloatType; |
| 144 bool m_isWebGL2OrHigher; | 156 bool m_isWebGL2OrHigher; |
| 145 bool m_immutable; | 157 bool m_immutable; |
| 146 size_t m_baseLevel; | 158 size_t m_baseLevel; |
| 147 size_t m_maxLevel; | 159 size_t m_maxLevel; |
| 148 }; | 160 }; |
| 149 | 161 |
| 150 } // namespace blink | 162 } // namespace blink |
| 151 | 163 |
| 152 #endif // WebGLTexture_h | 164 #endif // WebGLTexture_h |
| OLD | NEW |