| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #ifndef Canvas2DLayerBridge_h | 26 #ifndef Canvas2DLayerBridge_h |
| 27 #define Canvas2DLayerBridge_h | 27 #define Canvas2DLayerBridge_h |
| 28 | 28 |
| 29 #include "SkDeferredCanvas.h" | 29 #include "SkDeferredCanvas.h" |
| 30 #include "SkImage.h" | 30 #include "SkImage.h" |
| 31 #include "core/platform/graphics/GraphicsContext3D.h" | 31 #include "core/platform/graphics/GraphicsContext3D.h" |
| 32 #include "platform/geometry/IntSize.h" | 32 #include "platform/geometry/IntSize.h" |
| 33 #include "platform/graphics/ImageBufferSurface.h" |
| 33 #include "public/platform/WebExternalTextureLayer.h" | 34 #include "public/platform/WebExternalTextureLayer.h" |
| 34 #include "public/platform/WebExternalTextureLayerClient.h" | 35 #include "public/platform/WebExternalTextureLayerClient.h" |
| 35 #include "public/platform/WebExternalTextureMailbox.h" | 36 #include "public/platform/WebExternalTextureMailbox.h" |
| 36 #include "wtf/DoublyLinkedList.h" | 37 #include "wtf/DoublyLinkedList.h" |
| 37 #include "wtf/PassOwnPtr.h" | 38 #include "wtf/PassOwnPtr.h" |
| 38 #include "wtf/RefPtr.h" | 39 #include "wtf/RefPtr.h" |
| 39 | 40 |
| 40 namespace blink { | 41 namespace blink { |
| 41 class WebGraphicsContext3D; | 42 class WebGraphicsContext3D; |
| 42 } | 43 } |
| 43 | 44 |
| 44 namespace WebCore { | 45 namespace WebCore { |
| 45 | 46 |
| 46 class Canvas2DLayerBridge; | |
| 47 class PassCanvas2DLayerBridgePtr; | |
| 48 | |
| 49 class Canvas2DLayerBridgePtr { | |
| 50 public: | |
| 51 Canvas2DLayerBridgePtr() { } | |
| 52 Canvas2DLayerBridgePtr(const PassRefPtr<Canvas2DLayerBridge>& ptr) { m_ptr =
ptr; } | |
| 53 ~Canvas2DLayerBridgePtr() { clear(); } | |
| 54 Canvas2DLayerBridge* operator->() const { return m_ptr.get(); } | |
| 55 Canvas2DLayerBridgePtr& operator=(const PassRefPtr<Canvas2DLayerBridge>&); | |
| 56 Canvas2DLayerBridge* get() const { return m_ptr.get(); } | |
| 57 operator bool () const { return m_ptr; } | |
| 58 void clear(); | |
| 59 PassRefPtr<Canvas2DLayerBridge> release() WARN_UNUSED_RETURN { return m_ptr.
release(); } | |
| 60 private: | |
| 61 RefPtr<Canvas2DLayerBridge> m_ptr; | |
| 62 }; | |
| 63 | |
| 64 class Canvas2DLayerBridge : public blink::WebExternalTextureLayerClient, public
SkDeferredCanvas::NotificationClient, public DoublyLinkedListNode<Canvas2DLayerB
ridge>, public RefCounted<Canvas2DLayerBridge> { | 47 class Canvas2DLayerBridge : public blink::WebExternalTextureLayerClient, public
SkDeferredCanvas::NotificationClient, public DoublyLinkedListNode<Canvas2DLayerB
ridge>, public RefCounted<Canvas2DLayerBridge> { |
| 65 WTF_MAKE_NONCOPYABLE(Canvas2DLayerBridge); | 48 WTF_MAKE_NONCOPYABLE(Canvas2DLayerBridge); |
| 66 public: | 49 public: |
| 67 enum OpacityMode { | 50 static PassRefPtr<Canvas2DLayerBridge> create(const IntSize&, OpacityMode, i
nt msaaSampleCount); |
| 68 Opaque, | |
| 69 NonOpaque | |
| 70 }; | |
| 71 | |
| 72 static PassRefPtr<Canvas2DLayerBridge> create(PassRefPtr<GraphicsContext3D>,
const IntSize&, OpacityMode, int msaaSampleCount); | |
| 73 | |
| 74 virtual ~Canvas2DLayerBridge(); | 51 virtual ~Canvas2DLayerBridge(); |
| 75 | 52 |
| 76 // blink::WebExternalTextureLayerClient implementation. | 53 // blink::WebExternalTextureLayerClient implementation. |
| 77 virtual blink::WebGraphicsContext3D* context() OVERRIDE; | 54 virtual blink::WebGraphicsContext3D* context() OVERRIDE; |
| 78 virtual bool prepareMailbox(blink::WebExternalTextureMailbox*, blink::WebExt
ernalBitmap*) OVERRIDE; | 55 virtual bool prepareMailbox(blink::WebExternalTextureMailbox*, blink::WebExt
ernalBitmap*) OVERRIDE; |
| 79 virtual void mailboxReleased(const blink::WebExternalTextureMailbox&) OVERRI
DE; | 56 virtual void mailboxReleased(const blink::WebExternalTextureMailbox&) OVERRI
DE; |
| 80 | 57 |
| 81 // SkDeferredCanvas::NotificationClient implementation | 58 // SkDeferredCanvas::NotificationClient implementation |
| 82 virtual void prepareForDraw() OVERRIDE; | 59 virtual void prepareForDraw() OVERRIDE; |
| 83 virtual void storageAllocatedForRecordingChanged(size_t) OVERRIDE; | 60 virtual void storageAllocatedForRecordingChanged(size_t) OVERRIDE; |
| 84 virtual void flushedDrawCommands() OVERRIDE; | 61 virtual void flushedDrawCommands() OVERRIDE; |
| 85 virtual void skippedPendingDrawCommands() OVERRIDE; | 62 virtual void skippedPendingDrawCommands() OVERRIDE; |
| 86 | 63 |
| 64 // ImageBufferSurface implementation |
| 65 void aboutToUse(); |
| 66 SkCanvas* canvas() const { return m_canvas.get(); } |
| 67 bool isValid(); |
| 68 blink::WebLayer* layer() const; |
| 69 Platform3DObject getBackingTexture(); |
| 70 bool isAccelerated() const { return true; } |
| 71 |
| 87 // Methods used by Canvas2DLayerManager | 72 // Methods used by Canvas2DLayerManager |
| 88 virtual size_t freeMemoryIfPossible(size_t); // virtual for mocking | 73 virtual size_t freeMemoryIfPossible(size_t); // virtual for mocking |
| 89 virtual void flush(); // virtual for mocking | 74 virtual void flush(); // virtual for mocking |
| 90 virtual size_t storageAllocatedForRecording(); // virtual for faking | 75 virtual size_t storageAllocatedForRecording(); // virtual for faking |
| 91 size_t bytesAllocated() const {return m_bytesAllocated;} | 76 size_t bytesAllocated() const {return m_bytesAllocated;} |
| 92 void limitPendingFrames(); | 77 void limitPendingFrames(); |
| 93 | 78 |
| 94 blink::WebLayer* layer(); | 79 void destroy(); |
| 95 void contextAcquired(); | |
| 96 PassRefPtr<SkCanvas> getCanvas() { return PassRefPtr<SkCanvas>(m_canvas); } | |
| 97 | |
| 98 unsigned backBufferTexture(); | |
| 99 | |
| 100 bool isValid(); | |
| 101 | 80 |
| 102 protected: | 81 protected: |
| 103 void destroy(); | 82 Canvas2DLayerBridge(PassRefPtr<GraphicsContext3D>, PassOwnPtr<SkDeferredCanv
as>, int, OpacityMode); |
| 104 friend class Canvas2DLayerBridgePtr; | |
| 105 Canvas2DLayerBridge(PassRefPtr<GraphicsContext3D>, PassRefPtr<SkDeferredCanv
as>, int, OpacityMode); | |
| 106 void setRateLimitingEnabled(bool); | 83 void setRateLimitingEnabled(bool); |
| 107 | 84 |
| 108 RefPtr<SkDeferredCanvas> m_canvas; | 85 OwnPtr<SkDeferredCanvas> m_canvas; |
| 109 OwnPtr<blink::WebExternalTextureLayer> m_layer; | 86 OwnPtr<blink::WebExternalTextureLayer> m_layer; |
| 110 RefPtr<GraphicsContext3D> m_context; | 87 RefPtr<GraphicsContext3D> m_context; |
| 111 int m_msaaSampleCount; | 88 int m_msaaSampleCount; |
| 112 size_t m_bytesAllocated; | 89 size_t m_bytesAllocated; |
| 113 bool m_didRecordDrawCommand; | 90 bool m_didRecordDrawCommand; |
| 114 bool m_surfaceIsValid; | 91 bool m_surfaceIsValid; |
| 115 int m_framesPending; | 92 int m_framesPending; |
| 116 bool m_destructionInProgress; | 93 bool m_destructionInProgress; |
| 117 bool m_rateLimitingEnabled; | 94 bool m_rateLimitingEnabled; |
| 118 | 95 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 135 MailboxInfo(const MailboxInfo&); | 112 MailboxInfo(const MailboxInfo&); |
| 136 MailboxInfo() {} | 113 MailboxInfo() {} |
| 137 }; | 114 }; |
| 138 MailboxInfo* createMailboxInfo(); | 115 MailboxInfo* createMailboxInfo(); |
| 139 | 116 |
| 140 uint32_t m_lastImageId; | 117 uint32_t m_lastImageId; |
| 141 Vector<MailboxInfo> m_mailboxes; | 118 Vector<MailboxInfo> m_mailboxes; |
| 142 }; | 119 }; |
| 143 } | 120 } |
| 144 #endif | 121 #endif |
| OLD | NEW |