| 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 class PassCanvas2DLayerBridgePtr; | 
|  | 48 | 
|  | 49 class Canvas2DLayerBridgePtr { | 
|  | 50 public: | 
|  | 51     Canvas2DLayerBridgePtr() { } | 
|  | 52     Canvas2DLayerBridgePtr(const PassRefPtr<Canvas2DLayerBridge>& ptr) { m_ptr =
      ptr; } | 
|  | 53     ~Canvas2DLayerBridgePtr() { clear(); } | 
|  | 54     Canvas2DLayerBridge* operator->() const { return m_ptr.get(); } | 
|  | 55     Canvas2DLayerBridgePtr& operator=(const PassRefPtr<Canvas2DLayerBridge>&); | 
|  | 56     Canvas2DLayerBridge* get() const { return m_ptr.get(); } | 
|  | 57     operator bool () const { return m_ptr; } | 
|  | 58     void clear(); | 
|  | 59     PassRefPtr<Canvas2DLayerBridge> release() WARN_UNUSED_RETURN { return m_ptr.
     release(); } | 
|  | 60 private: | 
|  | 61     RefPtr<Canvas2DLayerBridge> m_ptr; | 
|  | 62 }; | 
|  | 63 | 
|  | 64 class Canvas2DLayerBridge : public WebKit::WebExternalTextureLayerClient, public
      SkDeferredCanvas::NotificationClient, public DoublyLinkedListNode<Canvas2DLayer
     Bridge>, public RefCounted<Canvas2DLayerBridge> { | 
| 47     WTF_MAKE_NONCOPYABLE(Canvas2DLayerBridge); | 65     WTF_MAKE_NONCOPYABLE(Canvas2DLayerBridge); | 
| 48 public: | 66 public: | 
| 49     enum OpacityMode { | 67     enum OpacityMode { | 
| 50         Opaque, | 68         Opaque, | 
| 51         NonOpaque | 69         NonOpaque | 
| 52     }; | 70     }; | 
| 53 | 71 | 
| 54     static PassOwnPtr<Canvas2DLayerBridge> create(PassRefPtr<GraphicsContext3D>,
      const IntSize&, OpacityMode); | 72     static PassRefPtr<Canvas2DLayerBridge> create(PassRefPtr<GraphicsContext3D>,
      const IntSize&, OpacityMode); | 
| 55 | 73 | 
| 56     virtual ~Canvas2DLayerBridge(); | 74     virtual ~Canvas2DLayerBridge(); | 
| 57 | 75 | 
| 58     // WebKit::WebExternalTextureLayerClient implementation. | 76     // WebKit::WebExternalTextureLayerClient implementation. | 
| 59     virtual WebKit::WebGraphicsContext3D* context() OVERRIDE; | 77     virtual WebKit::WebGraphicsContext3D* context() OVERRIDE; | 
| 60     virtual bool prepareMailbox(WebKit::WebExternalTextureMailbox*, WebKit::WebE
     xternalBitmap*) OVERRIDE; | 78     virtual bool prepareMailbox(WebKit::WebExternalTextureMailbox*, WebKit::WebE
     xternalBitmap*) OVERRIDE; | 
| 61     virtual void mailboxReleased(const WebKit::WebExternalTextureMailbox&) OVERR
     IDE; | 79     virtual void mailboxReleased(const WebKit::WebExternalTextureMailbox&) OVERR
     IDE; | 
| 62 | 80 | 
| 63     // SkDeferredCanvas::NotificationClient implementation | 81     // SkDeferredCanvas::NotificationClient implementation | 
| 64     virtual void prepareForDraw() OVERRIDE; | 82     virtual void prepareForDraw() OVERRIDE; | 
| (...skipping 10 matching lines...) Expand all  Loading... | 
| 75 | 93 | 
| 76     WebKit::WebLayer* layer(); | 94     WebKit::WebLayer* layer(); | 
| 77     void contextAcquired(); | 95     void contextAcquired(); | 
| 78     SkCanvas* getCanvas() { return m_canvas; } | 96     SkCanvas* getCanvas() { return m_canvas; } | 
| 79 | 97 | 
| 80     unsigned backBufferTexture(); | 98     unsigned backBufferTexture(); | 
| 81 | 99 | 
| 82     bool isValid(); | 100     bool isValid(); | 
| 83 | 101 | 
| 84 protected: | 102 protected: | 
|  | 103     void destroy(); | 
|  | 104     friend class Canvas2DLayerBridgePtr; | 
| 85     Canvas2DLayerBridge(PassRefPtr<GraphicsContext3D>, SkDeferredCanvas*, Opacit
     yMode); | 105     Canvas2DLayerBridge(PassRefPtr<GraphicsContext3D>, SkDeferredCanvas*, Opacit
     yMode); | 
| 86     void setRateLimitingEnabled(bool); | 106     void setRateLimitingEnabled(bool); | 
| 87 | 107 | 
| 88     SkDeferredCanvas* m_canvas; | 108     SkDeferredCanvas* m_canvas; | 
| 89     OwnPtr<WebKit::WebExternalTextureLayer> m_layer; | 109     OwnPtr<WebKit::WebExternalTextureLayer> m_layer; | 
| 90     RefPtr<GraphicsContext3D> m_context; | 110     RefPtr<GraphicsContext3D> m_context; | 
| 91     size_t m_bytesAllocated; | 111     size_t m_bytesAllocated; | 
| 92     bool m_didRecordDrawCommand; | 112     bool m_didRecordDrawCommand; | 
| 93     bool m_surfaceIsValid; | 113     bool m_surfaceIsValid; | 
| 94     int m_framesPending; | 114     int m_framesPending; | 
|  | 115     bool m_destructionInProgress; | 
| 95     bool m_rateLimitingEnabled; | 116     bool m_rateLimitingEnabled; | 
| 96 | 117 | 
| 97     friend class WTF::DoublyLinkedListNode<Canvas2DLayerBridge>; | 118     friend class WTF::DoublyLinkedListNode<Canvas2DLayerBridge>; | 
| 98     Canvas2DLayerBridge* m_next; | 119     Canvas2DLayerBridge* m_next; | 
| 99     Canvas2DLayerBridge* m_prev; | 120     Canvas2DLayerBridge* m_prev; | 
| 100 | 121 | 
| 101     enum MailboxStatus { | 122     enum MailboxStatus { | 
| 102         MailboxInUse, | 123         MailboxInUse, | 
| 103         MailboxReleased, | 124         MailboxReleased, | 
| 104         MailboxAvailable, | 125         MailboxAvailable, | 
| 105     }; | 126     }; | 
| 106 | 127 | 
| 107     struct MailboxInfo { | 128     struct MailboxInfo { | 
| 108         WebKit::WebExternalTextureMailbox m_mailbox; | 129         WebKit::WebExternalTextureMailbox m_mailbox; | 
| 109         SkAutoTUnref<SkImage> m_image; | 130         SkAutoTUnref<SkImage> m_image; | 
| 110         MailboxStatus m_status; | 131         MailboxStatus m_status; | 
|  | 132         RefPtr<Canvas2DLayerBridge> m_parentLayerBridge; | 
| 111 | 133 | 
| 112         MailboxInfo(const MailboxInfo&); | 134         MailboxInfo(const MailboxInfo&); | 
| 113         MailboxInfo() {} | 135         MailboxInfo() {} | 
| 114     }; | 136     }; | 
| 115     MailboxInfo* createMailboxInfo(); | 137     MailboxInfo* createMailboxInfo(); | 
| 116 | 138 | 
| 117     uint32_t m_lastImageId; | 139     uint32_t m_lastImageId; | 
| 118     Vector<MailboxInfo> m_mailboxes; | 140     Vector<MailboxInfo> m_mailboxes; | 
| 119 }; | 141 }; | 
| 120 |  | 
| 121 } | 142 } | 
| 122 |  | 
| 123 #endif | 143 #endif | 
| OLD | NEW | 
|---|