| 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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 WebGLRenderingContextBaseMap& forciblyEvictedContexts() | 120 WebGLRenderingContextBaseMap& forciblyEvictedContexts() |
| 121 { | 121 { |
| 122 DEFINE_STATIC_LOCAL(WebGLRenderingContextBaseMap, forciblyEvictedContexts, (
)); | 122 DEFINE_STATIC_LOCAL(WebGLRenderingContextBaseMap, forciblyEvictedContexts, (
)); |
| 123 return forciblyEvictedContexts; | 123 return forciblyEvictedContexts; |
| 124 } | 124 } |
| 125 | 125 |
| 126 } // namespace | 126 } // namespace |
| 127 | 127 |
| 128 ScopedRGBEmulationColorMask::ScopedRGBEmulationColorMask(gpu::gles2::GLES2Interf
ace* contextGL, GLboolean* colorMask, DrawingBuffer* drawingBuffer) | 128 ScopedRGBEmulationColorMask::ScopedRGBEmulationColorMask(gpu::gles2::GLES2Interf
ace* contextGL, GLboolean* colorMask, DrawingBuffer* drawingBuffer) |
| 129 : m_contextGL(contextGL) | 129 : m_contextGL(contextGL) |
| 130 , m_requiresEmulation(drawingBuffer->requiresRGBEmulation()) | 130 , m_requiresEmulation(drawingBuffer->requiresAlphaChannelToBePreserved()) |
| 131 { | 131 { |
| 132 if (m_requiresEmulation) { | 132 if (m_requiresEmulation) { |
| 133 memcpy(m_colorMask, colorMask, 4 * sizeof(GLboolean)); | 133 memcpy(m_colorMask, colorMask, 4 * sizeof(GLboolean)); |
| 134 m_contextGL->ColorMask(m_colorMask[0], m_colorMask[1], m_colorMask[2], f
alse); | 134 m_contextGL->ColorMask(m_colorMask[0], m_colorMask[1], m_colorMask[2], f
alse); |
| 135 } | 135 } |
| 136 } | 136 } |
| 137 | 137 |
| 138 ScopedRGBEmulationColorMask::~ScopedRGBEmulationColorMask() | 138 ScopedRGBEmulationColorMask::~ScopedRGBEmulationColorMask() |
| 139 { | 139 { |
| 140 if (m_requiresEmulation) | 140 if (m_requiresEmulation) |
| (...skipping 1016 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1157 | 1157 |
| 1158 contextGL()->Disable(GL_SCISSOR_TEST); | 1158 contextGL()->Disable(GL_SCISSOR_TEST); |
| 1159 if (combinedClear && (mask & GL_COLOR_BUFFER_BIT)) { | 1159 if (combinedClear && (mask & GL_COLOR_BUFFER_BIT)) { |
| 1160 contextGL()->ClearColor(m_colorMask[0] ? m_clearColor[0] : 0, | 1160 contextGL()->ClearColor(m_colorMask[0] ? m_clearColor[0] : 0, |
| 1161 m_colorMask[1] ? m_clearColor[1] : 0, | 1161 m_colorMask[1] ? m_clearColor[1] : 0, |
| 1162 m_colorMask[2] ? m_clearColor[2] : 0, | 1162 m_colorMask[2] ? m_clearColor[2] : 0, |
| 1163 m_colorMask[3] ? m_clearColor[3] : 0); | 1163 m_colorMask[3] ? m_clearColor[3] : 0); |
| 1164 } else { | 1164 } else { |
| 1165 contextGL()->ClearColor(0, 0, 0, 0); | 1165 contextGL()->ClearColor(0, 0, 0, 0); |
| 1166 } | 1166 } |
| 1167 contextGL()->ColorMask(true, true, true, !drawingBuffer()->requiresRGBEmulat
ion()); | 1167 contextGL()->ColorMask(true, true, true, !drawingBuffer()->requiresAlphaChan
nelToBePreserved()); |
| 1168 GLbitfield clearMask = GL_COLOR_BUFFER_BIT; | 1168 GLbitfield clearMask = GL_COLOR_BUFFER_BIT; |
| 1169 if (contextAttributes.get().depth()) { | 1169 if (contextAttributes.get().depth()) { |
| 1170 if (!combinedClear || !m_depthMask || !(mask & GL_DEPTH_BUFFER_BIT)) | 1170 if (!combinedClear || !m_depthMask || !(mask & GL_DEPTH_BUFFER_BIT)) |
| 1171 contextGL()->ClearDepthf(1.0f); | 1171 contextGL()->ClearDepthf(1.0f); |
| 1172 clearMask |= GL_DEPTH_BUFFER_BIT; | 1172 clearMask |= GL_DEPTH_BUFFER_BIT; |
| 1173 contextGL()->DepthMask(true); | 1173 contextGL()->DepthMask(true); |
| 1174 } | 1174 } |
| 1175 if (contextAttributes.get().stencil() || drawingBuffer()->hasImplicitStencil
Buffer()) { | 1175 if (contextAttributes.get().stencil() || drawingBuffer()->hasImplicitStencil
Buffer()) { |
| 1176 if (combinedClear && (mask & GL_STENCIL_BUFFER_BIT)) | 1176 if (combinedClear && (mask & GL_STENCIL_BUFFER_BIT)) |
| 1177 contextGL()->ClearStencil(m_clearStencil & m_stencilMask); | 1177 contextGL()->ClearStencil(m_clearStencil & m_stencilMask); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1297 int currentArea = width * height; | 1297 int currentArea = width * height; |
| 1298 if (currentArea > maxArea) { | 1298 if (currentArea > maxArea) { |
| 1299 // If we've exceeded the area limit scale the buffer down, preserving as
cpect ratio, until it fits. | 1299 // If we've exceeded the area limit scale the buffer down, preserving as
cpect ratio, until it fits. |
| 1300 float scaleFactor = sqrtf(static_cast<float>(maxArea) / static_cast<floa
t>(currentArea)); | 1300 float scaleFactor = sqrtf(static_cast<float>(maxArea) / static_cast<floa
t>(currentArea)); |
| 1301 width = std::max(1, static_cast<int>(width * scaleFactor)); | 1301 width = std::max(1, static_cast<int>(width * scaleFactor)); |
| 1302 height = std::max(1, static_cast<int>(height * scaleFactor)); | 1302 height = std::max(1, static_cast<int>(height * scaleFactor)); |
| 1303 } | 1303 } |
| 1304 | 1304 |
| 1305 // We don't have to mark the canvas as dirty, since the newly created image
buffer will also start off | 1305 // We don't have to mark the canvas as dirty, since the newly created image
buffer will also start off |
| 1306 // clear (and this matches what reshape will do). | 1306 // clear (and this matches what reshape will do). |
| 1307 bool wantDepthOrStencilBuffer = m_requestedAttributes.depth() || m_requested
Attributes.stencil(); | 1307 drawingBuffer()->reset(IntSize(width, height)); |
| 1308 drawingBuffer()->reset(IntSize(width, height), wantDepthOrStencilBuffer); | |
| 1309 restoreStateAfterClear(); | 1308 restoreStateAfterClear(); |
| 1310 | 1309 |
| 1311 contextGL()->BindTexture(GL_TEXTURE_2D, objectOrZero(m_textureUnits[m_active
TextureUnit].m_texture2DBinding.get())); | 1310 contextGL()->BindTexture(GL_TEXTURE_2D, objectOrZero(m_textureUnits[m_active
TextureUnit].m_texture2DBinding.get())); |
| 1312 contextGL()->BindRenderbuffer(GL_RENDERBUFFER, objectOrZero(m_renderbufferBi
nding.get())); | 1311 contextGL()->BindRenderbuffer(GL_RENDERBUFFER, objectOrZero(m_renderbufferBi
nding.get())); |
| 1313 drawingBuffer()->restoreFramebufferBindings(); | 1312 drawingBuffer()->restoreFramebufferBindings(); |
| 1314 } | 1313 } |
| 1315 | 1314 |
| 1316 int WebGLRenderingContextBase::drawingBufferWidth() const | 1315 int WebGLRenderingContextBase::drawingBufferWidth() const |
| 1317 { | 1316 { |
| 1318 return isContextLost() ? 0 : drawingBuffer()->size().width(); | 1317 return isContextLost() ? 0 : drawingBuffer()->size().width(); |
| (...skipping 1268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2587 return ScriptValue::createNull(scriptState); | 2586 return ScriptValue::createNull(scriptState); |
| 2588 const int intZero = 0; | 2587 const int intZero = 0; |
| 2589 switch (pname) { | 2588 switch (pname) { |
| 2590 case GL_ACTIVE_TEXTURE: | 2589 case GL_ACTIVE_TEXTURE: |
| 2591 return getUnsignedIntParameter(scriptState, pname); | 2590 return getUnsignedIntParameter(scriptState, pname); |
| 2592 case GL_ALIASED_LINE_WIDTH_RANGE: | 2591 case GL_ALIASED_LINE_WIDTH_RANGE: |
| 2593 return getWebGLFloatArrayParameter(scriptState, pname); | 2592 return getWebGLFloatArrayParameter(scriptState, pname); |
| 2594 case GL_ALIASED_POINT_SIZE_RANGE: | 2593 case GL_ALIASED_POINT_SIZE_RANGE: |
| 2595 return getWebGLFloatArrayParameter(scriptState, pname); | 2594 return getWebGLFloatArrayParameter(scriptState, pname); |
| 2596 case GL_ALPHA_BITS: | 2595 case GL_ALPHA_BITS: |
| 2597 if (m_drawingBuffer->requiresRGBEmulation()) | 2596 if (m_drawingBuffer->requiresAlphaChannelToBePreserved()) |
| 2598 return WebGLAny(scriptState, 0); | 2597 return WebGLAny(scriptState, 0); |
| 2599 return getIntParameter(scriptState, pname); | 2598 return getIntParameter(scriptState, pname); |
| 2600 case GL_ARRAY_BUFFER_BINDING: | 2599 case GL_ARRAY_BUFFER_BINDING: |
| 2601 return WebGLAny(scriptState, m_boundArrayBuffer.get()); | 2600 return WebGLAny(scriptState, m_boundArrayBuffer.get()); |
| 2602 case GL_BLEND: | 2601 case GL_BLEND: |
| 2603 return getBooleanParameter(scriptState, pname); | 2602 return getBooleanParameter(scriptState, pname); |
| 2604 case GL_BLEND_COLOR: | 2603 case GL_BLEND_COLOR: |
| 2605 return getWebGLFloatArrayParameter(scriptState, pname); | 2604 return getWebGLFloatArrayParameter(scriptState, pname); |
| 2606 case GL_BLEND_DST_ALPHA: | 2605 case GL_BLEND_DST_ALPHA: |
| 2607 return getUnsignedIntParameter(scriptState, pname); | 2606 return getUnsignedIntParameter(scriptState, pname); |
| (...skipping 3699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6307 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, 1); | 6306 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, 1); |
| 6308 } | 6307 } |
| 6309 | 6308 |
| 6310 void WebGLRenderingContextBase::restoreUnpackParameters() | 6309 void WebGLRenderingContextBase::restoreUnpackParameters() |
| 6311 { | 6310 { |
| 6312 if (m_unpackAlignment != 1) | 6311 if (m_unpackAlignment != 1) |
| 6313 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); | 6312 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); |
| 6314 } | 6313 } |
| 6315 | 6314 |
| 6316 } // namespace blink | 6315 } // namespace blink |
| OLD | NEW |