| 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 2004 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2015 WebGLTexture* tex = validateTextureBinding("generateMipmap", target, false); | 2015 WebGLTexture* tex = validateTextureBinding("generateMipmap", target, false); |
| 2016 if (!tex) | 2016 if (!tex) |
| 2017 return; | 2017 return; |
| 2018 if (!tex->canGenerateMipmaps()) { | 2018 if (!tex->canGenerateMipmaps()) { |
| 2019 synthesizeGLError(GL_INVALID_OPERATION, "generateMipmap", "level 0 not p
ower of 2 or not all the same size"); | 2019 synthesizeGLError(GL_INVALID_OPERATION, "generateMipmap", "level 0 not p
ower of 2 or not all the same size"); |
| 2020 return; | 2020 return; |
| 2021 } | 2021 } |
| 2022 if (!validateSettableTexFormat("generateMipmap", tex->getInternalFormat(targ
et, 0))) | 2022 if (!validateSettableTexFormat("generateMipmap", tex->getInternalFormat(targ
et, 0))) |
| 2023 return; | 2023 return; |
| 2024 | 2024 |
| 2025 // generateMipmap won't work properly if minFilter is not NEAREST_MIPMAP_LIN
EAR | |
| 2026 // on Mac. Remove the hack once this driver bug is fixed. | |
| 2027 #if OS(MACOSX) | |
| 2028 bool needToResetMinFilter = false; | |
| 2029 if (tex->getMinFilter() != GL_NEAREST_MIPMAP_LINEAR) { | |
| 2030 webContext()->texParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MI
PMAP_LINEAR); | |
| 2031 needToResetMinFilter = true; | |
| 2032 } | |
| 2033 #endif | |
| 2034 webContext()->generateMipmap(target); | 2025 webContext()->generateMipmap(target); |
| 2035 #if OS(MACOSX) | |
| 2036 if (needToResetMinFilter) | |
| 2037 webContext()->texParameteri(target, GL_TEXTURE_MIN_FILTER, tex->getMinFi
lter()); | |
| 2038 #endif | |
| 2039 tex->generateMipmapLevelInfo(); | 2026 tex->generateMipmapLevelInfo(); |
| 2040 } | 2027 } |
| 2041 | 2028 |
| 2042 PassRefPtr<WebGLActiveInfo> WebGLRenderingContextBase::getActiveAttrib(WebGLProg
ram* program, GLuint index) | 2029 PassRefPtr<WebGLActiveInfo> WebGLRenderingContextBase::getActiveAttrib(WebGLProg
ram* program, GLuint index) |
| 2043 { | 2030 { |
| 2044 if (isContextLost() || !validateWebGLObject("getActiveAttrib", program)) | 2031 if (isContextLost() || !validateWebGLObject("getActiveAttrib", program)) |
| 2045 return nullptr; | 2032 return nullptr; |
| 2046 blink::WebGraphicsContext3D::ActiveInfo info; | 2033 blink::WebGraphicsContext3D::ActiveInfo info; |
| 2047 if (!webContext()->getActiveAttrib(objectOrZero(program), index, info)) | 2034 if (!webContext()->getActiveAttrib(objectOrZero(program), index, info)) |
| 2048 return nullptr; | 2035 return nullptr; |
| (...skipping 1079 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3128 return; | 3115 return; |
| 3129 } | 3116 } |
| 3130 | 3117 |
| 3131 clearIfComposited(); | 3118 clearIfComposited(); |
| 3132 void* data = pixels->baseAddress(); | 3119 void* data = pixels->baseAddress(); |
| 3133 | 3120 |
| 3134 { | 3121 { |
| 3135 ScopedDrawingBufferBinder binder(drawingBuffer(), m_framebufferBinding.g
et()); | 3122 ScopedDrawingBufferBinder binder(drawingBuffer(), m_framebufferBinding.g
et()); |
| 3136 webContext()->readPixels(x, y, width, height, format, type, data); | 3123 webContext()->readPixels(x, y, width, height, format, type, data); |
| 3137 } | 3124 } |
| 3138 | |
| 3139 #if OS(MACOSX) | |
| 3140 // FIXME: remove this section when GL driver bug on Mac is fixed, i.e., | |
| 3141 // when alpha is off, readPixels should set alpha to 255 instead of 0. | |
| 3142 if (!m_framebufferBinding && !drawingBuffer()->getActualAttributes().alpha)
{ | |
| 3143 unsigned char* pixels = reinterpret_cast<unsigned char*>(data); | |
| 3144 for (GLsizei iy = 0; iy < height; ++iy) { | |
| 3145 for (GLsizei ix = 0; ix < width; ++ix) { | |
| 3146 pixels[3] = 255; | |
| 3147 pixels += 4; | |
| 3148 } | |
| 3149 pixels += padding; | |
| 3150 } | |
| 3151 } | |
| 3152 #endif | |
| 3153 } | 3125 } |
| 3154 | 3126 |
| 3155 void WebGLRenderingContextBase::renderbufferStorage(GLenum target, GLenum intern
alformat, GLsizei width, GLsizei height) | 3127 void WebGLRenderingContextBase::renderbufferStorage(GLenum target, GLenum intern
alformat, GLsizei width, GLsizei height) |
| 3156 { | 3128 { |
| 3157 if (isContextLost()) | 3129 if (isContextLost()) |
| 3158 return; | 3130 return; |
| 3159 if (target != GL_RENDERBUFFER) { | 3131 if (target != GL_RENDERBUFFER) { |
| 3160 synthesizeGLError(GL_INVALID_ENUM, "renderbufferStorage", "invalid targe
t"); | 3132 synthesizeGLError(GL_INVALID_ENUM, "renderbufferStorage", "invalid targe
t"); |
| 3161 return; | 3133 return; |
| 3162 } | 3134 } |
| (...skipping 2516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5679 return m_sharedWebGraphicsContext3D ? m_sharedWebGraphicsContext3D->drawingB
uffer() : 0; | 5651 return m_sharedWebGraphicsContext3D ? m_sharedWebGraphicsContext3D->drawingB
uffer() : 0; |
| 5680 } | 5652 } |
| 5681 #else | 5653 #else |
| 5682 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const | 5654 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const |
| 5683 { | 5655 { |
| 5684 return m_drawingBuffer.get(); | 5656 return m_drawingBuffer.get(); |
| 5685 } | 5657 } |
| 5686 #endif | 5658 #endif |
| 5687 | 5659 |
| 5688 } // namespace blink | 5660 } // namespace blink |
| OLD | NEW |