| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 | 42 |
| 43 namespace blink { | 43 namespace blink { |
| 44 class WebGraphicsContext3D; | 44 class WebGraphicsContext3D; |
| 45 class WebGraphicsContext3DProvider; | 45 class WebGraphicsContext3DProvider; |
| 46 } | 46 } |
| 47 | 47 |
| 48 class Canvas2DLayerBridgeTest; | 48 class Canvas2DLayerBridgeTest; |
| 49 | 49 |
| 50 namespace WebCore { | 50 namespace WebCore { |
| 51 | 51 |
| 52 class ImageBuffer; |
| 53 |
| 52 class PLATFORM_EXPORT Canvas2DLayerBridge : public blink::WebExternalTextureLaye
rClient, public SkDeferredCanvas::NotificationClient, public DoublyLinkedListNod
e<Canvas2DLayerBridge>, public RefCounted<Canvas2DLayerBridge> { | 54 class PLATFORM_EXPORT Canvas2DLayerBridge : public blink::WebExternalTextureLaye
rClient, public SkDeferredCanvas::NotificationClient, public DoublyLinkedListNod
e<Canvas2DLayerBridge>, public RefCounted<Canvas2DLayerBridge> { |
| 53 WTF_MAKE_NONCOPYABLE(Canvas2DLayerBridge); | 55 WTF_MAKE_NONCOPYABLE(Canvas2DLayerBridge); |
| 54 public: | 56 public: |
| 55 static PassRefPtr<Canvas2DLayerBridge> create(const IntSize&, OpacityMode, i
nt msaaSampleCount); | 57 static PassRefPtr<Canvas2DLayerBridge> create(const IntSize&, OpacityMode, i
nt msaaSampleCount); |
| 56 | 58 |
| 57 virtual ~Canvas2DLayerBridge(); | 59 virtual ~Canvas2DLayerBridge(); |
| 58 | 60 |
| 59 // blink::WebExternalTextureLayerClient implementation. | 61 // blink::WebExternalTextureLayerClient implementation. |
| 60 virtual blink::WebGraphicsContext3D* context() OVERRIDE; | 62 virtual blink::WebGraphicsContext3D* context() OVERRIDE; |
| 61 virtual bool prepareMailbox(blink::WebExternalTextureMailbox*, blink::WebExt
ernalBitmap*) OVERRIDE; | 63 virtual bool prepareMailbox(blink::WebExternalTextureMailbox*, blink::WebExt
ernalBitmap*) OVERRIDE; |
| 62 virtual void mailboxReleased(const blink::WebExternalTextureMailbox&) OVERRI
DE; | 64 virtual void mailboxReleased(const blink::WebExternalTextureMailbox&) OVERRI
DE; |
| 63 | 65 |
| 64 // SkDeferredCanvas::NotificationClient implementation | 66 // SkDeferredCanvas::NotificationClient implementation |
| 65 virtual void prepareForDraw() OVERRIDE; | 67 virtual void prepareForDraw() OVERRIDE; |
| 66 virtual void storageAllocatedForRecordingChanged(size_t) OVERRIDE; | 68 virtual void storageAllocatedForRecordingChanged(size_t) OVERRIDE; |
| 67 virtual void flushedDrawCommands() OVERRIDE; | 69 virtual void flushedDrawCommands() OVERRIDE; |
| 68 virtual void skippedPendingDrawCommands() OVERRIDE; | 70 virtual void skippedPendingDrawCommands() OVERRIDE; |
| 69 | 71 |
| 70 // ImageBufferSurface implementation | 72 // ImageBufferSurface implementation |
| 71 void willUse(); | 73 void willUse(); |
| 72 SkCanvas* canvas() const { return m_canvas.get(); } | 74 SkCanvas* canvas() const { return m_canvas.get(); } |
| 73 bool surfaceIsValid(); | 75 bool isSurfaceValid(); |
| 74 bool recoverSurface(); | 76 bool restoreSurface(); |
| 75 blink::WebLayer* layer() const; | 77 blink::WebLayer* layer() const; |
| 76 Platform3DObject getBackingTexture(); | 78 Platform3DObject getBackingTexture(); |
| 77 bool isAccelerated() const { return true; } | 79 bool isAccelerated() const { return true; } |
| 78 void setIsHidden(bool); | 80 void setIsHidden(bool); |
| 81 void setImageBuffer(ImageBuffer* imageBuffer) { m_imageBuffer = imageBuffer;
} |
| 79 | 82 |
| 80 // Methods used by Canvas2DLayerManager | 83 // Methods used by Canvas2DLayerManager |
| 81 virtual size_t freeMemoryIfPossible(size_t); // virtual for mocking | 84 virtual size_t freeMemoryIfPossible(size_t); // virtual for mocking |
| 82 virtual void flush(); // virtual for mocking | 85 virtual void flush(); // virtual for mocking |
| 83 virtual size_t storageAllocatedForRecording(); // virtual for faking | 86 virtual size_t storageAllocatedForRecording(); // virtual for faking |
| 84 size_t bytesAllocated() const { return m_bytesAllocated; } | 87 size_t bytesAllocated() const { return m_bytesAllocated; } |
| 85 void limitPendingFrames(); | 88 void limitPendingFrames(); |
| 86 void freeReleasedMailbox(); | 89 void freeReleasedMailbox(); |
| 87 bool hasReleasedMailbox() const; | 90 bool hasReleasedMailbox() const; |
| 88 void freeTransientResources(); | 91 void freeTransientResources(); |
| 89 bool hasTransientResources() const; | 92 bool hasTransientResources() const; |
| 90 bool isHidden() { return m_isHidden; } | 93 bool isHidden() { return m_isHidden; } |
| 91 | 94 |
| 92 void beginDestruction(); | 95 void beginDestruction(); |
| 93 | 96 |
| 94 protected: | 97 protected: |
| 95 Canvas2DLayerBridge(PassOwnPtr<blink::WebGraphicsContext3DProvider>, PassOwn
Ptr<SkDeferredCanvas>, int, OpacityMode); | 98 Canvas2DLayerBridge(PassOwnPtr<blink::WebGraphicsContext3DProvider>, PassOwn
Ptr<SkDeferredCanvas>, int, OpacityMode); |
| 96 void setRateLimitingEnabled(bool); | 99 void setRateLimitingEnabled(bool); |
| 97 bool releasedMailboxHasExpired(); | 100 bool releasedMailboxHasExpired(); |
| 98 | 101 |
| 99 OwnPtr<SkDeferredCanvas> m_canvas; | 102 OwnPtr<SkDeferredCanvas> m_canvas; |
| 100 OwnPtr<blink::WebExternalTextureLayer> m_layer; | 103 OwnPtr<blink::WebExternalTextureLayer> m_layer; |
| 101 OwnPtr<blink::WebGraphicsContext3DProvider> m_contextProvider; | 104 OwnPtr<blink::WebGraphicsContext3DProvider> m_contextProvider; |
| 105 ImageBuffer* m_imageBuffer; |
| 102 int m_msaaSampleCount; | 106 int m_msaaSampleCount; |
| 103 size_t m_bytesAllocated; | 107 size_t m_bytesAllocated; |
| 104 bool m_didRecordDrawCommand; | 108 bool m_didRecordDrawCommand; |
| 105 bool m_surfaceIsValid; | 109 bool m_isSurfaceValid; |
| 106 int m_framesPending; | 110 int m_framesPending; |
| 107 int m_framesSinceMailboxRelease; | 111 int m_framesSinceMailboxRelease; |
| 108 bool m_destructionInProgress; | 112 bool m_destructionInProgress; |
| 109 bool m_rateLimitingEnabled; | 113 bool m_rateLimitingEnabled; |
| 110 bool m_isHidden; | 114 bool m_isHidden; |
| 111 | 115 |
| 112 friend class WTF::DoublyLinkedListNode<Canvas2DLayerBridge>; | 116 friend class WTF::DoublyLinkedListNode<Canvas2DLayerBridge>; |
| 113 friend class ::Canvas2DLayerBridgeTest; | 117 friend class ::Canvas2DLayerBridgeTest; |
| 114 Canvas2DLayerBridge* m_next; | 118 Canvas2DLayerBridge* m_next; |
| 115 Canvas2DLayerBridge* m_prev; | 119 Canvas2DLayerBridge* m_prev; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 131 }; | 135 }; |
| 132 MailboxInfo* createMailboxInfo(); | 136 MailboxInfo* createMailboxInfo(); |
| 133 MailboxInfo* releasedMailboxInfo(); | 137 MailboxInfo* releasedMailboxInfo(); |
| 134 | 138 |
| 135 uint32_t m_lastImageId; | 139 uint32_t m_lastImageId; |
| 136 Vector<MailboxInfo> m_mailboxes; | 140 Vector<MailboxInfo> m_mailboxes; |
| 137 int m_releasedMailboxInfoIndex; | 141 int m_releasedMailboxInfoIndex; |
| 138 }; | 142 }; |
| 139 } | 143 } |
| 140 #endif | 144 #endif |
| OLD | NEW |