| 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>
context, SkDeferredCanvas* canvas, OpacityMode opacityMode) | 54 static PassOwnPtr<Canvas2DLayerBridge> create(PassRefPtr<GraphicsContext3D>,
const IntSize&, OpacityMode); |
| 55 { | |
| 56 return adoptPtr(new Canvas2DLayerBridge(context, canvas, opacityMode)); | |
| 57 } | |
| 58 | 55 |
| 59 virtual ~Canvas2DLayerBridge(); | 56 virtual ~Canvas2DLayerBridge(); |
| 60 | 57 |
| 61 // WebKit::WebExternalTextureLayerClient implementation. | 58 // WebKit::WebExternalTextureLayerClient implementation. |
| 62 virtual WebKit::WebGraphicsContext3D* context() OVERRIDE; | 59 virtual WebKit::WebGraphicsContext3D* context() OVERRIDE; |
| 63 virtual bool prepareMailbox(WebKit::WebExternalTextureMailbox*, WebKit::WebE
xternalBitmap*) OVERRIDE; | 60 virtual bool prepareMailbox(WebKit::WebExternalTextureMailbox*, WebKit::WebE
xternalBitmap*) OVERRIDE; |
| 64 virtual void mailboxReleased(const WebKit::WebExternalTextureMailbox&) OVERR
IDE; | 61 virtual void mailboxReleased(const WebKit::WebExternalTextureMailbox&) OVERR
IDE; |
| 65 | 62 |
| 66 // SkDeferredCanvas::NotificationClient implementation | 63 // SkDeferredCanvas::NotificationClient implementation |
| 67 virtual void prepareForDraw() OVERRIDE; | 64 virtual void prepareForDraw() OVERRIDE; |
| 68 virtual void storageAllocatedForRecordingChanged(size_t) OVERRIDE; | 65 virtual void storageAllocatedForRecordingChanged(size_t) OVERRIDE; |
| 69 virtual void flushedDrawCommands() OVERRIDE; | 66 virtual void flushedDrawCommands() OVERRIDE; |
| 70 virtual void skippedPendingDrawCommands() OVERRIDE; | 67 virtual void skippedPendingDrawCommands() OVERRIDE; |
| 71 | 68 |
| 72 // Methods used by Canvas2DLayerManager | 69 // Methods used by Canvas2DLayerManager |
| 73 virtual size_t freeMemoryIfPossible(size_t); // virtual for mocking | 70 virtual size_t freeMemoryIfPossible(size_t); // virtual for mocking |
| 74 virtual void flush(); // virtual for mocking | 71 virtual void flush(); // virtual for mocking |
| 75 virtual size_t storageAllocatedForRecording(); // virtual for faking | 72 virtual size_t storageAllocatedForRecording(); // virtual for faking |
| 76 size_t bytesAllocated() const {return m_bytesAllocated;} | 73 size_t bytesAllocated() const {return m_bytesAllocated;} |
| 77 void limitPendingFrames(); | 74 void limitPendingFrames(); |
| 78 | 75 |
| 79 WebKit::WebLayer* layer(); | 76 WebKit::WebLayer* layer(); |
| 80 void contextAcquired(); | 77 void contextAcquired(); |
| 78 SkCanvas* getCanvas() { return m_canvas; } |
| 81 | 79 |
| 82 unsigned backBufferTexture(); | 80 unsigned backBufferTexture(); |
| 83 | 81 |
| 82 bool isValid(); |
| 83 |
| 84 protected: | 84 protected: |
| 85 Canvas2DLayerBridge(PassRefPtr<GraphicsContext3D>, SkDeferredCanvas*, Opacit
yMode); | 85 Canvas2DLayerBridge(PassRefPtr<GraphicsContext3D>, SkDeferredCanvas*, Opacit
yMode); |
| 86 void setRateLimitingEnabled(bool); | 86 void setRateLimitingEnabled(bool); |
| 87 | 87 |
| 88 SkDeferredCanvas* m_canvas; | 88 SkDeferredCanvas* m_canvas; |
| 89 OwnPtr<WebKit::WebExternalTextureLayer> m_layer; | 89 OwnPtr<WebKit::WebExternalTextureLayer> m_layer; |
| 90 RefPtr<GraphicsContext3D> m_context; | 90 RefPtr<GraphicsContext3D> m_context; |
| 91 size_t m_bytesAllocated; | 91 size_t m_bytesAllocated; |
| 92 bool m_didRecordDrawCommand; | 92 bool m_didRecordDrawCommand; |
| 93 bool m_surfaceIsValid; |
| 93 int m_framesPending; | 94 int m_framesPending; |
| 94 bool m_rateLimitingEnabled; | 95 bool m_rateLimitingEnabled; |
| 95 | 96 |
| 96 friend class WTF::DoublyLinkedListNode<Canvas2DLayerBridge>; | 97 friend class WTF::DoublyLinkedListNode<Canvas2DLayerBridge>; |
| 97 Canvas2DLayerBridge* m_next; | 98 Canvas2DLayerBridge* m_next; |
| 98 Canvas2DLayerBridge* m_prev; | 99 Canvas2DLayerBridge* m_prev; |
| 99 | 100 |
| 100 enum MailboxStatus { | 101 enum MailboxStatus { |
| 101 MailboxInUse, | 102 MailboxInUse, |
| 102 MailboxReleased, | 103 MailboxReleased, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 113 }; | 114 }; |
| 114 MailboxInfo* createMailboxInfo(); | 115 MailboxInfo* createMailboxInfo(); |
| 115 | 116 |
| 116 uint32_t m_lastImageId; | 117 uint32_t m_lastImageId; |
| 117 Vector<MailboxInfo> m_mailboxes; | 118 Vector<MailboxInfo> m_mailboxes; |
| 118 }; | 119 }; |
| 119 | 120 |
| 120 } | 121 } |
| 121 | 122 |
| 122 #endif | 123 #endif |
| OLD | NEW |