| 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 // Destruction will be completed after all mailboxes are released. | 100 // Destruction will be completed after all mailboxes are released. |
| 101 void beginDestruction(); | 101 void beginDestruction(); |
| 102 | 102 |
| 103 // Issues a glClear() on all framebuffers associated with this DrawingBuffer
. The caller is responsible for | 103 // Issues a glClear() on all framebuffers associated with this DrawingBuffer
. The caller is responsible for |
| 104 // making the context current and setting the clear values and masks. Modifi
es the framebuffer binding. | 104 // making the context current and setting the clear values and masks. Modifi
es the framebuffer binding. |
| 105 void clearFramebuffers(GLbitfield clearMask); | 105 void clearFramebuffers(GLbitfield clearMask); |
| 106 | 106 |
| 107 // Given the desired buffer size, provides the largest dimensions that will
fit in the pixel budget. | 107 // Given the desired buffer size, provides the largest dimensions that will
fit in the pixel budget. |
| 108 static IntSize adjustSize(const IntSize& desiredSize, const IntSize& curSize
, int maxTextureSize); | 108 static IntSize adjustSize(const IntSize& desiredSize, const IntSize& curSize
, int maxTextureSize); |
| 109 bool reset(const IntSize&); | 109 bool reset(const IntSize&); |
| 110 void bind(GLenum target = GL_FRAMEBUFFER); | 110 void bind(GLenum target); |
| 111 IntSize size() const { return m_size; } | 111 IntSize size() const { return m_size; } |
| 112 | 112 |
| 113 // Copies the multisample color buffer to the normal color buffer and leaves
m_fbo bound. | 113 // Copies the multisample color buffer to the normal color buffer and leaves
m_fbo bound. |
| 114 void commit(); | 114 void commit(); |
| 115 | 115 |
| 116 // commit should copy the full multisample buffer, and not respect the | 116 // commit should copy the full multisample buffer, and not respect the |
| 117 // current scissor bounds. Track the state of the scissor test so that it | 117 // current scissor bounds. Track the state of the scissor test so that it |
| 118 // can be disabled during calls to commit. | 118 // can be disabled during calls to commit. |
| 119 void setScissorEnabled(bool scissorEnabled) { m_scissorEnabled = scissorEnab
led; } | 119 void setScissorEnabled(bool scissorEnabled) { m_scissorEnabled = scissorEnab
led; } |
| 120 | 120 |
| 121 // The DrawingBuffer needs to track the texture bound to texture unit 0. | 121 // The DrawingBuffer needs to track the texture bound to texture unit 0. |
| 122 // The bound texture is tracked to avoid costly queries during rendering. | 122 // The bound texture is tracked to avoid costly queries during rendering. |
| 123 void setTexture2DBinding(Platform3DObject texture) { m_texture2DBinding = te
xture; } | 123 void setTexture2DBinding(Platform3DObject texture) { m_texture2DBinding = te
xture; } |
| 124 | 124 |
| 125 // The DrawingBuffer needs to track the currently bound framebuffer so it | 125 // The DrawingBuffer needs to track the currently bound framebuffer so it |
| 126 // restore the binding when needed. | 126 // restore the binding when needed. |
| 127 void setFramebufferBinding(Platform3DObject fbo) { m_framebufferBinding = fb
o; } | 127 void setFramebufferBinding(GLenum target, Platform3DObject fbo) |
| 128 { |
| 129 switch (target) { |
| 130 case GL_FRAMEBUFFER: |
| 131 m_drawFramebufferBinding = fbo; |
| 132 m_readFramebufferBinding = fbo; |
| 133 break; |
| 134 case GL_DRAW_FRAMEBUFFER: |
| 135 m_drawFramebufferBinding = fbo; |
| 136 break; |
| 137 case GL_READ_FRAMEBUFFER: |
| 138 m_readFramebufferBinding = fbo; |
| 139 break; |
| 140 default: |
| 141 ASSERT(0); |
| 142 } |
| 143 } |
| 128 | 144 |
| 129 // Track the currently active texture unit. Texture unit 0 is used as host f
or a scratch | 145 // Track the currently active texture unit. Texture unit 0 is used as host f
or a scratch |
| 130 // texture. | 146 // texture. |
| 131 void setActiveTextureUnit(GLint textureUnit) { m_activeTextureUnit = texture
Unit; } | 147 void setActiveTextureUnit(GLint textureUnit) { m_activeTextureUnit = texture
Unit; } |
| 132 | 148 |
| 133 bool multisample() const; | 149 bool multisample() const; |
| 134 | 150 |
| 135 Platform3DObject framebuffer() const; | 151 Platform3DObject framebuffer() const; |
| 136 | 152 |
| 137 bool discardFramebufferSupported() const { return m_discardFramebufferSuppor
ted; } | 153 bool discardFramebufferSupported() const { return m_discardFramebufferSuppor
ted; } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 159 GLenum destType, GLint level, bool premultiplyAlpha, bool flipY, SourceD
rawingBuffer); | 175 GLenum destType, GLint level, bool premultiplyAlpha, bool flipY, SourceD
rawingBuffer); |
| 160 | 176 |
| 161 void setPackAlignment(GLint param); | 177 void setPackAlignment(GLint param); |
| 162 | 178 |
| 163 void paintRenderingResultsToCanvas(ImageBuffer*); | 179 void paintRenderingResultsToCanvas(ImageBuffer*); |
| 164 bool paintRenderingResultsToImageData(int&, int&, SourceDrawingBuffer, WTF::
ArrayBufferContents&); | 180 bool paintRenderingResultsToImageData(int&, int&, SourceDrawingBuffer, WTF::
ArrayBufferContents&); |
| 165 | 181 |
| 166 int sampleCount() const { return m_sampleCount; } | 182 int sampleCount() const { return m_sampleCount; } |
| 167 bool explicitResolveOfMultisampleData() const { return m_multisampleMode ==
ExplicitResolve; }; | 183 bool explicitResolveOfMultisampleData() const { return m_multisampleMode ==
ExplicitResolve; }; |
| 168 | 184 |
| 185 // Bind to m_drawFramebufferBinding or m_readFramebufferBinding if it's not
0. |
| 186 // Otherwise, bind to the default FBO. |
| 187 void restoreFramebufferBindings(); |
| 188 |
| 169 protected: // For unittests | 189 protected: // For unittests |
| 170 DrawingBuffer( | 190 DrawingBuffer( |
| 171 PassOwnPtr<WebGraphicsContext3D>, | 191 PassOwnPtr<WebGraphicsContext3D>, |
| 172 PassOwnPtr<Extensions3DUtil>, | 192 PassOwnPtr<Extensions3DUtil>, |
| 173 bool multisampleExtensionSupported, | 193 bool multisampleExtensionSupported, |
| 174 bool packedDepthStencilExtensionSupported, | 194 bool packedDepthStencilExtensionSupported, |
| 175 bool discardFramebufferSupported, | 195 bool discardFramebufferSupported, |
| 176 PreserveDrawingBuffer, | 196 PreserveDrawingBuffer, |
| 177 WebGraphicsContext3D::Attributes requestedAttributes); | 197 WebGraphicsContext3D::Attributes requestedAttributes); |
| 178 | 198 |
| 179 bool initialize(const IntSize&); | 199 bool initialize(const IntSize&); |
| 180 | 200 |
| 181 private: | 201 private: |
| 182 void mailboxReleasedWithoutRecycling(const WebExternalTextureMailbox&); | 202 void mailboxReleasedWithoutRecycling(const WebExternalTextureMailbox&); |
| 183 | 203 |
| 184 unsigned createColorTexture(); | 204 unsigned createColorTexture(); |
| 185 // Create the depth/stencil and multisample buffers, if needed. | 205 // Create the depth/stencil and multisample buffers, if needed. |
| 186 void createSecondaryBuffers(); | 206 void createSecondaryBuffers(); |
| 187 bool resizeFramebuffer(const IntSize&); | 207 bool resizeFramebuffer(const IntSize&); |
| 188 bool resizeMultisampleFramebuffer(const IntSize&); | 208 bool resizeMultisampleFramebuffer(const IntSize&); |
| 189 void resizeDepthStencil(const IntSize&); | 209 void resizeDepthStencil(const IntSize&); |
| 190 | 210 |
| 191 // Bind to the m_framebufferBinding if it's not 0. Otherwise, bind to the de
fault FBO. | |
| 192 void restoreFramebufferBinding(); | |
| 193 | |
| 194 void clearPlatformLayer(); | 211 void clearPlatformLayer(); |
| 195 | 212 |
| 196 PassRefPtr<MailboxInfo> recycledMailbox(); | 213 PassRefPtr<MailboxInfo> recycledMailbox(); |
| 197 PassRefPtr<MailboxInfo> createNewMailbox(const TextureInfo&); | 214 PassRefPtr<MailboxInfo> createNewMailbox(const TextureInfo&); |
| 198 void deleteMailbox(const WebExternalTextureMailbox&); | 215 void deleteMailbox(const WebExternalTextureMailbox&); |
| 199 void freeRecycledMailboxes(); | 216 void freeRecycledMailboxes(); |
| 200 | 217 |
| 201 // Updates the current size of the buffer, ensuring that s_currentResourceUs
ePixels is updated. | 218 // Updates the current size of the buffer, ensuring that s_currentResourceUs
ePixels is updated. |
| 202 void setSize(const IntSize& size); | 219 void setSize(const IntSize& size); |
| 203 | 220 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 219 // Helper to texImage2D with pixel==0 case: pixels are initialized to 0. | 236 // Helper to texImage2D with pixel==0 case: pixels are initialized to 0. |
| 220 // By default, alignment is 4, the OpenGL default setting. | 237 // By default, alignment is 4, the OpenGL default setting. |
| 221 void texImage2DResourceSafe(GLenum target, GLint level, GLenum internalforma
t, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, GLin
t alignment = 4); | 238 void texImage2DResourceSafe(GLenum target, GLint level, GLenum internalforma
t, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, GLin
t alignment = 4); |
| 222 // Allocate buffer storage to be sent to compositor using either texImage2D
or CHROMIUM_image based on available support. | 239 // Allocate buffer storage to be sent to compositor using either texImage2D
or CHROMIUM_image based on available support. |
| 223 void allocateTextureMemory(TextureInfo*, const IntSize&); | 240 void allocateTextureMemory(TextureInfo*, const IntSize&); |
| 224 void deleteChromiumImageForTexture(TextureInfo*); | 241 void deleteChromiumImageForTexture(TextureInfo*); |
| 225 | 242 |
| 226 PreserveDrawingBuffer m_preserveDrawingBuffer; | 243 PreserveDrawingBuffer m_preserveDrawingBuffer; |
| 227 bool m_scissorEnabled; | 244 bool m_scissorEnabled; |
| 228 Platform3DObject m_texture2DBinding; | 245 Platform3DObject m_texture2DBinding; |
| 229 Platform3DObject m_framebufferBinding; | 246 Platform3DObject m_drawFramebufferBinding; |
| 247 Platform3DObject m_readFramebufferBinding; |
| 230 GLenum m_activeTextureUnit; | 248 GLenum m_activeTextureUnit; |
| 231 | 249 |
| 232 OwnPtr<WebGraphicsContext3D> m_context; | 250 OwnPtr<WebGraphicsContext3D> m_context; |
| 233 OwnPtr<Extensions3DUtil> m_extensionsUtil; | 251 OwnPtr<Extensions3DUtil> m_extensionsUtil; |
| 234 IntSize m_size; | 252 IntSize m_size; |
| 235 WebGraphicsContext3D::Attributes m_requestedAttributes; | 253 WebGraphicsContext3D::Attributes m_requestedAttributes; |
| 236 bool m_multisampleExtensionSupported; | 254 bool m_multisampleExtensionSupported; |
| 237 bool m_packedDepthStencilExtensionSupported; | 255 bool m_packedDepthStencilExtensionSupported; |
| 238 bool m_discardFramebufferSupported; | 256 bool m_discardFramebufferSupported; |
| 239 Platform3DObject m_fbo; | 257 Platform3DObject m_fbo; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 // used to resize the Canvas. | 314 // used to resize the Canvas. |
| 297 SkBitmap m_resizingBitmap; | 315 SkBitmap m_resizingBitmap; |
| 298 | 316 |
| 299 // Used to flip a bitmap vertically. | 317 // Used to flip a bitmap vertically. |
| 300 Vector<uint8_t> m_scanline; | 318 Vector<uint8_t> m_scanline; |
| 301 }; | 319 }; |
| 302 | 320 |
| 303 } // namespace blink | 321 } // namespace blink |
| 304 | 322 |
| 305 #endif // DrawingBuffer_h | 323 #endif // DrawingBuffer_h |
| OLD | NEW |