| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google 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 are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 , m_textureUpdated(false) | 54 , m_textureUpdated(false) |
| 55 { | 55 { |
| 56 } | 56 } |
| 57 | 57 |
| 58 WebGLLayerChromium::~WebGLLayerChromium() | 58 WebGLLayerChromium::~WebGLLayerChromium() |
| 59 { | 59 { |
| 60 if (m_context && layerRenderer()) | 60 if (m_context && layerRenderer()) |
| 61 layerRenderer()->removeChildContext(m_context); | 61 layerRenderer()->removeChildContext(m_context); |
| 62 } | 62 } |
| 63 | 63 |
| 64 bool WebGLLayerChromium::drawsContent() const |
| 65 { |
| 66 return (m_context && m_context->getExtensions()->getGraphicsResetStatusARB()
== GraphicsContext3D::NO_ERROR); |
| 67 } |
| 68 |
| 64 void WebGLLayerChromium::updateCompositorResources() | 69 void WebGLLayerChromium::updateCompositorResources() |
| 65 { | 70 { |
| 66 if (!m_context) | 71 if (!drawsContent()) |
| 67 return; | 72 return; |
| 68 | 73 |
| 69 if (!m_contentsDirty) | 74 if (!m_contentsDirty) |
| 70 return; | 75 return; |
| 71 | 76 |
| 72 GraphicsContext3D* rendererContext = layerRendererContext(); | 77 GraphicsContext3D* rendererContext = layerRendererContext(); |
| 73 if (m_textureChanged) { | 78 if (m_textureChanged) { |
| 74 rendererContext->bindTexture(GraphicsContext3D::TEXTURE_2D, m_textureId)
; | 79 rendererContext->bindTexture(GraphicsContext3D::TEXTURE_2D, m_textureId)
; |
| 75 // Set the min-mag filters to linear and wrap modes to GL_CLAMP_TO_EDGE | 80 // Set the min-mag filters to linear and wrap modes to GL_CLAMP_TO_EDGE |
| 76 // to get around NPOT texture limitations of GLES. | 81 // to get around NPOT texture limitations of GLES. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 96 { | 101 { |
| 97 m_textureUpdated = true; | 102 m_textureUpdated = true; |
| 98 // If WebGL commands are issued outside of a the animation callbacks, then u
se | 103 // If WebGL commands are issued outside of a the animation callbacks, then u
se |
| 99 // call rateLimitOffscreenContextCHROMIUM() to keep the context from getting
too far ahead. | 104 // call rateLimitOffscreenContextCHROMIUM() to keep the context from getting
too far ahead. |
| 100 if (layerRenderer() && !layerRenderer()->isAnimating() && m_contextSupportsR
ateLimitingExtension && !m_rateLimitingTimer.isActive()) | 105 if (layerRenderer() && !layerRenderer()->isAnimating() && m_contextSupportsR
ateLimitingExtension && !m_rateLimitingTimer.isActive()) |
| 101 m_rateLimitingTimer.startOneShot(0); | 106 m_rateLimitingTimer.startOneShot(0); |
| 102 } | 107 } |
| 103 | 108 |
| 104 void WebGLLayerChromium::setContext(const GraphicsContext3D* context) | 109 void WebGLLayerChromium::setContext(const GraphicsContext3D* context) |
| 105 { | 110 { |
| 106 if (m_context != context && layerRenderer()) { | 111 bool contextChanged = (m_context != context); |
| 112 if (contextChanged && layerRenderer()) { |
| 107 if (m_context) | 113 if (m_context) |
| 108 layerRenderer()->removeChildContext(m_context); | 114 layerRenderer()->removeChildContext(m_context); |
| 109 if (context) | 115 if (context) |
| 110 layerRenderer()->addChildContext(const_cast<GraphicsContext3D*>(cont
ext)); | 116 layerRenderer()->addChildContext(const_cast<GraphicsContext3D*>(cont
ext)); |
| 111 } | 117 } |
| 112 | 118 |
| 113 m_context = const_cast<GraphicsContext3D*>(context); | 119 m_context = const_cast<GraphicsContext3D*>(context); |
| 114 | 120 |
| 115 if (!m_context) | 121 if (!m_context) |
| 116 return; | 122 return; |
| 117 | 123 |
| 118 unsigned int textureId = m_context->platformTexture(); | 124 unsigned int textureId = m_context->platformTexture(); |
| 119 if (textureId != m_textureId) { | 125 if (textureId != m_textureId || contextChanged) { |
| 120 m_textureChanged = true; | 126 m_textureChanged = true; |
| 121 m_textureUpdated = true; | 127 m_textureUpdated = true; |
| 122 } | 128 } |
| 123 m_textureId = textureId; | 129 m_textureId = textureId; |
| 124 GraphicsContext3D::Attributes attributes = m_context->getContextAttributes()
; | 130 GraphicsContext3D::Attributes attributes = m_context->getContextAttributes()
; |
| 125 m_hasAlpha = attributes.alpha; | 131 m_hasAlpha = attributes.alpha; |
| 126 m_premultipliedAlpha = attributes.premultipliedAlpha; | 132 m_premultipliedAlpha = attributes.premultipliedAlpha; |
| 127 m_contextSupportsRateLimitingExtension = m_context->getExtensions()->support
s("GL_CHROMIUM_rate_limit_offscreen_context"); | 133 m_contextSupportsRateLimitingExtension = m_context->getExtensions()->support
s("GL_CHROMIUM_rate_limit_offscreen_context"); |
| 128 } | 134 } |
| 129 | 135 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 147 | 153 |
| 148 if (!m_context) | 154 if (!m_context) |
| 149 return; | 155 return; |
| 150 | 156 |
| 151 Extensions3DChromium* extensions = static_cast<Extensions3DChromium*>(m_cont
ext->getExtensions()); | 157 Extensions3DChromium* extensions = static_cast<Extensions3DChromium*>(m_cont
ext->getExtensions()); |
| 152 extensions->rateLimitOffscreenContextCHROMIUM(); | 158 extensions->rateLimitOffscreenContextCHROMIUM(); |
| 153 } | 159 } |
| 154 | 160 |
| 155 } | 161 } |
| 156 #endif // USE(ACCELERATED_COMPOSITING) | 162 #endif // USE(ACCELERATED_COMPOSITING) |
| OLD | NEW |