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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 blink::WebExternalTextureMailbox mailbox; | 72 blink::WebExternalTextureMailbox mailbox; |
73 unsigned textureId; | 73 unsigned textureId; |
74 IntSize size; | 74 IntSize size; |
75 }; | 75 }; |
76 public: | 76 public: |
77 enum PreserveDrawingBuffer { | 77 enum PreserveDrawingBuffer { |
78 Preserve, | 78 Preserve, |
79 Discard | 79 Discard |
80 }; | 80 }; |
81 | 81 |
82 static PassRefPtr<DrawingBuffer> create(blink::WebGraphicsContext3D*, const
IntSize&, PreserveDrawingBuffer, PassRefPtr<ContextEvictionManager>); | 82 static PassRefPtr<DrawingBuffer> create(PassOwnPtr<blink::WebGraphicsContext
3D>, const IntSize&, PreserveDrawingBuffer, PassRefPtr<ContextEvictionManager>); |
83 | 83 |
84 virtual ~DrawingBuffer(); | 84 virtual ~DrawingBuffer(); |
85 | 85 |
| 86 // Clear all resources from this object, as well as context. Called when con
text is destroyed |
| 87 // to prevent invalid accesses to the resources. |
| 88 void releaseResources(); |
| 89 |
86 // Issues a glClear() on all framebuffers associated with this DrawingBuffer
. The caller is responsible for | 90 // Issues a glClear() on all framebuffers associated with this DrawingBuffer
. The caller is responsible for |
87 // making the context current and setting the clear values and masks. Modifi
es the framebuffer binding. | 91 // making the context current and setting the clear values and masks. Modifi
es the framebuffer binding. |
88 void clearFramebuffers(GLbitfield clearMask); | 92 void clearFramebuffers(GLbitfield clearMask); |
89 | 93 |
90 // Given the desired buffer size, provides the largest dimensions that will
fit in the pixel budget. | 94 // Given the desired buffer size, provides the largest dimensions that will
fit in the pixel budget. |
91 IntSize adjustSize(const IntSize&); | 95 IntSize adjustSize(const IntSize&); |
92 bool reset(const IntSize&); | 96 bool reset(const IntSize&); |
93 void bind(); | 97 void bind(); |
94 IntSize size() const { return m_size; } | 98 IntSize size() const { return m_size; } |
95 | 99 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 | 135 |
132 bool copyToPlatformTexture(blink::WebGraphicsContext3D*, Platform3DObject te
xture, GLenum internalFormat, | 136 bool copyToPlatformTexture(blink::WebGraphicsContext3D*, Platform3DObject te
xture, GLenum internalFormat, |
133 GLenum destType, GLint level, bool premultiplyAlpha, bool flipY); | 137 GLenum destType, GLint level, bool premultiplyAlpha, bool flipY); |
134 | 138 |
135 void setPackAlignment(GLint param); | 139 void setPackAlignment(GLint param); |
136 | 140 |
137 void paintRenderingResultsToCanvas(ImageBuffer*); | 141 void paintRenderingResultsToCanvas(ImageBuffer*); |
138 PassRefPtr<Uint8ClampedArray> paintRenderingResultsToImageData(int&, int&); | 142 PassRefPtr<Uint8ClampedArray> paintRenderingResultsToImageData(int&, int&); |
139 | 143 |
140 private: | 144 private: |
141 DrawingBuffer(blink::WebGraphicsContext3D*, bool multisampleExtensionSupport
ed, | 145 DrawingBuffer(PassOwnPtr<blink::WebGraphicsContext3D>, bool multisampleExten
sionSupported, |
142 bool packedDepthStencilExtensionSupported, PreserveDrawingBuff
er, PassRefPtr<ContextEvictionManager>); | 146 bool packedDepthStencilExtensionSupported, PreserveDrawingBuff
er, PassRefPtr<ContextEvictionManager>); |
143 | 147 |
144 bool initialize(const IntSize&); | 148 bool initialize(const IntSize&); |
145 // Clear all resources from this object, as well as context. Called when con
text is destroyed | 149 void releaseSelf(const blink::WebExternalTextureMailbox&); |
146 // to prevent invalid accesses to the resources. | |
147 void releaseResources(); | |
148 | 150 |
149 unsigned createColorTexture(const IntSize& size = IntSize()); | 151 unsigned createColorTexture(const IntSize& size = IntSize()); |
150 // Create the depth/stencil and multisample buffers, if needed. | 152 // Create the depth/stencil and multisample buffers, if needed. |
151 void createSecondaryBuffers(); | 153 void createSecondaryBuffers(); |
152 bool resizeFramebuffer(const IntSize&); | 154 bool resizeFramebuffer(const IntSize&); |
153 bool resizeMultisampleFramebuffer(const IntSize&); | 155 bool resizeMultisampleFramebuffer(const IntSize&); |
154 void resizeDepthStencil(const IntSize&); | 156 void resizeDepthStencil(const IntSize&); |
155 | 157 |
156 // Bind to the m_framebufferBinding if it's not 0. | 158 // Bind to the m_framebufferBinding if it's not 0. |
157 void restoreFramebufferBinding(); | 159 void restoreFramebufferBinding(); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 // Helper to texImage2D with pixel==0 case: pixels are initialized to 0. | 191 // Helper to texImage2D with pixel==0 case: pixels are initialized to 0. |
190 // By default, alignment is 4, the OpenGL default setting. | 192 // By default, alignment is 4, the OpenGL default setting. |
191 void texImage2DResourceSafe(GLenum target, GLint level, GLenum internalforma
t, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, GLin
t alignment = 4); | 193 void texImage2DResourceSafe(GLenum target, GLint level, GLenum internalforma
t, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, GLin
t alignment = 4); |
192 | 194 |
193 PreserveDrawingBuffer m_preserveDrawingBuffer; | 195 PreserveDrawingBuffer m_preserveDrawingBuffer; |
194 bool m_scissorEnabled; | 196 bool m_scissorEnabled; |
195 Platform3DObject m_texture2DBinding; | 197 Platform3DObject m_texture2DBinding; |
196 Platform3DObject m_framebufferBinding; | 198 Platform3DObject m_framebufferBinding; |
197 GLenum m_activeTextureUnit; | 199 GLenum m_activeTextureUnit; |
198 | 200 |
199 blink::WebGraphicsContext3D* m_context; | 201 OwnPtr<blink::WebGraphicsContext3D> m_context; |
200 IntSize m_size; | 202 IntSize m_size; |
201 bool m_multisampleExtensionSupported; | 203 bool m_multisampleExtensionSupported; |
202 bool m_packedDepthStencilExtensionSupported; | 204 bool m_packedDepthStencilExtensionSupported; |
203 Platform3DObject m_fbo; | 205 Platform3DObject m_fbo; |
204 // DrawingBuffer's output is double-buffered. m_colorBuffer is the back buff
er. | 206 // DrawingBuffer's output is double-buffered. m_colorBuffer is the back buff
er. |
205 Platform3DObject m_colorBuffer; | 207 Platform3DObject m_colorBuffer; |
206 Platform3DObject m_frontColorBuffer; | 208 Platform3DObject m_frontColorBuffer; |
207 | 209 |
208 // This is used when we have OES_packed_depth_stencil. | 210 // This is used when we have OES_packed_depth_stencil. |
209 Platform3DObject m_depthStencilBuffer; | 211 Platform3DObject m_depthStencilBuffer; |
(...skipping 20 matching lines...) Expand all Loading... |
230 int m_maxTextureSize; | 232 int m_maxTextureSize; |
231 int m_sampleCount; | 233 int m_sampleCount; |
232 int m_packAlignment; | 234 int m_packAlignment; |
233 | 235 |
234 OwnPtr<blink::WebExternalTextureLayer> m_layer; | 236 OwnPtr<blink::WebExternalTextureLayer> m_layer; |
235 | 237 |
236 // All of the mailboxes that this DrawingBuffer has ever created. | 238 // All of the mailboxes that this DrawingBuffer has ever created. |
237 Vector<RefPtr<MailboxInfo> > m_textureMailboxes; | 239 Vector<RefPtr<MailboxInfo> > m_textureMailboxes; |
238 // Mailboxes that were released by the compositor and can be used again by t
his DrawingBuffer. | 240 // Mailboxes that were released by the compositor and can be used again by t
his DrawingBuffer. |
239 Vector<RefPtr<MailboxInfo> > m_recycledMailboxes; | 241 Vector<RefPtr<MailboxInfo> > m_recycledMailboxes; |
| 242 // This class will be destructed after all mailboxes are received. |
| 243 RefPtr<DrawingBuffer> m_selfToWaitForMailboxes; |
240 | 244 |
241 RefPtr<ContextEvictionManager> m_contextEvictionManager; | 245 RefPtr<ContextEvictionManager> m_contextEvictionManager; |
242 | 246 |
243 // If the width and height of the Canvas's backing store don't | 247 // If the width and height of the Canvas's backing store don't |
244 // match those that we were given in the most recent call to | 248 // match those that we were given in the most recent call to |
245 // reshape(), then we need an intermediate bitmap to read back the | 249 // reshape(), then we need an intermediate bitmap to read back the |
246 // frame buffer into. This seems to happen when CSS styles are | 250 // frame buffer into. This seems to happen when CSS styles are |
247 // used to resize the Canvas. | 251 // used to resize the Canvas. |
248 SkBitmap m_resizingBitmap; | 252 SkBitmap m_resizingBitmap; |
249 | 253 |
250 // Used to flip a bitmap vertically. | 254 // Used to flip a bitmap vertically. |
251 Vector<uint8_t> m_scanline; | 255 Vector<uint8_t> m_scanline; |
252 }; | 256 }; |
253 | 257 |
254 } // namespace WebCore | 258 } // namespace WebCore |
255 | 259 |
256 #endif // DrawingBuffer_h | 260 #endif // DrawingBuffer_h |
OLD | NEW |