| 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 | 54 |
| 55 namespace WebCore { | 55 namespace WebCore { |
| 56 | 56 |
| 57 class CCHeadsUpDisplay; | 57 class CCHeadsUpDisplay; |
| 58 class CCLayerImpl; | 58 class CCLayerImpl; |
| 59 class CCRenderPass; | 59 class CCRenderPass; |
| 60 class CCTextureDrawQuad; | 60 class CCTextureDrawQuad; |
| 61 class GeometryBinding; | 61 class GeometryBinding; |
| 62 class GraphicsContext3D; | 62 class GraphicsContext3D; |
| 63 class LayerRendererSwapBuffersCompleteCallbackAdapter; | 63 class LayerRendererSwapBuffersCompleteCallbackAdapter; |
| 64 class LayerRendererGpuMemoryAllocationChangedCallbackAdapter; |
| 64 class ScopedEnsureFramebufferAllocation; | 65 class ScopedEnsureFramebufferAllocation; |
| 65 | 66 |
| 66 class LayerRendererChromiumClient { | 67 class LayerRendererChromiumClient { |
| 67 public: | 68 public: |
| 68 virtual const IntSize& viewportSize() const = 0; | 69 virtual const IntSize& viewportSize() const = 0; |
| 69 virtual const CCSettings& settings() const = 0; | 70 virtual const CCSettings& settings() const = 0; |
| 70 virtual CCLayerImpl* rootLayer() = 0; | 71 virtual CCLayerImpl* rootLayer() = 0; |
| 71 virtual const CCLayerImpl* rootLayer() const = 0; | 72 virtual const CCLayerImpl* rootLayer() const = 0; |
| 72 virtual void didLoseContext() = 0; | 73 virtual void didLoseContext() = 0; |
| 73 virtual void onSwapBuffersComplete() = 0; | 74 virtual void onSwapBuffersComplete() = 0; |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 | 157 |
| 157 void setVisible(bool); | 158 void setVisible(bool); |
| 158 | 159 |
| 159 GC3Denum bestTextureFormat(); | 160 GC3Denum bestTextureFormat(); |
| 160 | 161 |
| 161 static void toGLMatrix(float*, const TransformationMatrix&); | 162 static void toGLMatrix(float*, const TransformationMatrix&); |
| 162 void drawTexturedQuad(const TransformationMatrix& layerMatrix, | 163 void drawTexturedQuad(const TransformationMatrix& layerMatrix, |
| 163 float width, float height, float opacity, const FloatQ
uad&, | 164 float width, float height, float opacity, const FloatQ
uad&, |
| 164 int matrixLocation, int alphaLocation, int quadLocatio
n); | 165 int matrixLocation, int alphaLocation, int quadLocatio
n); |
| 165 | 166 |
| 167 protected: |
| 168 friend class LayerRendererGpuMemoryAllocationChangedCallbackAdapter; |
| 166 void discardFramebuffer(); | 169 void discardFramebuffer(); |
| 167 void ensureFramebuffer(); | 170 void ensureFramebuffer(); |
| 168 bool isFramebufferDiscarded() const { return m_isFramebufferDiscarded; } | 171 bool isFramebufferDiscarded() const { return m_isFramebufferDiscarded; } |
| 169 | 172 |
| 170 protected: | |
| 171 LayerRendererChromium(LayerRendererChromiumClient*, PassRefPtr<GraphicsConte
xt3D>); | 173 LayerRendererChromium(LayerRendererChromiumClient*, PassRefPtr<GraphicsConte
xt3D>); |
| 172 bool initialize(); | 174 bool initialize(); |
| 173 | 175 |
| 174 private: | 176 private: |
| 175 void drawQuad(const CCDrawQuad*, const FloatRect& surfaceDamageRect); | 177 void drawQuad(const CCDrawQuad*, const FloatRect& surfaceDamageRect); |
| 176 void drawDebugBorderQuad(const CCDebugBorderDrawQuad*); | 178 void drawDebugBorderQuad(const CCDebugBorderDrawQuad*); |
| 177 void drawRenderSurfaceQuad(const CCRenderSurfaceDrawQuad*); | 179 void drawRenderSurfaceQuad(const CCRenderSurfaceDrawQuad*); |
| 178 void drawSolidColorQuad(const CCSolidColorDrawQuad*); | 180 void drawSolidColorQuad(const CCSolidColorDrawQuad*); |
| 179 void drawTextureQuad(const CCTextureDrawQuad*); | 181 void drawTextureQuad(const CCTextureDrawQuad*); |
| 180 void drawTileQuad(const CCTileDrawQuad*); | 182 void drawTileQuad(const CCTileDrawQuad*); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 RefPtr<GraphicsContext3D> m_context; | 261 RefPtr<GraphicsContext3D> m_context; |
| 260 | 262 |
| 261 CCRenderSurface* m_defaultRenderSurface; | 263 CCRenderSurface* m_defaultRenderSurface; |
| 262 | 264 |
| 263 FloatQuad m_sharedGeometryQuad; | 265 FloatQuad m_sharedGeometryQuad; |
| 264 | 266 |
| 265 bool m_isViewportChanged; | 267 bool m_isViewportChanged; |
| 266 bool m_isFramebufferDiscarded; | 268 bool m_isFramebufferDiscarded; |
| 267 }; | 269 }; |
| 268 | 270 |
| 269 // The purpose of this helper is twofold: | |
| 270 // 1. To ensure that a framebuffer is available for scope lifetime, and | |
| 271 // 2. To reset framebuffer allocation to previous state on scope exit. | |
| 272 // If the framebuffer is recreated, its contents are undefined. | |
| 273 // FIXME: Prevent/delay discarding framebuffer via any means while any | |
| 274 // instance of this is alive. At the moment, this isn't an issue. | |
| 275 class ScopedEnsureFramebufferAllocation { | |
| 276 public: | |
| 277 explicit ScopedEnsureFramebufferAllocation(LayerRendererChromium* layerRende
rer) | |
| 278 : m_layerRenderer(layerRenderer) | |
| 279 , m_framebufferWasInitiallyDiscarded(layerRenderer->isFramebufferDiscard
ed()) | |
| 280 { | |
| 281 if (m_framebufferWasInitiallyDiscarded) | |
| 282 m_layerRenderer->ensureFramebuffer(); | |
| 283 } | |
| 284 | |
| 285 ~ScopedEnsureFramebufferAllocation() | |
| 286 { | |
| 287 if (m_framebufferWasInitiallyDiscarded) | |
| 288 m_layerRenderer->discardFramebuffer(); | |
| 289 } | |
| 290 | |
| 291 private: | |
| 292 LayerRendererChromium* m_layerRenderer; | |
| 293 bool m_framebufferWasInitiallyDiscarded; | |
| 294 }; | |
| 295 | |
| 296 | 271 |
| 297 // Setting DEBUG_GL_CALLS to 1 will call glGetError() after almost every GL | 272 // Setting DEBUG_GL_CALLS to 1 will call glGetError() after almost every GL |
| 298 // call made by the compositor. Useful for debugging rendering issues but | 273 // call made by the compositor. Useful for debugging rendering issues but |
| 299 // will significantly degrade performance. | 274 // will significantly degrade performance. |
| 300 #define DEBUG_GL_CALLS 0 | 275 #define DEBUG_GL_CALLS 0 |
| 301 | 276 |
| 302 #if DEBUG_GL_CALLS && !defined ( NDEBUG ) | 277 #if DEBUG_GL_CALLS && !defined ( NDEBUG ) |
| 303 #define GLC(context, x) { (x), LayerRendererChromium::debugGLCall(context, #x, _
_FILE__, __LINE__); } | 278 #define GLC(context, x) { (x), LayerRendererChromium::debugGLCall(context, #x, _
_FILE__, __LINE__); } |
| 304 #else | 279 #else |
| 305 #define GLC(context, x) (x) | 280 #define GLC(context, x) (x) |
| 306 #endif | 281 #endif |
| 307 | 282 |
| 308 | 283 |
| 309 } | 284 } |
| 310 | 285 |
| 311 #endif // USE(ACCELERATED_COMPOSITING) | 286 #endif // USE(ACCELERATED_COMPOSITING) |
| 312 | 287 |
| 313 #endif | 288 #endif |
| OLD | NEW |