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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 } | 45 } |
46 | 46 |
47 class Canvas2DLayerBridgeTest; | 47 class Canvas2DLayerBridgeTest; |
48 | 48 |
49 namespace WebCore { | 49 namespace WebCore { |
50 | 50 |
51 class PLATFORM_EXPORT Canvas2DLayerBridge : public blink::WebExternalTextureLaye
rClient, public SkDeferredCanvas::NotificationClient, public DoublyLinkedListNod
e<Canvas2DLayerBridge>, public RefCounted<Canvas2DLayerBridge> { | 51 class PLATFORM_EXPORT Canvas2DLayerBridge : public blink::WebExternalTextureLaye
rClient, public SkDeferredCanvas::NotificationClient, public DoublyLinkedListNod
e<Canvas2DLayerBridge>, public RefCounted<Canvas2DLayerBridge> { |
52 WTF_MAKE_NONCOPYABLE(Canvas2DLayerBridge); | 52 WTF_MAKE_NONCOPYABLE(Canvas2DLayerBridge); |
53 public: | 53 public: |
54 static PassRefPtr<Canvas2DLayerBridge> create(const IntSize&, OpacityMode, i
nt msaaSampleCount); | 54 static PassRefPtr<Canvas2DLayerBridge> create(const IntSize&, OpacityMode, i
nt msaaSampleCount); |
| 55 |
55 virtual ~Canvas2DLayerBridge(); | 56 virtual ~Canvas2DLayerBridge(); |
56 | 57 |
57 // blink::WebExternalTextureLayerClient implementation. | 58 // blink::WebExternalTextureLayerClient implementation. |
58 virtual blink::WebGraphicsContext3D* context() OVERRIDE; | 59 virtual blink::WebGraphicsContext3D* context() OVERRIDE; |
59 virtual bool prepareMailbox(blink::WebExternalTextureMailbox*, blink::WebExt
ernalBitmap*) OVERRIDE; | 60 virtual bool prepareMailbox(blink::WebExternalTextureMailbox*, blink::WebExt
ernalBitmap*) OVERRIDE; |
60 virtual void mailboxReleased(const blink::WebExternalTextureMailbox&) OVERRI
DE; | 61 virtual void mailboxReleased(const blink::WebExternalTextureMailbox&) OVERRI
DE; |
61 | 62 |
62 // SkDeferredCanvas::NotificationClient implementation | 63 // SkDeferredCanvas::NotificationClient implementation |
63 virtual void prepareForDraw() OVERRIDE; | 64 virtual void prepareForDraw() OVERRIDE; |
64 virtual void storageAllocatedForRecordingChanged(size_t) OVERRIDE; | 65 virtual void storageAllocatedForRecordingChanged(size_t) OVERRIDE; |
65 virtual void flushedDrawCommands() OVERRIDE; | 66 virtual void flushedDrawCommands() OVERRIDE; |
66 virtual void skippedPendingDrawCommands() OVERRIDE; | 67 virtual void skippedPendingDrawCommands() OVERRIDE; |
67 | 68 |
68 // ImageBufferSurface implementation | 69 // ImageBufferSurface implementation |
69 void willUse(); | 70 void willUse(); |
70 SkCanvas* canvas() const { return m_canvas.get(); } | 71 SkCanvas* canvas() const { return m_canvas.get(); } |
71 bool isValid(); | 72 bool isValid(); |
72 blink::WebLayer* layer() const; | 73 blink::WebLayer* layer() const; |
73 Platform3DObject getBackingTexture(); | 74 Platform3DObject getBackingTexture(); |
74 bool isAccelerated() const { return true; } | 75 bool isAccelerated() const { return true; } |
| 76 void setIsHidden(bool); |
75 | 77 |
76 // Methods used by Canvas2DLayerManager | 78 // Methods used by Canvas2DLayerManager |
77 virtual size_t freeMemoryIfPossible(size_t); // virtual for mocking | 79 virtual size_t freeMemoryIfPossible(size_t); // virtual for mocking |
78 virtual void flush(); // virtual for mocking | 80 virtual void flush(); // virtual for mocking |
79 virtual size_t storageAllocatedForRecording(); // virtual for faking | 81 virtual size_t storageAllocatedForRecording(); // virtual for faking |
80 size_t bytesAllocated() const {return m_bytesAllocated;} | 82 size_t bytesAllocated() const { return m_bytesAllocated; } |
81 void limitPendingFrames(); | 83 void limitPendingFrames(); |
| 84 void freeReleasedMailbox(); |
| 85 bool hasReleasedMailbox() const { return m_releasedMailboxInfo; }; |
| 86 void freeTransientResources(); |
| 87 bool hasTransientResources() const; |
| 88 bool isHidden() { return m_isHidden; } |
82 | 89 |
83 void beginDestruction(); | 90 void beginDestruction(); |
84 | 91 |
85 protected: | 92 protected: |
86 Canvas2DLayerBridge(PassRefPtr<GraphicsContext3D>, PassOwnPtr<SkDeferredCanv
as>, int, OpacityMode); | 93 Canvas2DLayerBridge(PassRefPtr<GraphicsContext3D>, PassOwnPtr<SkDeferredCanv
as>, int, OpacityMode); |
87 void setRateLimitingEnabled(bool); | 94 void setRateLimitingEnabled(bool); |
| 95 bool releasedMailboxHasExpired(); |
88 | 96 |
89 OwnPtr<SkDeferredCanvas> m_canvas; | 97 OwnPtr<SkDeferredCanvas> m_canvas; |
90 OwnPtr<blink::WebExternalTextureLayer> m_layer; | 98 OwnPtr<blink::WebExternalTextureLayer> m_layer; |
91 RefPtr<GraphicsContext3D> m_context; | 99 RefPtr<GraphicsContext3D> m_context; |
92 int m_msaaSampleCount; | 100 int m_msaaSampleCount; |
93 size_t m_bytesAllocated; | 101 size_t m_bytesAllocated; |
94 bool m_didRecordDrawCommand; | 102 bool m_didRecordDrawCommand; |
95 bool m_surfaceIsValid; | 103 bool m_surfaceIsValid; |
96 int m_framesPending; | 104 int m_framesPending; |
| 105 int m_framesSinceMailboxRelease; |
97 bool m_destructionInProgress; | 106 bool m_destructionInProgress; |
98 bool m_rateLimitingEnabled; | 107 bool m_rateLimitingEnabled; |
| 108 bool m_isHidden; |
99 | 109 |
100 friend class WTF::DoublyLinkedListNode<Canvas2DLayerBridge>; | 110 friend class WTF::DoublyLinkedListNode<Canvas2DLayerBridge>; |
101 friend class ::Canvas2DLayerBridgeTest; | 111 friend class ::Canvas2DLayerBridgeTest; |
102 Canvas2DLayerBridge* m_next; | 112 Canvas2DLayerBridge* m_next; |
103 Canvas2DLayerBridge* m_prev; | 113 Canvas2DLayerBridge* m_prev; |
104 | 114 |
105 enum MailboxStatus { | 115 enum MailboxStatus { |
106 MailboxInUse, | 116 MailboxInUse, |
107 MailboxReleased, | 117 MailboxReleased, |
108 MailboxAvailable, | 118 MailboxAvailable, |
109 }; | 119 }; |
110 | 120 |
111 struct MailboxInfo { | 121 struct MailboxInfo { |
112 blink::WebExternalTextureMailbox m_mailbox; | 122 blink::WebExternalTextureMailbox m_mailbox; |
113 SkAutoTUnref<SkImage> m_image; | 123 RefPtr<SkImage> m_image; |
114 MailboxStatus m_status; | 124 MailboxStatus m_status; |
115 RefPtr<Canvas2DLayerBridge> m_parentLayerBridge; | 125 RefPtr<Canvas2DLayerBridge> m_parentLayerBridge; |
116 | 126 |
117 MailboxInfo(const MailboxInfo&); | 127 MailboxInfo(const MailboxInfo&); |
118 MailboxInfo() {} | 128 MailboxInfo() {} |
119 }; | 129 }; |
120 MailboxInfo* createMailboxInfo(); | 130 MailboxInfo* createMailboxInfo(); |
121 | 131 |
122 uint32_t m_lastImageId; | 132 uint32_t m_lastImageId; |
123 Vector<MailboxInfo> m_mailboxes; | 133 Vector<MailboxInfo> m_mailboxes; |
| 134 MailboxInfo* m_releasedMailboxInfo; |
124 }; | 135 }; |
125 } | 136 } |
126 #endif | 137 #endif |
OLD | NEW |