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 19 matching lines...) Expand all Loading... | |
| 30 #include "SkImage.h" | 30 #include "SkImage.h" |
| 31 #include "core/platform/graphics/GraphicsContext3D.h" | 31 #include "core/platform/graphics/GraphicsContext3D.h" |
| 32 #include "core/platform/graphics/IntSize.h" | 32 #include "core/platform/graphics/IntSize.h" |
| 33 #include <public/WebExternalTextureLayer.h> | 33 #include <public/WebExternalTextureLayer.h> |
| 34 #include <public/WebExternalTextureLayerClient.h> | 34 #include <public/WebExternalTextureLayerClient.h> |
| 35 #include <public/WebExternalTextureMailbox.h> | 35 #include <public/WebExternalTextureMailbox.h> |
| 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 class Canvas2DLayerBridgeTest; | |
| 41 | |
| 40 namespace WebKit { | 42 namespace WebKit { |
| 41 class WebGraphicsContext3D; | 43 class WebGraphicsContext3D; |
| 42 } | 44 } |
| 43 | 45 |
| 44 namespace WebCore { | 46 namespace WebCore { |
| 45 | 47 |
| 46 class Canvas2DLayerBridge : public WebKit::WebExternalTextureLayerClient, public SkDeferredCanvas::NotificationClient, public DoublyLinkedListNode<Canvas2DLayer Bridge> { | 48 class Canvas2DLayerBridge : public WebKit::WebExternalTextureLayerClient, public SkDeferredCanvas::NotificationClient, public DoublyLinkedListNode<Canvas2DLayer Bridge> { |
| 47 WTF_MAKE_NONCOPYABLE(Canvas2DLayerBridge); | 49 WTF_MAKE_NONCOPYABLE(Canvas2DLayerBridge); |
| 48 public: | 50 public: |
| 49 enum OpacityMode { | 51 enum OpacityMode { |
| 50 Opaque, | 52 Opaque, |
| 51 NonOpaque | 53 NonOpaque |
| 52 }; | 54 }; |
| 53 | 55 |
| 54 enum ThreadMode { | 56 enum ThreadMode { |
| 55 SingleThread, | 57 SingleThread, |
| 56 Threaded | 58 Threaded |
| 57 }; | 59 }; |
| 58 | 60 |
| 59 static PassOwnPtr<Canvas2DLayerBridge> create(PassRefPtr<GraphicsContext3D> context, SkDeferredCanvas* canvas, OpacityMode opacityMode, ThreadMode threading ) | 61 static PassOwnPtr<Canvas2DLayerBridge> create(PassRefPtr<GraphicsContext3D>, const IntSize&, OpacityMode, ThreadMode); |
| 60 { | |
| 61 return adoptPtr(new Canvas2DLayerBridge(context, canvas, opacityMode, th reading)); | |
| 62 } | |
| 63 | 62 |
| 64 virtual ~Canvas2DLayerBridge(); | 63 virtual ~Canvas2DLayerBridge(); |
| 65 | 64 |
| 66 // WebKit::WebExternalTextureLayerClient implementation. | 65 // WebKit::WebExternalTextureLayerClient implementation. |
| 67 virtual unsigned prepareTexture(WebKit::WebTextureUpdater&) OVERRIDE; | 66 virtual unsigned prepareTexture(WebKit::WebTextureUpdater&) OVERRIDE; |
| 68 virtual WebKit::WebGraphicsContext3D* context() OVERRIDE; | 67 virtual WebKit::WebGraphicsContext3D* context() OVERRIDE; |
| 69 virtual bool prepareMailbox(WebKit::WebExternalTextureMailbox*) OVERRIDE; | 68 virtual bool prepareMailbox(WebKit::WebExternalTextureMailbox*) OVERRIDE; |
| 70 virtual void mailboxReleased(const WebKit::WebExternalTextureMailbox&) OVERR IDE; | 69 virtual void mailboxReleased(const WebKit::WebExternalTextureMailbox&) OVERR IDE; |
| 71 | 70 |
| 72 // SkDeferredCanvas::NotificationClient implementation | 71 // SkDeferredCanvas::NotificationClient implementation |
| 73 virtual void prepareForDraw() OVERRIDE; | 72 virtual void prepareForDraw() OVERRIDE; |
| 74 virtual void storageAllocatedForRecordingChanged(size_t) OVERRIDE; | 73 virtual void storageAllocatedForRecordingChanged(size_t) OVERRIDE; |
| 75 virtual void flushedDrawCommands() OVERRIDE; | 74 virtual void flushedDrawCommands() OVERRIDE; |
| 76 virtual void skippedPendingDrawCommands() OVERRIDE; | 75 virtual void skippedPendingDrawCommands() OVERRIDE; |
| 77 | 76 |
| 78 // Methods used by Canvas2DLayerManager | 77 // Methods used by Canvas2DLayerManager |
| 79 virtual size_t freeMemoryIfPossible(size_t); // virtual for mocking | 78 virtual size_t freeMemoryIfPossible(size_t); // virtual for mocking |
| 80 virtual void flush(); // virtual for mocking | 79 virtual void flush(); // virtual for mocking |
| 81 virtual size_t storageAllocatedForRecording(); // virtual for faking | 80 virtual size_t storageAllocatedForRecording(); // virtual for faking |
| 82 size_t bytesAllocated() const {return m_bytesAllocated;} | 81 size_t bytesAllocated() const {return m_bytesAllocated;} |
| 83 void limitPendingFrames(); | 82 void limitPendingFrames(); |
| 84 | 83 |
| 85 WebKit::WebLayer* layer(); | 84 WebKit::WebLayer* layer(); |
| 86 void contextAcquired(); | 85 void contextAcquired(); |
| 86 SkCanvas* getCanvas() {return m_canvas;} | |
|
Stephen White
2013/05/31 15:06:18
Nit: Missing spaces?
| |
| 87 | 87 |
| 88 unsigned backBufferTexture(); | 88 unsigned backBufferTexture(); |
| 89 | 89 |
| 90 bool isValid(); | |
| 91 | |
| 90 protected: | 92 protected: |
| 91 Canvas2DLayerBridge(PassRefPtr<GraphicsContext3D>, SkDeferredCanvas*, Opacit yMode, ThreadMode); | 93 virtual PassRefPtr<GraphicsContext3D> getSharedContext() const; // virtual f or faking |
| 94 Canvas2DLayerBridge(PassRefPtr<GraphicsContext3D>, SkDeferredCanvas*); | |
| 95 void init(OpacityMode, ThreadMode); | |
| 92 | 96 |
| 93 SkDeferredCanvas* m_canvas; | 97 SkDeferredCanvas* m_canvas; |
| 94 OwnPtr<WebKit::WebExternalTextureLayer> m_layer; | 98 OwnPtr<WebKit::WebExternalTextureLayer> m_layer; |
| 95 RefPtr<GraphicsContext3D> m_context; | 99 RefPtr<GraphicsContext3D> m_context; |
| 96 size_t m_bytesAllocated; | 100 size_t m_bytesAllocated; |
| 97 bool m_didRecordDrawCommand; | 101 bool m_didRecordDrawCommand; |
| 98 int m_framesPending; | 102 int m_framesPending; |
| 99 | 103 |
| 104 friend class ::Canvas2DLayerBridgeTest; // for unit testing | |
| 105 | |
| 100 friend class WTF::DoublyLinkedListNode<Canvas2DLayerBridge>; | 106 friend class WTF::DoublyLinkedListNode<Canvas2DLayerBridge>; |
| 101 Canvas2DLayerBridge* m_next; | 107 Canvas2DLayerBridge* m_next; |
| 102 Canvas2DLayerBridge* m_prev; | 108 Canvas2DLayerBridge* m_prev; |
| 103 | 109 |
| 104 #if ENABLE(CANVAS_USES_MAILBOX) | 110 #if ENABLE(CANVAS_USES_MAILBOX) |
| 105 enum MailboxStatus { | 111 enum MailboxStatus { |
| 106 MailboxInUse, | 112 MailboxInUse, |
| 107 MailboxReleased, | 113 MailboxReleased, |
| 108 MailboxAvailable, | 114 MailboxAvailable, |
| 109 }; | 115 }; |
| 110 | 116 |
| 111 struct MailboxInfo { | 117 struct MailboxInfo { |
| 112 WebKit::WebExternalTextureMailbox m_mailbox; | 118 WebKit::WebExternalTextureMailbox m_mailbox; |
| 113 SkAutoTUnref<SkImage> m_image; | 119 SkAutoTUnref<SkImage> m_image; |
| 114 MailboxStatus m_status; | 120 MailboxStatus m_status; |
| 115 | 121 |
| 116 MailboxInfo(const MailboxInfo&); | 122 MailboxInfo(const MailboxInfo&); |
| 117 MailboxInfo() {} | 123 MailboxInfo() {} |
| 118 }; | 124 }; |
| 119 MailboxInfo* createMailboxInfo(); | 125 MailboxInfo* createMailboxInfo(); |
| 120 | 126 |
| 121 uint32_t m_lastImageId; | 127 uint32_t m_lastImageId; |
| 122 Vector<MailboxInfo> m_mailboxes; | 128 Vector<MailboxInfo> m_mailboxes; |
| 123 #endif | 129 #endif |
| 124 }; | 130 }; |
| 125 | 131 |
| 126 } | 132 } |
| 127 | 133 |
| 128 #endif | 134 #endif |
| OLD | NEW |