Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: Source/core/platform/graphics/Canvas2DLayerBridge.h

Issue 99103006: Moving GraphicsContext and dependencies from core to platform. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Final patch - fixes Android Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26 #ifndef Canvas2DLayerBridge_h
27 #define Canvas2DLayerBridge_h
28
29 #include "SkDeferredCanvas.h"
30 #include "SkImage.h"
31 #include "core/platform/graphics/GraphicsContext3D.h"
32 #include "platform/geometry/IntSize.h"
33 #include "public/platform/WebExternalTextureLayer.h"
34 #include "public/platform/WebExternalTextureLayerClient.h"
35 #include "public/platform/WebExternalTextureMailbox.h"
36 #include "wtf/DoublyLinkedList.h"
37 #include "wtf/PassOwnPtr.h"
38 #include "wtf/RefPtr.h"
39
40 namespace blink {
41 class WebGraphicsContext3D;
42 }
43
44 namespace WebCore {
45
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 blink::WebExternalTextureLayerClient, public SkDeferredCanvas::NotificationClient, public DoublyLinkedListNode<Canvas2DLayerB ridge>, public RefCounted<Canvas2DLayerBridge> {
65 WTF_MAKE_NONCOPYABLE(Canvas2DLayerBridge);
66 public:
67 enum OpacityMode {
68 Opaque,
69 NonOpaque
70 };
71
72 static PassRefPtr<Canvas2DLayerBridge> create(PassRefPtr<GraphicsContext3D>, const IntSize&, OpacityMode, int msaaSampleCount);
73
74 virtual ~Canvas2DLayerBridge();
75
76 // blink::WebExternalTextureLayerClient implementation.
77 virtual blink::WebGraphicsContext3D* context() OVERRIDE;
78 virtual bool prepareMailbox(blink::WebExternalTextureMailbox*, blink::WebExt ernalBitmap*) OVERRIDE;
79 virtual void mailboxReleased(const blink::WebExternalTextureMailbox&) OVERRI DE;
80
81 // SkDeferredCanvas::NotificationClient implementation
82 virtual void prepareForDraw() OVERRIDE;
83 virtual void storageAllocatedForRecordingChanged(size_t) OVERRIDE;
84 virtual void flushedDrawCommands() OVERRIDE;
85 virtual void skippedPendingDrawCommands() OVERRIDE;
86
87 // Methods used by Canvas2DLayerManager
88 virtual size_t freeMemoryIfPossible(size_t); // virtual for mocking
89 virtual void flush(); // virtual for mocking
90 virtual size_t storageAllocatedForRecording(); // virtual for faking
91 size_t bytesAllocated() const {return m_bytesAllocated;}
92 void limitPendingFrames();
93
94 blink::WebLayer* layer();
95 void contextAcquired();
96 PassRefPtr<SkCanvas> getCanvas() { return PassRefPtr<SkCanvas>(m_canvas); }
97
98 unsigned backBufferTexture();
99
100 bool isValid();
101
102 protected:
103 void destroy();
104 friend class Canvas2DLayerBridgePtr;
105 Canvas2DLayerBridge(PassRefPtr<GraphicsContext3D>, PassRefPtr<SkDeferredCanv as>, int, OpacityMode);
106 void setRateLimitingEnabled(bool);
107
108 RefPtr<SkDeferredCanvas> m_canvas;
109 OwnPtr<blink::WebExternalTextureLayer> m_layer;
110 RefPtr<GraphicsContext3D> m_context;
111 int m_msaaSampleCount;
112 size_t m_bytesAllocated;
113 bool m_didRecordDrawCommand;
114 bool m_surfaceIsValid;
115 int m_framesPending;
116 bool m_destructionInProgress;
117 bool m_rateLimitingEnabled;
118
119 friend class WTF::DoublyLinkedListNode<Canvas2DLayerBridge>;
120 Canvas2DLayerBridge* m_next;
121 Canvas2DLayerBridge* m_prev;
122
123 enum MailboxStatus {
124 MailboxInUse,
125 MailboxReleased,
126 MailboxAvailable,
127 };
128
129 struct MailboxInfo {
130 blink::WebExternalTextureMailbox m_mailbox;
131 SkAutoTUnref<SkImage> m_image;
132 MailboxStatus m_status;
133 RefPtr<Canvas2DLayerBridge> m_parentLayerBridge;
134
135 MailboxInfo(const MailboxInfo&);
136 MailboxInfo() {}
137 };
138 MailboxInfo* createMailboxInfo();
139
140 uint32_t m_lastImageId;
141 Vector<MailboxInfo> m_mailboxes;
142 };
143 }
144 #endif
OLDNEW
« no previous file with comments | « Source/core/platform/graphics/BitmapImageTest.cpp ('k') | Source/core/platform/graphics/Canvas2DLayerBridge.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698