| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 namespace WebCore { | 44 namespace WebCore { |
| 45 | 45 |
| 46 class Canvas2DLayerBridge : public WebKit::WebExternalTextureLayerClient, public
SkDeferredCanvas::NotificationClient, public DoublyLinkedListNode<Canvas2DLayer
Bridge> { | 46 class Canvas2DLayerBridge : public WebKit::WebExternalTextureLayerClient, public
SkDeferredCanvas::NotificationClient, public DoublyLinkedListNode<Canvas2DLayer
Bridge> { |
| 47 WTF_MAKE_NONCOPYABLE(Canvas2DLayerBridge); | 47 WTF_MAKE_NONCOPYABLE(Canvas2DLayerBridge); |
| 48 public: | 48 public: |
| 49 enum OpacityMode { | 49 enum OpacityMode { |
| 50 Opaque, | 50 Opaque, |
| 51 NonOpaque | 51 NonOpaque |
| 52 }; | 52 }; |
| 53 | 53 |
| 54 static PassOwnPtr<Canvas2DLayerBridge> create(PassRefPtr<GraphicsContext3D>,
const IntSize&, OpacityMode); | 54 class Helper { |
| 55 public: |
| 56 virtual PassRefPtr<GraphicsContext3D> getContext() = 0; |
| 57 virtual SkSurface* createSurface(GraphicsContext3D*, const IntSize&) = 0
; |
| 58 }; |
| 59 |
| 60 static PassOwnPtr<Canvas2DLayerBridge> create(PassOwnPtr<Helper>, const IntS
ize&, OpacityMode); |
| 55 | 61 |
| 56 virtual ~Canvas2DLayerBridge(); | 62 virtual ~Canvas2DLayerBridge(); |
| 57 | 63 |
| 58 // WebKit::WebExternalTextureLayerClient implementation. | 64 // WebKit::WebExternalTextureLayerClient implementation. |
| 59 virtual WebKit::WebGraphicsContext3D* context() OVERRIDE; | 65 virtual WebKit::WebGraphicsContext3D* context() OVERRIDE; |
| 60 virtual bool prepareMailbox(WebKit::WebExternalTextureMailbox*, WebKit::WebE
xternalBitmap*) OVERRIDE; | 66 virtual bool prepareMailbox(WebKit::WebExternalTextureMailbox*, WebKit::WebE
xternalBitmap*) OVERRIDE; |
| 61 virtual void mailboxReleased(const WebKit::WebExternalTextureMailbox&) OVERR
IDE; | 67 virtual void mailboxReleased(const WebKit::WebExternalTextureMailbox&) OVERR
IDE; |
| 62 | 68 |
| 63 // SkDeferredCanvas::NotificationClient implementation | 69 // SkDeferredCanvas::NotificationClient implementation |
| 64 virtual void prepareForDraw() OVERRIDE; | 70 virtual void prepareForDraw() OVERRIDE; |
| 65 virtual void storageAllocatedForRecordingChanged(size_t) OVERRIDE; | 71 virtual void storageAllocatedForRecordingChanged(size_t) OVERRIDE; |
| 66 virtual void flushedDrawCommands() OVERRIDE; | 72 virtual void flushedDrawCommands() OVERRIDE; |
| 67 virtual void skippedPendingDrawCommands() OVERRIDE; | 73 virtual void skippedPendingDrawCommands() OVERRIDE; |
| 68 | 74 |
| 69 // Methods used by Canvas2DLayerManager | 75 // Methods used by Canvas2DLayerManager |
| 70 virtual size_t freeMemoryIfPossible(size_t); // virtual for mocking | 76 virtual size_t freeMemoryIfPossible(size_t); // virtual for mocking |
| 71 virtual void flush(); // virtual for mocking | 77 virtual void flush(); // virtual for mocking |
| 72 virtual size_t storageAllocatedForRecording(); // virtual for faking | 78 virtual size_t storageAllocatedForRecording(); // virtual for faking |
| 73 size_t bytesAllocated() const {return m_bytesAllocated;} | 79 size_t bytesAllocated() const {return m_bytesAllocated;} |
| 74 void limitPendingFrames(); | 80 void limitPendingFrames(); |
| 75 | 81 |
| 76 WebKit::WebLayer* layer(); | 82 WebKit::WebLayer* layer(); |
| 77 void contextAcquired(); | 83 void contextAcquired(); |
| 78 SkCanvas* getCanvas() { return m_canvas; } | 84 SkCanvas* getCanvas() { return m_canvas; } |
| 85 Helper* helper() { return m_helper.get(); } |
| 79 | 86 |
| 80 unsigned backBufferTexture(); | 87 unsigned backBufferTexture(); |
| 81 | 88 |
| 82 bool isValid(); | 89 bool isValid(); |
| 83 | 90 |
| 84 protected: | 91 protected: |
| 85 Canvas2DLayerBridge(PassRefPtr<GraphicsContext3D>, SkDeferredCanvas*, Opacit
yMode); | 92 Canvas2DLayerBridge(PassOwnPtr<Helper>, const IntSize&, OpacityMode, bool* s
uccess); |
| 93 |
| 86 void setRateLimitingEnabled(bool); | 94 void setRateLimitingEnabled(bool); |
| 87 | 95 |
| 88 SkDeferredCanvas* m_canvas; | 96 SkDeferredCanvas* m_canvas; |
| 89 OwnPtr<WebKit::WebExternalTextureLayer> m_layer; | 97 OwnPtr<WebKit::WebExternalTextureLayer> m_layer; |
| 90 RefPtr<GraphicsContext3D> m_context; | 98 RefPtr<GraphicsContext3D> m_context; |
| 99 OwnPtr<Helper> m_helper; |
| 91 size_t m_bytesAllocated; | 100 size_t m_bytesAllocated; |
| 92 bool m_didRecordDrawCommand; | 101 bool m_didRecordDrawCommand; |
| 93 bool m_surfaceIsValid; | 102 bool m_surfaceIsValid; |
| 94 int m_framesPending; | 103 int m_framesPending; |
| 95 bool m_rateLimitingEnabled; | 104 bool m_rateLimitingEnabled; |
| 105 bool m_contentsDrawable; |
| 96 | 106 |
| 97 friend class WTF::DoublyLinkedListNode<Canvas2DLayerBridge>; | 107 friend class WTF::DoublyLinkedListNode<Canvas2DLayerBridge>; |
| 98 Canvas2DLayerBridge* m_next; | 108 Canvas2DLayerBridge* m_next; |
| 99 Canvas2DLayerBridge* m_prev; | 109 Canvas2DLayerBridge* m_prev; |
| 100 | 110 |
| 101 enum MailboxStatus { | 111 enum MailboxStatus { |
| 102 MailboxInUse, | 112 MailboxInUse, |
| 103 MailboxReleased, | 113 MailboxReleased, |
| 104 MailboxAvailable, | 114 MailboxAvailable, |
| 105 }; | 115 }; |
| 106 | 116 |
| 107 struct MailboxInfo { | 117 struct MailboxInfo { |
| 108 WebKit::WebExternalTextureMailbox m_mailbox; | 118 WebKit::WebExternalTextureMailbox m_mailbox; |
| 109 SkAutoTUnref<SkImage> m_image; | 119 SkAutoTUnref<SkImage> m_image; |
| 110 MailboxStatus m_status; | 120 MailboxStatus m_status; |
| 111 | 121 |
| 112 MailboxInfo(const MailboxInfo&); | 122 MailboxInfo(const MailboxInfo&); |
| 113 MailboxInfo() {} | 123 MailboxInfo() {} |
| 114 }; | 124 }; |
| 115 MailboxInfo* createMailboxInfo(); | 125 MailboxInfo* createMailboxInfo(); |
| 116 | 126 |
| 117 uint32_t m_lastImageId; | 127 uint32_t m_lastImageId; |
| 118 Vector<MailboxInfo> m_mailboxes; | 128 Vector<MailboxInfo> m_mailboxes; |
| 119 }; | 129 }; |
| 120 | 130 |
| 121 } | 131 } |
| 122 | 132 |
| 123 #endif | 133 #endif |
| OLD | NEW |