Changeset 69172 in webkit
- Timestamp:
- Oct 5, 2010 8:41:47 PM (13 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r69170 r69172 1 2010-10-05 W. James MacLean <wjmaclean@chromium.org> 2 3 Reviewed by James Robinson. 4 5 [chromium] Add mipmap support for ImageLayerChromium 6 https://bugs.webkit.org/show_bug.cgi?id=46493 7 8 Mipmap behaviour can be tested with existing tests. 9 Tests in LayoutTests/compositing/images/ will detect if 10 mipmaps fail. 11 12 * platform/graphics/chromium/ContentLayerChromium.cpp: 13 (WebCore::ContentLayerChromium::SharedValues::SharedValues): 14 (WebCore::isPowerOfTwo): 15 (WebCore::ContentLayerChromium::updateTextureRect): 16 * platform/graphics/chromium/ContentLayerChromium.h: 17 (WebCore::ContentLayerChromium::SharedValues::npotSupported): 18 * platform/graphics/chromium/ImageLayerChromium.cpp: 19 (WebCore::ImageLayerChromium::updateContents): 20 1 21 2010-10-05 Adam Barth <abarth@webkit.org> 2 22 -
trunk/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp
r69166 r69172 58 58 , m_shaderAlphaLocation(-1) 59 59 , m_initialized(false) 60 , m_npotSupported(false) 60 61 { 61 62 // Shaders for drawing the layer contents. … … 104 105 ASSERT(m_shaderAlphaLocation != -1); 105 106 107 m_npotSupported = GLC(context, context->getString(GraphicsContext3D::EXTENSIONS).contains("GL_OES_texture_npot")); 108 106 109 m_initialized = true; 107 110 } … … 240 243 } 241 244 242 void ContentLayerChromium::updateTextureRect(void* pixels, const IntSize& bitmapSize, const IntSize& requiredTextureSize, const IntRect& updateRect, unsigned textureId) 245 static inline bool isPowerOfTwo(int x) 246 { 247 ASSERT(x >= 0); 248 return !(x & (x-1)); 249 } 250 251 void ContentLayerChromium::updateTextureRect(void* pixels, const IntSize& bitmapSize, 252 const IntSize& requiredTextureSize, const IntRect& updateRect, unsigned textureId, MipmapUse requestMipmap) 243 253 { 244 254 if (!pixels) … … 247 257 GraphicsContext3D* context = layerRendererContext(); 248 258 context->bindTexture(GraphicsContext3D::TEXTURE_2D, textureId); 259 260 bool generateMipmap = (requestMipmap == useMipmap) 261 && (layerRenderer()->contentLayerSharedValues()->npotSupported() 262 || (isPowerOfTwo(updateRect.width()) && isPowerOfTwo(updateRect.height()))); 249 263 250 264 // If the texture id or size changed since last time then we need to tell GL … … 253 267 ASSERT(bitmapSize == requiredTextureSize); 254 268 GLC(context, context->texImage2D(GraphicsContext3D::TEXTURE_2D, 0, GraphicsContext3D::RGBA, requiredTextureSize.width(), requiredTextureSize.height(), 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, pixels)); 269 if (generateMipmap) { 270 GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, 271 GraphicsContext3D::LINEAR_MIPMAP_LINEAR)); 272 GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, 273 GraphicsContext3D::LINEAR)); 274 } else { 275 GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, 276 GraphicsContext3D::LINEAR)); 277 GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, 278 GraphicsContext3D::LINEAR)); 279 } 255 280 256 281 m_contentsTexture = textureId; … … 261 286 GLC(context, context->texSubImage2D(GraphicsContext3D::TEXTURE_2D, 0, updateRect.x(), updateRect.y(), updateRect.width(), updateRect.height(), GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, pixels)); 262 287 } 288 289 if (generateMipmap) 290 GLC(context, context->generateMipmap(GraphicsContext3D::TEXTURE_2D)); 263 291 264 292 m_dirtyRect.setSize(FloatSize()); -
trunk/WebCore/platform/graphics/chromium/ContentLayerChromium.h
r69166 r69172 64 64 int shaderAlphaLocation() const { return m_shaderAlphaLocation; } 65 65 int initialized() const { return m_initialized; } 66 bool npotSupported() const { return m_npotSupported; } 66 67 67 68 private: … … 72 73 int m_shaderAlphaLocation; 73 74 int m_initialized; 75 bool m_npotSupported; 74 76 }; 75 77 … … 77 79 ContentLayerChromium(GraphicsLayerChromium* owner); 78 80 81 enum MipmapUse {noMipmap, useMipmap}; 82 79 83 void updateTextureRect(void* pixels, const IntSize& bitmapSize, const IntSize& requiredTextureSize, 80 const IntRect& updateRect, unsigned textureId );84 const IntRect& updateRect, unsigned textureId, MipmapUse generateMipmap = noMipmap); 81 85 82 86 virtual void cleanupResources(); -
trunk/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp
r67714 r69172 153 153 154 154 if (pixels) 155 updateTextureRect(pixels, bitmapSize, requiredTextureSize, dirtyRect, textureId );155 updateTextureRect(pixels, bitmapSize, requiredTextureSize, dirtyRect, textureId, useMipmap); 156 156 } 157 157
Note: See TracChangeset
for help on using the changeset viewer.