| 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 23 matching lines...) Expand all Loading... |
| 34 #include "platform/PlatformExport.h" | 34 #include "platform/PlatformExport.h" |
| 35 #include "platform/geometry/IntSize.h" | 35 #include "platform/geometry/IntSize.h" |
| 36 #include "platform/graphics/GraphicsTypes3D.h" | 36 #include "platform/graphics/GraphicsTypes3D.h" |
| 37 #include "platform/graphics/gpu/WebGLImageConversion.h" | 37 #include "platform/graphics/gpu/WebGLImageConversion.h" |
| 38 #include "public/platform/WebExternalTextureLayerClient.h" | 38 #include "public/platform/WebExternalTextureLayerClient.h" |
| 39 #include "public/platform/WebExternalTextureMailbox.h" | 39 #include "public/platform/WebExternalTextureMailbox.h" |
| 40 #include "third_party/khronos/GLES2/gl2.h" | 40 #include "third_party/khronos/GLES2/gl2.h" |
| 41 #include "third_party/skia/include/core/SkBitmap.h" | 41 #include "third_party/skia/include/core/SkBitmap.h" |
| 42 #include "wtf/Deque.h" | 42 #include "wtf/Deque.h" |
| 43 #include "wtf/Noncopyable.h" | 43 #include "wtf/Noncopyable.h" |
| 44 #include "wtf/OwnPtr.h" | |
| 45 #include "wtf/PassOwnPtr.h" | |
| 46 #include "wtf/RefCounted.h" | 44 #include "wtf/RefCounted.h" |
| 45 #include <memory> |
| 47 | 46 |
| 48 namespace gpu { | 47 namespace gpu { |
| 49 namespace gles2 { | 48 namespace gles2 { |
| 50 class GLES2Interface; | 49 class GLES2Interface; |
| 51 } | 50 } |
| 52 } | 51 } |
| 53 | 52 |
| 54 namespace WTF { | 53 namespace WTF { |
| 55 class ArrayBufferContents; | 54 class ArrayBufferContents; |
| 56 } | 55 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 68 // results to a WebLayer for compositing. | 67 // results to a WebLayer for compositing. |
| 69 class PLATFORM_EXPORT DrawingBuffer : public RefCounted<DrawingBuffer>, public W
ebExternalTextureLayerClient { | 68 class PLATFORM_EXPORT DrawingBuffer : public RefCounted<DrawingBuffer>, public W
ebExternalTextureLayerClient { |
| 70 WTF_MAKE_NONCOPYABLE(DrawingBuffer); | 69 WTF_MAKE_NONCOPYABLE(DrawingBuffer); |
| 71 public: | 70 public: |
| 72 enum PreserveDrawingBuffer { | 71 enum PreserveDrawingBuffer { |
| 73 Preserve, | 72 Preserve, |
| 74 Discard | 73 Discard |
| 75 }; | 74 }; |
| 76 | 75 |
| 77 static PassRefPtr<DrawingBuffer> create( | 76 static PassRefPtr<DrawingBuffer> create( |
| 78 PassOwnPtr<WebGraphicsContext3DProvider>, | 77 std::unique_ptr<WebGraphicsContext3DProvider>, |
| 79 const IntSize&, | 78 const IntSize&, |
| 80 bool premultipliedAlpha, | 79 bool premultipliedAlpha, |
| 81 bool wantAlphaChannel, | 80 bool wantAlphaChannel, |
| 82 bool wantDepthBuffer, | 81 bool wantDepthBuffer, |
| 83 bool wantStencilBuffer, | 82 bool wantStencilBuffer, |
| 84 bool wantAntialiasing, | 83 bool wantAntialiasing, |
| 85 PreserveDrawingBuffer); | 84 PreserveDrawingBuffer); |
| 86 static void forceNextDrawingBufferCreationToFail(); | 85 static void forceNextDrawingBufferCreationToFail(); |
| 87 | 86 |
| 88 ~DrawingBuffer() override; | 87 ~DrawingBuffer() override; |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 // Bind to m_drawFramebufferBinding or m_readFramebufferBinding if it's not
0. | 214 // Bind to m_drawFramebufferBinding or m_readFramebufferBinding if it's not
0. |
| 216 // Otherwise, bind to the default FBO. | 215 // Otherwise, bind to the default FBO. |
| 217 void restoreFramebufferBindings(); | 216 void restoreFramebufferBindings(); |
| 218 | 217 |
| 219 void restoreTextureBindings(); | 218 void restoreTextureBindings(); |
| 220 | 219 |
| 221 void addNewMailboxCallback(std::unique_ptr<SameThreadClosure> closure) { m_n
ewMailboxCallback = std::move(closure); } | 220 void addNewMailboxCallback(std::unique_ptr<SameThreadClosure> closure) { m_n
ewMailboxCallback = std::move(closure); } |
| 222 | 221 |
| 223 protected: // For unittests | 222 protected: // For unittests |
| 224 DrawingBuffer( | 223 DrawingBuffer( |
| 225 PassOwnPtr<WebGraphicsContext3DProvider>, | 224 std::unique_ptr<WebGraphicsContext3DProvider>, |
| 226 PassOwnPtr<Extensions3DUtil>, | 225 std::unique_ptr<Extensions3DUtil>, |
| 227 bool discardFramebufferSupported, | 226 bool discardFramebufferSupported, |
| 228 bool wantAlphaChannel, | 227 bool wantAlphaChannel, |
| 229 bool premultipliedAlpha, | 228 bool premultipliedAlpha, |
| 230 PreserveDrawingBuffer, | 229 PreserveDrawingBuffer, |
| 231 bool wantsDepth, | 230 bool wantsDepth, |
| 232 bool wantsStencil); | 231 bool wantsStencil); |
| 233 | 232 |
| 234 bool initialize(const IntSize&, bool useMultisampling); | 233 bool initialize(const IntSize&, bool useMultisampling); |
| 235 | 234 |
| 236 private: | 235 private: |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 const PreserveDrawingBuffer m_preserveDrawingBuffer; | 360 const PreserveDrawingBuffer m_preserveDrawingBuffer; |
| 362 bool m_scissorEnabled = false; | 361 bool m_scissorEnabled = false; |
| 363 GLuint m_texture2DBinding = 0; | 362 GLuint m_texture2DBinding = 0; |
| 364 GLuint m_drawFramebufferBinding = 0; | 363 GLuint m_drawFramebufferBinding = 0; |
| 365 GLuint m_readFramebufferBinding = 0; | 364 GLuint m_readFramebufferBinding = 0; |
| 366 GLuint m_renderbufferBinding = 0; | 365 GLuint m_renderbufferBinding = 0; |
| 367 GLenum m_activeTextureUnit = GL_TEXTURE0; | 366 GLenum m_activeTextureUnit = GL_TEXTURE0; |
| 368 GLfloat m_clearColor[4]; | 367 GLfloat m_clearColor[4]; |
| 369 GLboolean m_colorMask[4]; | 368 GLboolean m_colorMask[4]; |
| 370 | 369 |
| 371 OwnPtr<WebGraphicsContext3DProvider> m_contextProvider; | 370 std::unique_ptr<WebGraphicsContext3DProvider> m_contextProvider; |
| 372 // Lifetime is tied to the m_contextProvider. | 371 // Lifetime is tied to the m_contextProvider. |
| 373 gpu::gles2::GLES2Interface* m_gl; | 372 gpu::gles2::GLES2Interface* m_gl; |
| 374 OwnPtr<Extensions3DUtil> m_extensionsUtil; | 373 std::unique_ptr<Extensions3DUtil> m_extensionsUtil; |
| 375 IntSize m_size = { -1, -1 }; | 374 IntSize m_size = { -1, -1 }; |
| 376 const bool m_discardFramebufferSupported; | 375 const bool m_discardFramebufferSupported; |
| 377 const bool m_wantAlphaChannel; | 376 const bool m_wantAlphaChannel; |
| 378 const bool m_premultipliedAlpha; | 377 const bool m_premultipliedAlpha; |
| 379 bool m_hasImplicitStencilBuffer = false; | 378 bool m_hasImplicitStencilBuffer = false; |
| 380 struct FrontBufferInfo { | 379 struct FrontBufferInfo { |
| 381 TextureInfo texInfo; | 380 TextureInfo texInfo; |
| 382 WebExternalTextureMailbox mailbox; | 381 WebExternalTextureMailbox mailbox; |
| 383 }; | 382 }; |
| 384 FrontBufferInfo m_frontColorBuffer; | 383 FrontBufferInfo m_frontColorBuffer; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 | 423 |
| 425 AntialiasingMode m_antiAliasingMode = None; | 424 AntialiasingMode m_antiAliasingMode = None; |
| 426 | 425 |
| 427 int m_maxTextureSize = 0; | 426 int m_maxTextureSize = 0; |
| 428 int m_sampleCount = 0; | 427 int m_sampleCount = 0; |
| 429 int m_packAlignment = 4; | 428 int m_packAlignment = 4; |
| 430 bool m_destructionInProgress = false; | 429 bool m_destructionInProgress = false; |
| 431 bool m_isHidden = false; | 430 bool m_isHidden = false; |
| 432 SkFilterQuality m_filterQuality = kLow_SkFilterQuality; | 431 SkFilterQuality m_filterQuality = kLow_SkFilterQuality; |
| 433 | 432 |
| 434 OwnPtr<WebExternalTextureLayer> m_layer; | 433 std::unique_ptr<WebExternalTextureLayer> m_layer; |
| 435 | 434 |
| 436 // All of the mailboxes that this DrawingBuffer has ever created. | 435 // All of the mailboxes that this DrawingBuffer has ever created. |
| 437 Vector<RefPtr<MailboxInfo>> m_textureMailboxes; | 436 Vector<RefPtr<MailboxInfo>> m_textureMailboxes; |
| 438 // Mailboxes that were released by the compositor can be used again by this
DrawingBuffer. | 437 // Mailboxes that were released by the compositor can be used again by this
DrawingBuffer. |
| 439 Deque<WebExternalTextureMailbox> m_recycledMailboxQueue; | 438 Deque<WebExternalTextureMailbox> m_recycledMailboxQueue; |
| 440 | 439 |
| 441 // If the width and height of the Canvas's backing store don't | 440 // If the width and height of the Canvas's backing store don't |
| 442 // match those that we were given in the most recent call to | 441 // match those that we were given in the most recent call to |
| 443 // reshape(), then we need an intermediate bitmap to read back the | 442 // reshape(), then we need an intermediate bitmap to read back the |
| 444 // frame buffer into. This seems to happen when CSS styles are | 443 // frame buffer into. This seems to happen when CSS styles are |
| 445 // used to resize the Canvas. | 444 // used to resize the Canvas. |
| 446 SkBitmap m_resizingBitmap; | 445 SkBitmap m_resizingBitmap; |
| 447 | 446 |
| 448 // Used to flip a bitmap vertically. | 447 // Used to flip a bitmap vertically. |
| 449 Vector<uint8_t> m_scanline; | 448 Vector<uint8_t> m_scanline; |
| 450 }; | 449 }; |
| 451 | 450 |
| 452 } // namespace blink | 451 } // namespace blink |
| 453 | 452 |
| 454 #endif // DrawingBuffer_h | 453 #endif // DrawingBuffer_h |
| OLD | NEW |