Chromium Code Reviews| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 44 | 44 |
| 45 namespace WebKit { | 45 namespace WebKit { |
| 46 class WebExternalTextureLayer; | 46 class WebExternalTextureLayer; |
| 47 class WebGraphicsContext3D; | 47 class WebGraphicsContext3D; |
| 48 } | 48 } |
| 49 | 49 |
| 50 namespace WebCore { | 50 namespace WebCore { |
| 51 class GraphicsContext3D; | 51 class GraphicsContext3D; |
| 52 class ImageData; | 52 class ImageData; |
| 53 | 53 |
| 54 // Abstract interface to allow basic context eviction management | |
| 55 class ContextEvictionManager : public RefCounted<ContextEvictionManager> { | |
| 56 public: | |
| 57 virtual ~ContextEvictionManager() {}; | |
| 58 | |
| 59 virtual void forciblyLoseOldestContext() = 0; | |
| 60 virtual IntSize oldestContextSize() = 0; | |
| 61 }; | |
| 62 | |
| 54 // Manages a rendering target (framebuffer + attachment) for a canvas. Can publ ish its rendering | 63 // Manages a rendering target (framebuffer + attachment) for a canvas. Can publ ish its rendering |
| 55 // results to a PlatformLayer for compositing. | 64 // results to a PlatformLayer for compositing. |
| 56 class DrawingBuffer : public RefCounted<DrawingBuffer>, public WebKit::WebExtern alTextureLayerClient { | 65 class DrawingBuffer : public RefCounted<DrawingBuffer>, public WebKit::WebExtern alTextureLayerClient { |
| 57 struct MailboxInfo : public RefCounted<MailboxInfo> { | 66 struct MailboxInfo : public RefCounted<MailboxInfo> { |
| 58 WebKit::WebExternalTextureMailbox mailbox; | 67 WebKit::WebExternalTextureMailbox mailbox; |
| 59 unsigned textureId; | 68 unsigned textureId; |
| 60 IntSize size; | 69 IntSize size; |
| 61 }; | 70 }; |
| 62 public: | 71 public: |
| 63 enum PreserveDrawingBuffer { | 72 enum PreserveDrawingBuffer { |
| 64 Preserve, | 73 Preserve, |
| 65 Discard | 74 Discard |
| 66 }; | 75 }; |
| 67 | 76 |
| 68 static PassRefPtr<DrawingBuffer> create(GraphicsContext3D*, const IntSize&, PreserveDrawingBuffer); | 77 static PassRefPtr<DrawingBuffer> create(GraphicsContext3D*, const IntSize&, PreserveDrawingBuffer, ContextEvictionManager*); |
| 69 | 78 |
| 70 ~DrawingBuffer(); | 79 ~DrawingBuffer(); |
| 71 | 80 |
| 72 // Clear all resources from this object, as well as context. Called when con text is destroyed | 81 // Clear all resources from this object, as well as context. Called when con text is destroyed |
| 73 // to prevent invalid accesses to the resources. | 82 // to prevent invalid accesses to the resources. |
| 74 void clear(); | 83 void clear(); |
| 75 | 84 |
| 76 // Issues a glClear() on all framebuffers associated with this DrawingBuffer . The caller is responsible for | 85 // Issues a glClear() on all framebuffers associated with this DrawingBuffer . The caller is responsible for |
| 77 // making the context current and setting the clear values and masks. Modifi es the framebuffer binding. | 86 // making the context current and setting the clear values and masks. Modifi es the framebuffer binding. |
| 78 void clearFramebuffers(GC3Dbitfield clearMask); | 87 void clearFramebuffers(GC3Dbitfield clearMask); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 114 void paintCompositedResultsToCanvas(ImageBuffer*); | 123 void paintCompositedResultsToCanvas(ImageBuffer*); |
| 115 | 124 |
| 116 // WebExternalTextureLayerClient implementation. | 125 // WebExternalTextureLayerClient implementation. |
| 117 virtual unsigned prepareTexture(WebKit::WebTextureUpdater& updater) OVERRIDE ; | 126 virtual unsigned prepareTexture(WebKit::WebTextureUpdater& updater) OVERRIDE ; |
| 118 virtual WebKit::WebGraphicsContext3D* context() OVERRIDE; | 127 virtual WebKit::WebGraphicsContext3D* context() OVERRIDE; |
| 119 virtual bool prepareMailbox(WebKit::WebExternalTextureMailbox*) OVERRIDE; | 128 virtual bool prepareMailbox(WebKit::WebExternalTextureMailbox*) OVERRIDE; |
| 120 virtual void mailboxReleased(const WebKit::WebExternalTextureMailbox&) OVERR IDE; | 129 virtual void mailboxReleased(const WebKit::WebExternalTextureMailbox&) OVERR IDE; |
| 121 | 130 |
| 122 private: | 131 private: |
| 123 DrawingBuffer(GraphicsContext3D*, const IntSize&, bool multisampleExtensionS upported, | 132 DrawingBuffer(GraphicsContext3D*, const IntSize&, bool multisampleExtensionS upported, |
| 124 bool packedDepthStencilExtensionSupported, PreserveDrawingBuff er); | 133 bool packedDepthStencilExtensionSupported, PreserveDrawingBuff er, ContextEvictionManager*); |
|
Ken Russell (switch to Gerrit)
2013/04/24 01:30:57
This should be PassRefPtr<ContextEvictionManager>.
| |
| 125 | 134 |
| 126 void initialize(const IntSize&); | 135 void initialize(const IntSize&); |
| 127 | 136 |
| 128 void prepareBackBuffer(); | 137 void prepareBackBuffer(); |
| 129 bool requiresCopyFromBackToFrontBuffer() const; | 138 bool requiresCopyFromBackToFrontBuffer() const; |
| 130 Platform3DObject frontColorBuffer() const; | 139 Platform3DObject frontColorBuffer() const; |
| 131 Platform3DObject colorBuffer() const { return m_colorBuffer; } | 140 Platform3DObject colorBuffer() const { return m_colorBuffer; } |
| 132 | 141 |
| 133 unsigned createColorTexture(const IntSize& size = IntSize()); | 142 unsigned createColorTexture(const IntSize& size = IntSize()); |
| 134 // Create the depth/stencil and multisample buffers, if needed. | 143 // Create the depth/stencil and multisample buffers, if needed. |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 145 | 154 |
| 146 PassRefPtr<MailboxInfo> getRecycledMailbox(); | 155 PassRefPtr<MailboxInfo> getRecycledMailbox(); |
| 147 PassRefPtr<MailboxInfo> createNewMailbox(unsigned); | 156 PassRefPtr<MailboxInfo> createNewMailbox(unsigned); |
| 148 | 157 |
| 149 // Updates the current size of the buffer, ensuring that s_currentResourceUs ePixels is updated. | 158 // Updates the current size of the buffer, ensuring that s_currentResourceUs ePixels is updated. |
| 150 void setSize(const IntSize& size); | 159 void setSize(const IntSize& size); |
| 151 | 160 |
| 152 // Calculates the difference in pixels between the current buffer size and t he proposed size. | 161 // Calculates the difference in pixels between the current buffer size and t he proposed size. |
| 153 int pixelDelta(const IntSize& size); | 162 int pixelDelta(const IntSize& size); |
| 154 | 163 |
| 164 // Given the desired buffer size, provides the largest dimensions that will fit in the pixel budget | |
| 165 // Returns true if the buffer will only fit if the oldest WebGL context is f orcibly lost | |
| 166 IntSize adjustSizeWithContextEviction(const IntSize&, bool& evictContext); | |
| 167 | |
| 155 PreserveDrawingBuffer m_preserveDrawingBuffer; | 168 PreserveDrawingBuffer m_preserveDrawingBuffer; |
| 156 bool m_scissorEnabled; | 169 bool m_scissorEnabled; |
| 157 Platform3DObject m_texture2DBinding; | 170 Platform3DObject m_texture2DBinding; |
| 158 Platform3DObject m_framebufferBinding; | 171 Platform3DObject m_framebufferBinding; |
| 159 GC3Denum m_activeTextureUnit; | 172 GC3Denum m_activeTextureUnit; |
| 160 | 173 |
| 161 RefPtr<GraphicsContext3D> m_context; | 174 RefPtr<GraphicsContext3D> m_context; |
| 162 IntSize m_size; | 175 IntSize m_size; |
| 163 bool m_multisampleExtensionSupported; | 176 bool m_multisampleExtensionSupported; |
| 164 bool m_packedDepthStencilExtensionSupported; | 177 bool m_packedDepthStencilExtensionSupported; |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 185 unsigned m_colorFormat; | 198 unsigned m_colorFormat; |
| 186 unsigned m_internalRenderbufferFormat; | 199 unsigned m_internalRenderbufferFormat; |
| 187 | 200 |
| 188 OwnPtr<WebKit::WebExternalTextureLayer> m_layer; | 201 OwnPtr<WebKit::WebExternalTextureLayer> m_layer; |
| 189 | 202 |
| 190 // All of the mailboxes that this DrawingBuffer has ever created. | 203 // All of the mailboxes that this DrawingBuffer has ever created. |
| 191 Vector<RefPtr<MailboxInfo> > m_textureMailboxes; | 204 Vector<RefPtr<MailboxInfo> > m_textureMailboxes; |
| 192 // Mailboxes that were released by the compositor and can be used again by t his DrawingBuffer. | 205 // Mailboxes that were released by the compositor and can be used again by t his DrawingBuffer. |
| 193 Vector<RefPtr<MailboxInfo> > m_recycledMailboxes; | 206 Vector<RefPtr<MailboxInfo> > m_recycledMailboxes; |
| 194 RefPtr<MailboxInfo> m_lastColorBuffer; | 207 RefPtr<MailboxInfo> m_lastColorBuffer; |
| 208 | |
| 209 RefPtr<ContextEvictionManager> m_contextEvictionManager; | |
| 195 }; | 210 }; |
| 196 | 211 |
| 197 } // namespace WebCore | 212 } // namespace WebCore |
| 198 | 213 |
| 199 #endif // DrawingBuffer_h | 214 #endif // DrawingBuffer_h |
| OLD | NEW |