Chromium Code Reviews| 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 25 matching lines...) Expand all Loading... | |
| 36 #include "wtf/DoublyLinkedList.h" | 36 #include "wtf/DoublyLinkedList.h" |
| 37 #include "wtf/PassOwnPtr.h" | 37 #include "wtf/PassOwnPtr.h" |
| 38 #include "wtf/RefPtr.h" | 38 #include "wtf/RefPtr.h" |
| 39 | 39 |
| 40 namespace WebKit { | 40 namespace WebKit { |
| 41 class WebGraphicsContext3D; | 41 class WebGraphicsContext3D; |
| 42 } | 42 } |
| 43 | 43 |
| 44 namespace WebCore { | 44 namespace WebCore { |
| 45 | 45 |
| 46 class Canvas2DLayerBridge : public WebKit::WebExternalTextureLayerClient, public SkDeferredCanvas::NotificationClient, public DoublyLinkedListNode<Canvas2DLayer Bridge> { | 46 class Canvas2DLayerBridge; |
| 47 | |
| 48 class Canvas2DLayerBridgePtr { | |
| 49 public: | |
| 50 Canvas2DLayerBridgePtr() { } | |
| 51 Canvas2DLayerBridgePtr(PassRefPtr<Canvas2DLayerBridge> ptr) { m_ptr = ptr; } | |
| 52 Canvas2DLayerBridgePtr(const Canvas2DLayerBridgePtr&); | |
| 53 ~Canvas2DLayerBridgePtr() { clear(); } | |
| 54 Canvas2DLayerBridge* operator->() const { return m_ptr.get(); } | |
| 55 Canvas2DLayerBridgePtr& operator=(const Canvas2DLayerBridgePtr&); | |
| 56 Canvas2DLayerBridge* get() const { return m_ptr.get(); } | |
| 57 operator bool () const { return m_ptr; } | |
| 58 void clear(); | |
|
Stephen White
2013/08/23 14:45:28
Nit: looks like this function is only called from
| |
| 59 private: | |
| 60 RefPtr<Canvas2DLayerBridge> m_ptr; | |
| 61 }; | |
| 62 | |
| 63 class Canvas2DLayerBridge : public WebKit::WebExternalTextureLayerClient, public SkDeferredCanvas::NotificationClient, public DoublyLinkedListNode<Canvas2DLayer Bridge>, public RefCounted<Canvas2DLayerBridge> { | |
| 47 WTF_MAKE_NONCOPYABLE(Canvas2DLayerBridge); | 64 WTF_MAKE_NONCOPYABLE(Canvas2DLayerBridge); |
| 48 public: | 65 public: |
| 49 enum OpacityMode { | 66 enum OpacityMode { |
| 50 Opaque, | 67 Opaque, |
| 51 NonOpaque | 68 NonOpaque |
| 52 }; | 69 }; |
| 53 | 70 |
| 54 static PassOwnPtr<Canvas2DLayerBridge> create(PassRefPtr<GraphicsContext3D>, const IntSize&, OpacityMode); | 71 static Canvas2DLayerBridgePtr create(PassRefPtr<GraphicsContext3D>, const In tSize&, OpacityMode); |
| 55 | 72 |
| 56 virtual ~Canvas2DLayerBridge(); | 73 virtual ~Canvas2DLayerBridge(); |
| 57 | 74 |
| 58 // WebKit::WebExternalTextureLayerClient implementation. | 75 // WebKit::WebExternalTextureLayerClient implementation. |
| 59 virtual WebKit::WebGraphicsContext3D* context() OVERRIDE; | 76 virtual WebKit::WebGraphicsContext3D* context() OVERRIDE; |
| 60 virtual bool prepareMailbox(WebKit::WebExternalTextureMailbox*, WebKit::WebE xternalBitmap*) OVERRIDE; | 77 virtual bool prepareMailbox(WebKit::WebExternalTextureMailbox*, WebKit::WebE xternalBitmap*) OVERRIDE; |
| 61 virtual void mailboxReleased(const WebKit::WebExternalTextureMailbox&) OVERR IDE; | 78 virtual void mailboxReleased(const WebKit::WebExternalTextureMailbox&) OVERR IDE; |
| 62 | 79 |
| 63 // SkDeferredCanvas::NotificationClient implementation | 80 // SkDeferredCanvas::NotificationClient implementation |
| 64 virtual void prepareForDraw() OVERRIDE; | 81 virtual void prepareForDraw() OVERRIDE; |
| 65 virtual void storageAllocatedForRecordingChanged(size_t) OVERRIDE; | 82 virtual void storageAllocatedForRecordingChanged(size_t) OVERRIDE; |
| 66 virtual void flushedDrawCommands() OVERRIDE; | 83 virtual void flushedDrawCommands() OVERRIDE; |
| 67 virtual void skippedPendingDrawCommands() OVERRIDE; | 84 virtual void skippedPendingDrawCommands() OVERRIDE; |
| 68 | 85 |
| 69 // Methods used by Canvas2DLayerManager | 86 // Methods used by Canvas2DLayerManager |
| 70 virtual size_t freeMemoryIfPossible(size_t); // virtual for mocking | 87 virtual size_t freeMemoryIfPossible(size_t); // virtual for mocking |
| 71 virtual void flush(); // virtual for mocking | 88 virtual void flush(); // virtual for mocking |
| 72 virtual size_t storageAllocatedForRecording(); // virtual for faking | 89 virtual size_t storageAllocatedForRecording(); // virtual for faking |
| 73 size_t bytesAllocated() const {return m_bytesAllocated;} | 90 size_t bytesAllocated() const {return m_bytesAllocated;} |
| 74 void limitPendingFrames(); | 91 void limitPendingFrames(); |
| 75 | 92 |
| 76 WebKit::WebLayer* layer(); | 93 WebKit::WebLayer* layer(); |
| 77 void contextAcquired(); | 94 void contextAcquired(); |
| 78 SkCanvas* getCanvas() { return m_canvas; } | 95 SkCanvas* getCanvas() { return m_canvas; } |
| 79 | 96 |
| 80 unsigned backBufferTexture(); | 97 unsigned backBufferTexture(); |
| 81 | 98 |
| 82 bool isValid(); | 99 bool isValid(); |
| 83 | 100 |
| 101 // Non-virtual overload of RefCounted::deref. RefPtr calls this one. | |
|
Stephen White
2013/08/23 14:45:28
Nit: stale comment?
| |
| 102 void destroy(); | |
| 103 | |
| 84 protected: | 104 protected: |
| 85 Canvas2DLayerBridge(PassRefPtr<GraphicsContext3D>, SkDeferredCanvas*, Opacit yMode); | 105 Canvas2DLayerBridge(PassRefPtr<GraphicsContext3D>, SkDeferredCanvas*, Opacit yMode); |
| 86 void setRateLimitingEnabled(bool); | 106 void setRateLimitingEnabled(bool); |
| 107 bool isDead(); | |
|
Stephen White
2013/08/23 14:45:28
This doesn't seem to be defined anywhere.
| |
| 87 | 108 |
| 88 SkDeferredCanvas* m_canvas; | 109 SkDeferredCanvas* m_canvas; |
| 89 OwnPtr<WebKit::WebExternalTextureLayer> m_layer; | 110 OwnPtr<WebKit::WebExternalTextureLayer> m_layer; |
| 90 RefPtr<GraphicsContext3D> m_context; | 111 RefPtr<GraphicsContext3D> m_context; |
| 91 size_t m_bytesAllocated; | 112 size_t m_bytesAllocated; |
| 92 bool m_didRecordDrawCommand; | 113 bool m_didRecordDrawCommand; |
| 93 bool m_surfaceIsValid; | 114 bool m_surfaceIsValid; |
| 94 int m_framesPending; | 115 int m_framesPending; |
| 116 int m_liveMailboxCount; | |
| 117 bool m_destructionInProgress; | |
| 95 bool m_rateLimitingEnabled; | 118 bool m_rateLimitingEnabled; |
| 96 | 119 |
| 97 friend class WTF::DoublyLinkedListNode<Canvas2DLayerBridge>; | 120 friend class WTF::DoublyLinkedListNode<Canvas2DLayerBridge>; |
| 98 Canvas2DLayerBridge* m_next; | 121 Canvas2DLayerBridge* m_next; |
| 99 Canvas2DLayerBridge* m_prev; | 122 Canvas2DLayerBridge* m_prev; |
| 100 | 123 |
| 101 enum MailboxStatus { | 124 enum MailboxStatus { |
| 102 MailboxInUse, | 125 MailboxInUse, |
| 103 MailboxReleased, | 126 MailboxReleased, |
| 104 MailboxAvailable, | 127 MailboxAvailable, |
| 105 }; | 128 }; |
| 106 | 129 |
| 107 struct MailboxInfo { | 130 struct MailboxInfo { |
| 108 WebKit::WebExternalTextureMailbox m_mailbox; | 131 WebKit::WebExternalTextureMailbox m_mailbox; |
| 109 SkAutoTUnref<SkImage> m_image; | 132 SkAutoTUnref<SkImage> m_image; |
| 110 MailboxStatus m_status; | 133 MailboxStatus m_status; |
| 134 RefPtr<Canvas2DLayerBridge> m_parentLayerBridge; | |
| 111 | 135 |
| 112 MailboxInfo(const MailboxInfo&); | 136 MailboxInfo(const MailboxInfo&); |
| 113 MailboxInfo() {} | 137 MailboxInfo() {} |
| 114 }; | 138 }; |
| 115 MailboxInfo* createMailboxInfo(); | 139 MailboxInfo* createMailboxInfo(); |
| 116 | 140 |
| 117 uint32_t m_lastImageId; | 141 uint32_t m_lastImageId; |
| 118 Vector<MailboxInfo> m_mailboxes; | 142 Vector<MailboxInfo> m_mailboxes; |
| 119 }; | 143 }; |
| 120 | |
| 121 } | 144 } |
| 122 | |
| 123 #endif | 145 #endif |
| OLD | NEW |