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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 PassRefPtr<Uint8ClampedArray> paintRenderingResultsToImageData(int&, int&); | 149 PassRefPtr<Uint8ClampedArray> paintRenderingResultsToImageData(int&, int&); |
150 | 150 |
151 protected: // For unittests | 151 protected: // For unittests |
152 DrawingBuffer( | 152 DrawingBuffer( |
153 PassOwnPtr<blink::WebGraphicsContext3D>, | 153 PassOwnPtr<blink::WebGraphicsContext3D>, |
154 PassOwnPtr<Extensions3DUtil>, | 154 PassOwnPtr<Extensions3DUtil>, |
155 bool multisampleExtensionSupported, | 155 bool multisampleExtensionSupported, |
156 bool packedDepthStencilExtensionSupported, PreserveDrawingBuffer, PassRe
fPtr<ContextEvictionManager>); | 156 bool packedDepthStencilExtensionSupported, PreserveDrawingBuffer, PassRe
fPtr<ContextEvictionManager>); |
157 | 157 |
158 bool initialize(const IntSize&); | 158 bool initialize(const IntSize&); |
| 159 void setUseImageChromium(bool useImageChromium) { m_useImageChromium = useIm
ageChromium; } |
159 | 160 |
160 private: | 161 private: |
161 void mailboxReleasedWhileDestructionInProgress(const blink::WebExternalTextu
reMailbox&); | 162 void mailboxReleasedWhileDestructionInProgress(const blink::WebExternalTextu
reMailbox&); |
162 | 163 |
163 unsigned createColorTexture(const IntSize& size = IntSize()); | 164 unsigned createColorTexture(); |
164 // Create the depth/stencil and multisample buffers, if needed. | 165 // Create the depth/stencil and multisample buffers, if needed. |
165 void createSecondaryBuffers(); | 166 void createSecondaryBuffers(); |
166 bool resizeFramebuffer(const IntSize&); | 167 bool resizeFramebuffer(const IntSize&); |
167 bool resizeMultisampleFramebuffer(const IntSize&); | 168 bool resizeMultisampleFramebuffer(const IntSize&); |
168 void resizeDepthStencil(const IntSize&); | 169 void resizeDepthStencil(const IntSize&); |
169 | 170 |
170 // Bind to the m_framebufferBinding if it's not 0. | 171 // Bind to the m_framebufferBinding if it's not 0. |
171 void restoreFramebufferBinding(); | 172 void restoreFramebufferBinding(); |
172 | 173 |
173 void clearPlatformLayer(); | 174 void clearPlatformLayer(); |
(...skipping 23 matching lines...) Expand all Loading... |
197 // Helper function which does a readback from the currently-bound | 198 // Helper function which does a readback from the currently-bound |
198 // framebuffer into a buffer of a certain size with 4-byte pixels. | 199 // framebuffer into a buffer of a certain size with 4-byte pixels. |
199 void readBackFramebuffer(unsigned char* pixels, int width, int height, Readb
ackOrder, WebGLImageConversion::AlphaOp); | 200 void readBackFramebuffer(unsigned char* pixels, int width, int height, Readb
ackOrder, WebGLImageConversion::AlphaOp); |
200 | 201 |
201 // Helper function to flip a bitmap vertically. | 202 // Helper function to flip a bitmap vertically. |
202 void flipVertically(uint8_t* data, int width, int height); | 203 void flipVertically(uint8_t* data, int width, int height); |
203 | 204 |
204 // Helper to texImage2D with pixel==0 case: pixels are initialized to 0. | 205 // Helper to texImage2D with pixel==0 case: pixels are initialized to 0. |
205 // By default, alignment is 4, the OpenGL default setting. | 206 // By default, alignment is 4, the OpenGL default setting. |
206 void texImage2DResourceSafe(GLenum target, GLint level, GLenum internalforma
t, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, GLin
t alignment = 4); | 207 void texImage2DResourceSafe(GLenum target, GLint level, GLenum internalforma
t, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, GLin
t alignment = 4); |
| 208 // Allocate buffer storage to be sent to compositor using either texImage2D
or CHROMIUM_image based on available support. |
| 209 void allocateTextureMemory(Platform3DObject textureId, const IntSize&); |
| 210 void deleteChromiumImageForTexture(Platform3DObject textureId); |
207 | 211 |
208 PreserveDrawingBuffer m_preserveDrawingBuffer; | 212 PreserveDrawingBuffer m_preserveDrawingBuffer; |
209 bool m_scissorEnabled; | 213 bool m_scissorEnabled; |
210 Platform3DObject m_texture2DBinding; | 214 Platform3DObject m_texture2DBinding; |
211 Platform3DObject m_framebufferBinding; | 215 Platform3DObject m_framebufferBinding; |
212 GLenum m_activeTextureUnit; | 216 GLenum m_activeTextureUnit; |
213 | 217 |
214 OwnPtr<blink::WebGraphicsContext3D> m_context; | 218 OwnPtr<blink::WebGraphicsContext3D> m_context; |
215 OwnPtr<Extensions3DUtil> m_extensionsUtil; | 219 OwnPtr<Extensions3DUtil> m_extensionsUtil; |
216 IntSize m_size; | 220 IntSize m_size; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 int m_sampleCount; | 259 int m_sampleCount; |
256 int m_packAlignment; | 260 int m_packAlignment; |
257 bool m_destructionInProgress; | 261 bool m_destructionInProgress; |
258 | 262 |
259 OwnPtr<blink::WebExternalTextureLayer> m_layer; | 263 OwnPtr<blink::WebExternalTextureLayer> m_layer; |
260 | 264 |
261 // All of the mailboxes that this DrawingBuffer has ever created. | 265 // All of the mailboxes that this DrawingBuffer has ever created. |
262 Vector<RefPtr<MailboxInfo> > m_textureMailboxes; | 266 Vector<RefPtr<MailboxInfo> > m_textureMailboxes; |
263 // Mailboxes that were released by the compositor can be used again by this
DrawingBuffer. | 267 // Mailboxes that were released by the compositor can be used again by this
DrawingBuffer. |
264 Deque<blink::WebExternalTextureMailbox> m_recycledMailboxQueue; | 268 Deque<blink::WebExternalTextureMailbox> m_recycledMailboxQueue; |
| 269 // If we used CHROMIUM_image as the backing storage for our buffers, |
| 270 // we need to know the mapping from texture id to image. |
| 271 HashMap<Platform3DObject, blink::WGC3Duint> m_textureToImageChromiumMap; |
| 272 bool m_useImageChromium; |
265 | 273 |
266 RefPtr<ContextEvictionManager> m_contextEvictionManager; | 274 RefPtr<ContextEvictionManager> m_contextEvictionManager; |
267 | 275 |
268 // If the width and height of the Canvas's backing store don't | 276 // If the width and height of the Canvas's backing store don't |
269 // match those that we were given in the most recent call to | 277 // match those that we were given in the most recent call to |
270 // reshape(), then we need an intermediate bitmap to read back the | 278 // reshape(), then we need an intermediate bitmap to read back the |
271 // frame buffer into. This seems to happen when CSS styles are | 279 // frame buffer into. This seems to happen when CSS styles are |
272 // used to resize the Canvas. | 280 // used to resize the Canvas. |
273 SkBitmap m_resizingBitmap; | 281 SkBitmap m_resizingBitmap; |
274 | 282 |
275 // Used to flip a bitmap vertically. | 283 // Used to flip a bitmap vertically. |
276 Vector<uint8_t> m_scanline; | 284 Vector<uint8_t> m_scanline; |
277 }; | 285 }; |
278 | 286 |
279 } // namespace WebCore | 287 } // namespace WebCore |
280 | 288 |
281 #endif // DrawingBuffer_h | 289 #endif // DrawingBuffer_h |
OLD | NEW |