| 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 | 94 |
| 95 static PassRefPtr<DrawingBuffer> create(PassOwnPtr<WebGraphicsContext3D>, co
nst IntSize&, PreserveDrawingBuffer, WebGraphicsContext3D::Attributes requestedA
ttributes); | 95 static PassRefPtr<DrawingBuffer> create(PassOwnPtr<WebGraphicsContext3D>, co
nst IntSize&, PreserveDrawingBuffer, WebGraphicsContext3D::Attributes requestedA
ttributes); |
| 96 | 96 |
| 97 virtual ~DrawingBuffer(); | 97 virtual ~DrawingBuffer(); |
| 98 | 98 |
| 99 // Destruction will be completed after all mailboxes are released. | 99 // Destruction will be completed after all mailboxes are released. |
| 100 void beginDestruction(); | 100 void beginDestruction(); |
| 101 | 101 |
| 102 // Issues a glClear() on all framebuffers associated with this DrawingBuffer
. The caller is responsible for | 102 // Issues a glClear() on all framebuffers associated with this DrawingBuffer
. The caller is responsible for |
| 103 // making the context current and setting the clear values and masks. Modifi
es the framebuffer binding. | 103 // making the context current and setting the clear values and masks. Modifi
es the framebuffer binding. |
| 104 void clearFramebuffers(GLbitfield clearMask); | 104 void clearFramebuffers(GLbitfield clearMask, GLenum target = GL_FRAMEBUFFER)
; |
| 105 | 105 |
| 106 // Given the desired buffer size, provides the largest dimensions that will
fit in the pixel budget. | 106 // Given the desired buffer size, provides the largest dimensions that will
fit in the pixel budget. |
| 107 static IntSize adjustSize(const IntSize& desiredSize, const IntSize& curSize
, int maxTextureSize); | 107 static IntSize adjustSize(const IntSize& desiredSize, const IntSize& curSize
, int maxTextureSize); |
| 108 bool reset(const IntSize&); | 108 bool reset(const IntSize&); |
| 109 void bind(GLenum target = GL_FRAMEBUFFER); | 109 void bind(GLenum target = GL_FRAMEBUFFER); |
| 110 IntSize size() const { return m_size; } | 110 IntSize size() const { return m_size; } |
| 111 | 111 |
| 112 // Copies the multisample color buffer to the normal color buffer and leaves
m_fbo bound. | 112 // Copies the multisample color buffer to the normal color buffer and leaves
m_fbo bound. |
| 113 void commit(); | 113 void commit(GLenum target = GL_FRAMEBUFFER); |
| 114 | 114 |
| 115 // commit should copy the full multisample buffer, and not respect the | 115 // commit should copy the full multisample buffer, and not respect the |
| 116 // current scissor bounds. Track the state of the scissor test so that it | 116 // current scissor bounds. Track the state of the scissor test so that it |
| 117 // can be disabled during calls to commit. | 117 // can be disabled during calls to commit. |
| 118 void setScissorEnabled(bool scissorEnabled) { m_scissorEnabled = scissorEnab
led; } | 118 void setScissorEnabled(bool scissorEnabled) { m_scissorEnabled = scissorEnab
led; } |
| 119 | 119 |
| 120 // The DrawingBuffer needs to track the texture bound to texture unit 0. | 120 // The DrawingBuffer needs to track the texture bound to texture unit 0. |
| 121 // The bound texture is tracked to avoid costly queries during rendering. | 121 // The bound texture is tracked to avoid costly queries during rendering. |
| 122 void setTexture2DBinding(Platform3DObject texture) { m_texture2DBinding = te
xture; } | 122 void setTexture2DBinding(Platform3DObject texture) { m_texture2DBinding = te
xture; } |
| 123 | 123 |
| 124 // The DrawingBuffer needs to track the currently bound framebuffer so it | 124 // The DrawingBuffer needs to track the currently bound framebuffer so it |
| 125 // restore the binding when needed. | 125 // restore the binding when needed. |
| 126 void setFramebufferBinding(Platform3DObject fbo) { m_framebufferBinding = fb
o; } | 126 void setFramebufferBinding(Platform3DObject fbo, GLenum target = GL_FRAMEBUF
FER) |
| 127 { |
| 128 if (target == GL_READ_FRAMEBUFFER) |
| 129 m_readFramebufferBinding = fbo; |
| 130 else |
| 131 m_framebufferBinding = fbo; |
| 132 } |
| 127 | 133 |
| 128 // Track the currently active texture unit. Texture unit 0 is used as host f
or a scratch | 134 // Track the currently active texture unit. Texture unit 0 is used as host f
or a scratch |
| 129 // texture. | 135 // texture. |
| 130 void setActiveTextureUnit(GLint textureUnit) { m_activeTextureUnit = texture
Unit; } | 136 void setActiveTextureUnit(GLint textureUnit) { m_activeTextureUnit = texture
Unit; } |
| 131 | 137 |
| 132 bool multisample() const; | 138 bool multisample() const; |
| 133 | 139 |
| 134 Platform3DObject framebuffer() const; | 140 Platform3DObject framebuffer() const; |
| 135 | 141 |
| 136 bool discardFramebufferSupported() const { return m_discardFramebufferSuppor
ted; } | 142 bool discardFramebufferSupported() const { return m_discardFramebufferSuppor
ted; } |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 private: | 186 private: |
| 181 void mailboxReleasedWithoutRecycling(const WebExternalTextureMailbox&); | 187 void mailboxReleasedWithoutRecycling(const WebExternalTextureMailbox&); |
| 182 | 188 |
| 183 unsigned createColorTexture(); | 189 unsigned createColorTexture(); |
| 184 // Create the depth/stencil and multisample buffers, if needed. | 190 // Create the depth/stencil and multisample buffers, if needed. |
| 185 void createSecondaryBuffers(); | 191 void createSecondaryBuffers(); |
| 186 bool resizeFramebuffer(const IntSize&); | 192 bool resizeFramebuffer(const IntSize&); |
| 187 bool resizeMultisampleFramebuffer(const IntSize&); | 193 bool resizeMultisampleFramebuffer(const IntSize&); |
| 188 void resizeDepthStencil(const IntSize&); | 194 void resizeDepthStencil(const IntSize&); |
| 189 | 195 |
| 190 // Bind to the m_framebufferBinding if it's not 0. Otherwise, bind to the de
fault FBO. | 196 // Bind to m_framebufferBinding or m_readFramebufferBinding if it's not 0. |
| 191 void restoreFramebufferBinding(); | 197 // Otherwise, bind to the default FBO. |
| 198 void restoreFramebufferBinding(GLenum target = GL_FRAMEBUFFER); |
| 192 | 199 |
| 193 void clearPlatformLayer(); | 200 void clearPlatformLayer(); |
| 194 | 201 |
| 195 PassRefPtr<MailboxInfo> recycledMailbox(); | 202 PassRefPtr<MailboxInfo> recycledMailbox(); |
| 196 PassRefPtr<MailboxInfo> createNewMailbox(const TextureInfo&); | 203 PassRefPtr<MailboxInfo> createNewMailbox(const TextureInfo&); |
| 197 void deleteMailbox(const WebExternalTextureMailbox&); | 204 void deleteMailbox(const WebExternalTextureMailbox&); |
| 198 void freeRecycledMailboxes(); | 205 void freeRecycledMailboxes(); |
| 199 | 206 |
| 200 // Updates the current size of the buffer, ensuring that s_currentResourceUs
ePixels is updated. | 207 // Updates the current size of the buffer, ensuring that s_currentResourceUs
ePixels is updated. |
| 201 void setSize(const IntSize& size); | 208 void setSize(const IntSize& size); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 219 // By default, alignment is 4, the OpenGL default setting. | 226 // By default, alignment is 4, the OpenGL default setting. |
| 220 void texImage2DResourceSafe(GLenum target, GLint level, GLenum internalforma
t, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, GLin
t alignment = 4); | 227 void texImage2DResourceSafe(GLenum target, GLint level, GLenum internalforma
t, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, GLin
t alignment = 4); |
| 221 // Allocate buffer storage to be sent to compositor using either texImage2D
or CHROMIUM_image based on available support. | 228 // Allocate buffer storage to be sent to compositor using either texImage2D
or CHROMIUM_image based on available support. |
| 222 void allocateTextureMemory(TextureInfo*, const IntSize&); | 229 void allocateTextureMemory(TextureInfo*, const IntSize&); |
| 223 void deleteChromiumImageForTexture(TextureInfo*); | 230 void deleteChromiumImageForTexture(TextureInfo*); |
| 224 | 231 |
| 225 PreserveDrawingBuffer m_preserveDrawingBuffer; | 232 PreserveDrawingBuffer m_preserveDrawingBuffer; |
| 226 bool m_scissorEnabled; | 233 bool m_scissorEnabled; |
| 227 Platform3DObject m_texture2DBinding; | 234 Platform3DObject m_texture2DBinding; |
| 228 Platform3DObject m_framebufferBinding; | 235 Platform3DObject m_framebufferBinding; |
| 236 Platform3DObject m_readFramebufferBinding; |
| 229 GLenum m_activeTextureUnit; | 237 GLenum m_activeTextureUnit; |
| 230 | 238 |
| 231 OwnPtr<WebGraphicsContext3D> m_context; | 239 OwnPtr<WebGraphicsContext3D> m_context; |
| 232 OwnPtr<Extensions3DUtil> m_extensionsUtil; | 240 OwnPtr<Extensions3DUtil> m_extensionsUtil; |
| 233 IntSize m_size; | 241 IntSize m_size; |
| 234 WebGraphicsContext3D::Attributes m_requestedAttributes; | 242 WebGraphicsContext3D::Attributes m_requestedAttributes; |
| 235 bool m_multisampleExtensionSupported; | 243 bool m_multisampleExtensionSupported; |
| 236 bool m_packedDepthStencilExtensionSupported; | 244 bool m_packedDepthStencilExtensionSupported; |
| 237 bool m_discardFramebufferSupported; | 245 bool m_discardFramebufferSupported; |
| 238 Platform3DObject m_fbo; | 246 Platform3DObject m_fbo; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 // used to resize the Canvas. | 303 // used to resize the Canvas. |
| 296 SkBitmap m_resizingBitmap; | 304 SkBitmap m_resizingBitmap; |
| 297 | 305 |
| 298 // Used to flip a bitmap vertically. | 306 // Used to flip a bitmap vertically. |
| 299 Vector<uint8_t> m_scanline; | 307 Vector<uint8_t> m_scanline; |
| 300 }; | 308 }; |
| 301 | 309 |
| 302 } // namespace blink | 310 } // namespace blink |
| 303 | 311 |
| 304 #endif // DrawingBuffer_h | 312 #endif // DrawingBuffer_h |
| OLD | NEW |