| 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 public: | 63 public: |
| 64 virtual ~ContextEvictionManager() {}; | 64 virtual ~ContextEvictionManager() {}; |
| 65 | 65 |
| 66 virtual void forciblyLoseOldestContext(const String& reason) = 0; | 66 virtual void forciblyLoseOldestContext(const String& reason) = 0; |
| 67 virtual IntSize oldestContextSize() = 0; | 67 virtual IntSize oldestContextSize() = 0; |
| 68 }; | 68 }; |
| 69 | 69 |
| 70 // Manages a rendering target (framebuffer + attachment) for a canvas. Can publ
ish its rendering | 70 // Manages a rendering target (framebuffer + attachment) for a canvas. Can publ
ish its rendering |
| 71 // results to a blink::WebLayer for compositing. | 71 // results to a blink::WebLayer for compositing. |
| 72 class PLATFORM_EXPORT DrawingBuffer : public RefCounted<DrawingBuffer>, public b
link::WebExternalTextureLayerClient { | 72 class PLATFORM_EXPORT DrawingBuffer : public RefCounted<DrawingBuffer>, public b
link::WebExternalTextureLayerClient { |
| 73 // If we used CHROMIUM_image as the backing storage for our buffers, |
| 74 // we need to know the mapping from texture id to image. |
| 75 struct TextureInfo { |
| 76 Platform3DObject textureId; |
| 77 blink::WGC3Duint imageId; |
| 78 |
| 79 TextureInfo() |
| 80 : textureId(0) |
| 81 , imageId(0) |
| 82 { |
| 83 } |
| 84 }; |
| 85 |
| 73 struct MailboxInfo : public RefCounted<MailboxInfo> { | 86 struct MailboxInfo : public RefCounted<MailboxInfo> { |
| 74 blink::WebExternalTextureMailbox mailbox; | 87 blink::WebExternalTextureMailbox mailbox; |
| 75 unsigned textureId; | 88 TextureInfo textureInfo; |
| 76 IntSize size; | 89 IntSize size; |
| 77 // This keeps the parent drawing buffer alive as long as the compositor
is | 90 // This keeps the parent drawing buffer alive as long as the compositor
is |
| 78 // referring to one of the mailboxes DrawingBuffer produced. The parent
drawing buffer is | 91 // referring to one of the mailboxes DrawingBuffer produced. The parent
drawing buffer is |
| 79 // cleared when the compositor returns the mailbox. See mailboxReleased(
). | 92 // cleared when the compositor returns the mailbox. See mailboxReleased(
). |
| 80 RefPtr<DrawingBuffer> m_parentDrawingBuffer; | 93 RefPtr<DrawingBuffer> m_parentDrawingBuffer; |
| 81 }; | 94 }; |
| 82 public: | 95 public: |
| 83 enum PreserveDrawingBuffer { | 96 enum PreserveDrawingBuffer { |
| 84 Preserve, | 97 Preserve, |
| 85 Discard | 98 Discard |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 PassOwnPtr<blink::WebGraphicsContext3D>, | 166 PassOwnPtr<blink::WebGraphicsContext3D>, |
| 154 PassOwnPtr<Extensions3DUtil>, | 167 PassOwnPtr<Extensions3DUtil>, |
| 155 bool multisampleExtensionSupported, | 168 bool multisampleExtensionSupported, |
| 156 bool packedDepthStencilExtensionSupported, PreserveDrawingBuffer, PassRe
fPtr<ContextEvictionManager>); | 169 bool packedDepthStencilExtensionSupported, PreserveDrawingBuffer, PassRe
fPtr<ContextEvictionManager>); |
| 157 | 170 |
| 158 bool initialize(const IntSize&); | 171 bool initialize(const IntSize&); |
| 159 | 172 |
| 160 private: | 173 private: |
| 161 void mailboxReleasedWhileDestructionInProgress(const blink::WebExternalTextu
reMailbox&); | 174 void mailboxReleasedWhileDestructionInProgress(const blink::WebExternalTextu
reMailbox&); |
| 162 | 175 |
| 163 unsigned createColorTexture(const IntSize& size = IntSize()); | 176 unsigned createColorTexture(); |
| 164 // Create the depth/stencil and multisample buffers, if needed. | 177 // Create the depth/stencil and multisample buffers, if needed. |
| 165 void createSecondaryBuffers(); | 178 void createSecondaryBuffers(); |
| 166 bool resizeFramebuffer(const IntSize&); | 179 bool resizeFramebuffer(const IntSize&); |
| 167 bool resizeMultisampleFramebuffer(const IntSize&); | 180 bool resizeMultisampleFramebuffer(const IntSize&); |
| 168 void resizeDepthStencil(const IntSize&); | 181 void resizeDepthStencil(const IntSize&); |
| 169 | 182 |
| 170 // Bind to the m_framebufferBinding if it's not 0. | 183 // Bind to the m_framebufferBinding if it's not 0. |
| 171 void restoreFramebufferBinding(); | 184 void restoreFramebufferBinding(); |
| 172 | 185 |
| 173 void clearPlatformLayer(); | 186 void clearPlatformLayer(); |
| 174 | 187 |
| 175 PassRefPtr<MailboxInfo> recycledMailbox(); | 188 PassRefPtr<MailboxInfo> recycledMailbox(); |
| 176 PassRefPtr<MailboxInfo> createNewMailbox(unsigned); | 189 PassRefPtr<MailboxInfo> createNewMailbox(const TextureInfo&); |
| 177 void deleteMailbox(const blink::WebExternalTextureMailbox&); | 190 void deleteMailbox(const blink::WebExternalTextureMailbox&); |
| 178 | 191 |
| 179 // Updates the current size of the buffer, ensuring that s_currentResourceUs
ePixels is updated. | 192 // Updates the current size of the buffer, ensuring that s_currentResourceUs
ePixels is updated. |
| 180 void setSize(const IntSize& size); | 193 void setSize(const IntSize& size); |
| 181 | 194 |
| 182 // Calculates the difference in pixels between the current buffer size and t
he proposed size. | 195 // Calculates the difference in pixels between the current buffer size and t
he proposed size. |
| 183 static int pixelDelta(const IntSize& newSize, const IntSize& curSize); | 196 static int pixelDelta(const IntSize& newSize, const IntSize& curSize); |
| 184 | 197 |
| 185 // Given the desired buffer size, provides the largest dimensions that will
fit in the pixel budget | 198 // Given the desired buffer size, provides the largest dimensions that will
fit in the pixel budget |
| 186 // Returns true if the buffer will only fit if the oldest WebGL context is f
orcibly lost | 199 // Returns true if the buffer will only fit if the oldest WebGL context is f
orcibly lost |
| (...skipping 10 matching lines...) Expand all Loading... |
| 197 // Helper function which does a readback from the currently-bound | 210 // Helper function which does a readback from the currently-bound |
| 198 // framebuffer into a buffer of a certain size with 4-byte pixels. | 211 // 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); | 212 void readBackFramebuffer(unsigned char* pixels, int width, int height, Readb
ackOrder, WebGLImageConversion::AlphaOp); |
| 200 | 213 |
| 201 // Helper function to flip a bitmap vertically. | 214 // Helper function to flip a bitmap vertically. |
| 202 void flipVertically(uint8_t* data, int width, int height); | 215 void flipVertically(uint8_t* data, int width, int height); |
| 203 | 216 |
| 204 // Helper to texImage2D with pixel==0 case: pixels are initialized to 0. | 217 // Helper to texImage2D with pixel==0 case: pixels are initialized to 0. |
| 205 // By default, alignment is 4, the OpenGL default setting. | 218 // 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); | 219 void texImage2DResourceSafe(GLenum target, GLint level, GLenum internalforma
t, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, GLin
t alignment = 4); |
| 220 // Allocate buffer storage to be sent to compositor using either texImage2D
or CHROMIUM_image based on available support. |
| 221 void allocateTextureMemory(TextureInfo*, const IntSize&); |
| 222 void deleteChromiumImageForTexture(TextureInfo*); |
| 207 | 223 |
| 208 PreserveDrawingBuffer m_preserveDrawingBuffer; | 224 PreserveDrawingBuffer m_preserveDrawingBuffer; |
| 209 bool m_scissorEnabled; | 225 bool m_scissorEnabled; |
| 210 Platform3DObject m_texture2DBinding; | 226 Platform3DObject m_texture2DBinding; |
| 211 Platform3DObject m_framebufferBinding; | 227 Platform3DObject m_framebufferBinding; |
| 212 GLenum m_activeTextureUnit; | 228 GLenum m_activeTextureUnit; |
| 213 | 229 |
| 214 OwnPtr<blink::WebGraphicsContext3D> m_context; | 230 OwnPtr<blink::WebGraphicsContext3D> m_context; |
| 215 OwnPtr<Extensions3DUtil> m_extensionsUtil; | 231 OwnPtr<Extensions3DUtil> m_extensionsUtil; |
| 216 IntSize m_size; | 232 IntSize m_size; |
| 217 bool m_multisampleExtensionSupported; | 233 bool m_multisampleExtensionSupported; |
| 218 bool m_packedDepthStencilExtensionSupported; | 234 bool m_packedDepthStencilExtensionSupported; |
| 219 Platform3DObject m_fbo; | 235 Platform3DObject m_fbo; |
| 220 // DrawingBuffer's output is double-buffered. m_colorBuffer is the back buff
er. | 236 // DrawingBuffer's output is double-buffered. m_colorBuffer is the back buff
er. |
| 221 Platform3DObject m_colorBuffer; | 237 TextureInfo m_colorBuffer; |
| 222 Platform3DObject m_frontColorBuffer; | 238 TextureInfo m_frontColorBuffer; |
| 223 | 239 |
| 224 // This is used when we have OES_packed_depth_stencil. | 240 // This is used when we have OES_packed_depth_stencil. |
| 225 Platform3DObject m_depthStencilBuffer; | 241 Platform3DObject m_depthStencilBuffer; |
| 226 | 242 |
| 227 // These are used when we don't. | 243 // These are used when we don't. |
| 228 Platform3DObject m_depthBuffer; | 244 Platform3DObject m_depthBuffer; |
| 229 Platform3DObject m_stencilBuffer; | 245 Platform3DObject m_stencilBuffer; |
| 230 | 246 |
| 231 // For multisampling. | 247 // For multisampling. |
| 232 Platform3DObject m_multisampleFBO; | 248 Platform3DObject m_multisampleFBO; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 // used to resize the Canvas. | 288 // used to resize the Canvas. |
| 273 SkBitmap m_resizingBitmap; | 289 SkBitmap m_resizingBitmap; |
| 274 | 290 |
| 275 // Used to flip a bitmap vertically. | 291 // Used to flip a bitmap vertically. |
| 276 Vector<uint8_t> m_scanline; | 292 Vector<uint8_t> m_scanline; |
| 277 }; | 293 }; |
| 278 | 294 |
| 279 } // namespace WebCore | 295 } // namespace WebCore |
| 280 | 296 |
| 281 #endif // DrawingBuffer_h | 297 #endif // DrawingBuffer_h |
| OLD | NEW |