| 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 // Copies the multisample color buffer to the normal color buffer and leaves
m_fbo bound. | 103 // Copies the multisample color buffer to the normal color buffer and leaves
m_fbo bound. |
| 104 void commit(); | 104 void commit(); |
| 105 | 105 |
| 106 // commit should copy the full multisample buffer, and not respect the | 106 // commit should copy the full multisample buffer, and not respect the |
| 107 // current scissor bounds. Track the state of the scissor test so that it | 107 // current scissor bounds. Track the state of the scissor test so that it |
| 108 // can be disabled during calls to commit. | 108 // can be disabled during calls to commit. |
| 109 void setScissorEnabled(bool scissorEnabled) { m_scissorEnabled = scissorEnab
led; } | 109 void setScissorEnabled(bool scissorEnabled) { m_scissorEnabled = scissorEnab
led; } |
| 110 | 110 |
| 111 // The DrawingBuffer needs to track the texture bound to texture unit 0. | 111 // The DrawingBuffer needs to track the texture bound to texture unit 0. |
| 112 // The bound texture is tracked to avoid costly queries during rendering. | 112 // The bound texture is tracked to avoid costly queries during rendering. |
| 113 void setTexture2DBinding(Platform3DObject texture) { m_texture2DBinding = te
xture; } | 113 void setTexture2DBinding(GLuint texture) { m_texture2DBinding = texture; } |
| 114 | 114 |
| 115 // The DrawingBuffer needs to track the currently bound framebuffer so it | 115 // The DrawingBuffer needs to track the currently bound framebuffer so it |
| 116 // restore the binding when needed. | 116 // restore the binding when needed. |
| 117 void setFramebufferBinding(GLenum target, Platform3DObject fbo) | 117 void setFramebufferBinding(GLenum target, GLuint fbo) |
| 118 { | 118 { |
| 119 switch (target) { | 119 switch (target) { |
| 120 case GL_FRAMEBUFFER: | 120 case GL_FRAMEBUFFER: |
| 121 m_drawFramebufferBinding = fbo; | 121 m_drawFramebufferBinding = fbo; |
| 122 m_readFramebufferBinding = fbo; | 122 m_readFramebufferBinding = fbo; |
| 123 break; | 123 break; |
| 124 case GL_DRAW_FRAMEBUFFER: | 124 case GL_DRAW_FRAMEBUFFER: |
| 125 m_drawFramebufferBinding = fbo; | 125 m_drawFramebufferBinding = fbo; |
| 126 break; | 126 break; |
| 127 case GL_READ_FRAMEBUFFER: | 127 case GL_READ_FRAMEBUFFER: |
| 128 m_readFramebufferBinding = fbo; | 128 m_readFramebufferBinding = fbo; |
| 129 break; | 129 break; |
| 130 default: | 130 default: |
| 131 ASSERT(0); | 131 ASSERT(0); |
| 132 } | 132 } |
| 133 } | 133 } |
| 134 | 134 |
| 135 // Track the currently active texture unit. Texture unit 0 is used as host f
or a scratch | 135 // Track the currently active texture unit. Texture unit 0 is used as host f
or a scratch |
| 136 // texture. | 136 // texture. |
| 137 void setActiveTextureUnit(GLint textureUnit) { m_activeTextureUnit = texture
Unit; } | 137 void setActiveTextureUnit(GLint textureUnit) { m_activeTextureUnit = texture
Unit; } |
| 138 | 138 |
| 139 bool multisample() const; | 139 bool multisample() const; |
| 140 | 140 |
| 141 Platform3DObject framebuffer() const; | 141 GLuint framebuffer() const; |
| 142 | 142 |
| 143 bool discardFramebufferSupported() const { return m_discardFramebufferSuppor
ted; } | 143 bool discardFramebufferSupported() const { return m_discardFramebufferSuppor
ted; } |
| 144 | 144 |
| 145 void markContentsChanged(); | 145 void markContentsChanged(); |
| 146 void setBufferClearNeeded(bool); | 146 void setBufferClearNeeded(bool); |
| 147 bool bufferClearNeeded() const; | 147 bool bufferClearNeeded() const; |
| 148 void setIsHidden(bool); | 148 void setIsHidden(bool); |
| 149 void setFilterQuality(SkFilterQuality); | 149 void setFilterQuality(SkFilterQuality); |
| 150 | 150 |
| 151 WebLayer* platformLayer(); | 151 WebLayer* platformLayer(); |
| 152 | 152 |
| 153 WebGraphicsContext3D* context(); | 153 WebGraphicsContext3D* context(); |
| 154 gpu::gles2::GLES2Interface* contextGL(); | 154 gpu::gles2::GLES2Interface* contextGL(); |
| 155 WebGraphicsContext3DProvider* contextProvider(); | 155 WebGraphicsContext3DProvider* contextProvider(); |
| 156 | 156 |
| 157 // Returns the actual context attributes for this drawing buffer which may d
iffer from the | 157 // Returns the actual context attributes for this drawing buffer which may d
iffer from the |
| 158 // requested context attributes due to implementation limits. | 158 // requested context attributes due to implementation limits. |
| 159 WebGraphicsContext3D::Attributes getActualAttributes() const { return m_actu
alAttributes; } | 159 WebGraphicsContext3D::Attributes getActualAttributes() const { return m_actu
alAttributes; } |
| 160 | 160 |
| 161 // WebExternalTextureLayerClient implementation. | 161 // WebExternalTextureLayerClient implementation. |
| 162 bool prepareMailbox(WebExternalTextureMailbox*, WebExternalBitmap*) override
; | 162 bool prepareMailbox(WebExternalTextureMailbox*, WebExternalBitmap*) override
; |
| 163 void mailboxReleased(const WebExternalTextureMailbox&, bool lostResource = f
alse) override; | 163 void mailboxReleased(const WebExternalTextureMailbox&, bool lostResource = f
alse) override; |
| 164 | 164 |
| 165 // Destroys the TEXTURE_2D binding for the owned context | 165 // Destroys the TEXTURE_2D binding for the owned context |
| 166 bool copyToPlatformTexture(WebGraphicsContext3D*, gpu::gles2::GLES2Interface
*, Platform3DObject texture, GLenum internalFormat, | 166 bool copyToPlatformTexture(WebGraphicsContext3D*, gpu::gles2::GLES2Interface
*, GLuint texture, GLenum internalFormat, |
| 167 GLenum destType, GLint level, bool premultiplyAlpha, bool flipY, SourceD
rawingBuffer); | 167 GLenum destType, GLint level, bool premultiplyAlpha, bool flipY, SourceD
rawingBuffer); |
| 168 | 168 |
| 169 void setPackAlignment(GLint param); | 169 void setPackAlignment(GLint param); |
| 170 | 170 |
| 171 bool paintRenderingResultsToImageData(int&, int&, SourceDrawingBuffer, WTF::
ArrayBufferContents&); | 171 bool paintRenderingResultsToImageData(int&, int&, SourceDrawingBuffer, WTF::
ArrayBufferContents&); |
| 172 | 172 |
| 173 int sampleCount() const { return m_sampleCount; } | 173 int sampleCount() const { return m_sampleCount; } |
| 174 bool explicitResolveOfMultisampleData() const { return m_antiAliasingMode ==
MSAAExplicitResolve; } | 174 bool explicitResolveOfMultisampleData() const { return m_antiAliasingMode ==
MSAAExplicitResolve; } |
| 175 | 175 |
| 176 // Bind to m_drawFramebufferBinding or m_readFramebufferBinding if it's not
0. | 176 // Bind to m_drawFramebufferBinding or m_readFramebufferBinding if it's not
0. |
| 177 // Otherwise, bind to the default FBO. | 177 // Otherwise, bind to the default FBO. |
| 178 void restoreFramebufferBindings(); | 178 void restoreFramebufferBindings(); |
| 179 | 179 |
| 180 void addNewMailboxCallback(PassOwnPtr<SameThreadClosure> closure) { m_newMai
lboxCallback = std::move(closure); } | 180 void addNewMailboxCallback(PassOwnPtr<SameThreadClosure> closure) { m_newMai
lboxCallback = std::move(closure); } |
| 181 | 181 |
| 182 protected: // For unittests | 182 protected: // For unittests |
| 183 DrawingBuffer( | 183 DrawingBuffer( |
| 184 PassOwnPtr<WebGraphicsContext3DProvider>, | 184 PassOwnPtr<WebGraphicsContext3DProvider>, |
| 185 PassOwnPtr<Extensions3DUtil>, | 185 PassOwnPtr<Extensions3DUtil>, |
| 186 bool multisampleExtensionSupported, | 186 bool multisampleExtensionSupported, |
| 187 bool discardFramebufferSupported, | 187 bool discardFramebufferSupported, |
| 188 PreserveDrawingBuffer, | 188 PreserveDrawingBuffer, |
| 189 WebGraphicsContext3D::Attributes requestedAttributes); | 189 WebGraphicsContext3D::Attributes requestedAttributes); |
| 190 | 190 |
| 191 bool initialize(const IntSize&); | 191 bool initialize(const IntSize&); |
| 192 | 192 |
| 193 private: | 193 private: |
| 194 struct TextureParameters { | 194 struct TextureParameters { |
| 195 DISALLOW_NEW(); | 195 DISALLOW_NEW(); |
| 196 WGC3Denum target; | 196 GLenum target; |
| 197 WGC3Denum internalColorFormat; | 197 GLenum internalColorFormat; |
| 198 WGC3Denum colorFormat; | 198 GLenum colorFormat; |
| 199 WGC3Denum internalRenderbufferFormat; | 199 GLenum internalRenderbufferFormat; |
| 200 | 200 |
| 201 TextureParameters() | 201 TextureParameters() |
| 202 : target(0) | 202 : target(0) |
| 203 , internalColorFormat(0) | 203 , internalColorFormat(0) |
| 204 , colorFormat(0) | 204 , colorFormat(0) |
| 205 , internalRenderbufferFormat(0) | 205 , internalRenderbufferFormat(0) |
| 206 { | 206 { |
| 207 } | 207 } |
| 208 }; | 208 }; |
| 209 | 209 |
| 210 // If we used CHROMIUM_image as the backing storage for our buffers, | 210 // If we used CHROMIUM_image as the backing storage for our buffers, |
| 211 // we need to know the mapping from texture id to image. | 211 // we need to know the mapping from texture id to image. |
| 212 struct TextureInfo { | 212 struct TextureInfo { |
| 213 DISALLOW_NEW(); | 213 DISALLOW_NEW(); |
| 214 Platform3DObject textureId; | 214 GLuint textureId; |
| 215 WGC3Duint imageId; | 215 GLuint imageId; |
| 216 TextureParameters parameters; | 216 TextureParameters parameters; |
| 217 | 217 |
| 218 TextureInfo() | 218 TextureInfo() |
| 219 : textureId(0) | 219 : textureId(0) |
| 220 , imageId(0) | 220 , imageId(0) |
| 221 { | 221 { |
| 222 } | 222 } |
| 223 }; | 223 }; |
| 224 | 224 |
| 225 struct MailboxInfo : public RefCounted<MailboxInfo> { | 225 struct MailboxInfo : public RefCounted<MailboxInfo> { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 242 TextureParameters chromiumImageTextureParameters(); | 242 TextureParameters chromiumImageTextureParameters(); |
| 243 | 243 |
| 244 // The texture parameters to use for a default texture. | 244 // The texture parameters to use for a default texture. |
| 245 TextureParameters defaultTextureParameters(); | 245 TextureParameters defaultTextureParameters(); |
| 246 | 246 |
| 247 void mailboxReleasedWithoutRecycling(const WebExternalTextureMailbox&); | 247 void mailboxReleasedWithoutRecycling(const WebExternalTextureMailbox&); |
| 248 | 248 |
| 249 // Creates and binds a texture with the given parameters. Returns 0 on | 249 // Creates and binds a texture with the given parameters. Returns 0 on |
| 250 // failure, or the newly created texture id on success. The caller takes | 250 // failure, or the newly created texture id on success. The caller takes |
| 251 // ownership of the newly created texture. | 251 // ownership of the newly created texture. |
| 252 WebGLId createColorTexture(const TextureParameters&); | 252 GLuint createColorTexture(const TextureParameters&); |
| 253 | 253 |
| 254 // Create the depth/stencil and multisample buffers, if needed. | 254 // Create the depth/stencil and multisample buffers, if needed. |
| 255 void createSecondaryBuffers(); | 255 void createSecondaryBuffers(); |
| 256 bool resizeFramebuffer(const IntSize&); | 256 bool resizeFramebuffer(const IntSize&); |
| 257 bool resizeMultisampleFramebuffer(const IntSize&); | 257 bool resizeMultisampleFramebuffer(const IntSize&); |
| 258 void resizeDepthStencil(const IntSize&); | 258 void resizeDepthStencil(const IntSize&); |
| 259 | 259 |
| 260 void clearPlatformLayer(); | 260 void clearPlatformLayer(); |
| 261 | 261 |
| 262 PassRefPtr<MailboxInfo> recycledMailbox(); | 262 PassRefPtr<MailboxInfo> recycledMailbox(); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 293 | 293 |
| 294 // Creates and allocates space for a default texture. | 294 // Creates and allocates space for a default texture. |
| 295 TextureInfo createDefaultTextureAndAllocateMemory(const IntSize&); | 295 TextureInfo createDefaultTextureAndAllocateMemory(const IntSize&); |
| 296 | 296 |
| 297 void resizeTextureMemory(TextureInfo*, const IntSize&); | 297 void resizeTextureMemory(TextureInfo*, const IntSize&); |
| 298 | 298 |
| 299 void attachColorBufferToCurrentFBO(); | 299 void attachColorBufferToCurrentFBO(); |
| 300 | 300 |
| 301 PreserveDrawingBuffer m_preserveDrawingBuffer; | 301 PreserveDrawingBuffer m_preserveDrawingBuffer; |
| 302 bool m_scissorEnabled; | 302 bool m_scissorEnabled; |
| 303 Platform3DObject m_texture2DBinding; | 303 GLuint m_texture2DBinding; |
| 304 Platform3DObject m_drawFramebufferBinding; | 304 GLuint m_drawFramebufferBinding; |
| 305 Platform3DObject m_readFramebufferBinding; | 305 GLuint m_readFramebufferBinding; |
| 306 GLenum m_activeTextureUnit; | 306 GLenum m_activeTextureUnit; |
| 307 | 307 |
| 308 OwnPtr<WebGraphicsContext3DProvider> m_contextProvider; | 308 OwnPtr<WebGraphicsContext3DProvider> m_contextProvider; |
| 309 WebGraphicsContext3D* m_context; // Lifetime is tied to the m_contextProvide
r. | 309 WebGraphicsContext3D* m_context; // Lifetime is tied to the m_contextProvide
r. |
| 310 gpu::gles2::GLES2Interface* m_gl; // Lifetime is tied to the m_contextProvid
er. | 310 gpu::gles2::GLES2Interface* m_gl; // Lifetime is tied to the m_contextProvid
er. |
| 311 OwnPtr<Extensions3DUtil> m_extensionsUtil; | 311 OwnPtr<Extensions3DUtil> m_extensionsUtil; |
| 312 IntSize m_size; | 312 IntSize m_size; |
| 313 WebGraphicsContext3D::Attributes m_requestedAttributes; | 313 WebGraphicsContext3D::Attributes m_requestedAttributes; |
| 314 bool m_multisampleExtensionSupported; | 314 bool m_multisampleExtensionSupported; |
| 315 bool m_discardFramebufferSupported; | 315 bool m_discardFramebufferSupported; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 // used to resize the Canvas. | 369 // used to resize the Canvas. |
| 370 SkBitmap m_resizingBitmap; | 370 SkBitmap m_resizingBitmap; |
| 371 | 371 |
| 372 // Used to flip a bitmap vertically. | 372 // Used to flip a bitmap vertically. |
| 373 Vector<uint8_t> m_scanline; | 373 Vector<uint8_t> m_scanline; |
| 374 }; | 374 }; |
| 375 | 375 |
| 376 } // namespace blink | 376 } // namespace blink |
| 377 | 377 |
| 378 #endif // DrawingBuffer_h | 378 #endif // DrawingBuffer_h |
| OLD | NEW |