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