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

Side by Side Diff: sky/engine/platform/graphics/Canvas2DLayerBridge.h

Issue 1229113003: Remove some unneeded DEPS from //sky (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 5 months 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
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 SKY_ENGINE_PLATFORM_GRAPHICS_CANVAS2DLAYERBRIDGE_H_
27 #define SKY_ENGINE_PLATFORM_GRAPHICS_CANVAS2DLAYERBRIDGE_H_
28
29 #include "sky/engine/platform/PlatformExport.h"
30 #include "sky/engine/platform/geometry/IntSize.h"
31 #include "sky/engine/platform/graphics/ImageBufferSurface.h"
32 #include "sky/engine/public/platform/WebExternalTextureLayer.h"
33 #include "sky/engine/public/platform/WebExternalTextureLayerClient.h"
34 #include "sky/engine/public/platform/WebExternalTextureMailbox.h"
35 #include "sky/engine/wtf/DoublyLinkedList.h"
36 #include "sky/engine/wtf/PassOwnPtr.h"
37 #include "sky/engine/wtf/RefCounted.h"
38 #include "sky/engine/wtf/RefPtr.h"
39 #include "third_party/khronos/GLES2/gl2.h"
40 #include "third_party/skia/include/core/SkImage.h"
41 #include "third_party/skia/include/utils/SkDeferredCanvas.h"
42
43 class Canvas2DLayerBridgeTest;
44
45 namespace blink {
46
47 class ImageBuffer;
48 class WebGraphicsContext3D;
49 class WebGraphicsContext3DProvider;
50
51 class PLATFORM_EXPORT Canvas2DLayerBridge : public WebExternalTextureLayerClient , public SkDeferredCanvas::NotificationClient, public DoublyLinkedListNode<Canva s2DLayerBridge>, public RefCounted<Canvas2DLayerBridge> {
52 WTF_MAKE_NONCOPYABLE(Canvas2DLayerBridge);
53 public:
54 static PassRefPtr<Canvas2DLayerBridge> create(const IntSize&, OpacityMode, i nt msaaSampleCount);
55
56 virtual ~Canvas2DLayerBridge();
57
58 // WebExternalTextureLayerClient implementation.
59 virtual bool prepareMailbox(WebExternalTextureMailbox*, WebExternalBitmap*) override;
60 virtual void mailboxReleased(const WebExternalTextureMailbox&, bool lostReso urce) override;
61
62 // SkDeferredCanvas::NotificationClient implementation
63 virtual void prepareForDraw() override;
64 virtual void storageAllocatedForRecordingChanged(size_t) override;
65 virtual void flushedDrawCommands() override;
66 virtual void skippedPendingDrawCommands() override;
67
68 // ImageBufferSurface implementation
69 void finalizeFrame();
70 void willAccessPixels();
71 SkCanvas* canvas() const { return m_canvas.get(); }
72 bool checkSurfaceValid();
73 bool restoreSurface();
74 WebLayer* layer() const;
75 Platform3DObject getBackingTexture();
76 bool isAccelerated() const { return true; }
77 void setIsHidden(bool);
78 void setImageBuffer(ImageBuffer* imageBuffer) { m_imageBuffer = imageBuffer; }
79
80 // Methods used by Canvas2DLayerManager
81 virtual size_t freeMemoryIfPossible(size_t); // virtual for mocking
82 virtual void flush(); // virtual for mocking
83 virtual size_t storageAllocatedForRecording(); // virtual for faking
84 size_t bytesAllocated() const { return m_bytesAllocated; }
85 void limitPendingFrames();
86 void freeReleasedMailbox();
87 bool hasReleasedMailbox() const;
88 void freeTransientResources();
89 bool hasTransientResources() const;
90 bool isHidden() { return m_isHidden; }
91
92 void beginDestruction();
93
94 protected:
95 Canvas2DLayerBridge(PassOwnPtr<WebGraphicsContext3DProvider>, PassOwnPtr<SkD eferredCanvas>, PassRefPtr<SkSurface>, int, OpacityMode);
96 void setRateLimitingEnabled(bool);
97 bool releasedMailboxHasExpired();
98 WebGraphicsContext3D* context();
99
100 OwnPtr<SkDeferredCanvas> m_canvas;
101 RefPtr<SkSurface> m_surface;
102 OwnPtr<WebExternalTextureLayer> m_layer;
103 OwnPtr<WebGraphicsContext3DProvider> m_contextProvider;
104 ImageBuffer* m_imageBuffer;
105 int m_msaaSampleCount;
106 size_t m_bytesAllocated;
107 bool m_didRecordDrawCommand;
108 bool m_isSurfaceValid;
109 int m_framesPending;
110 int m_framesSinceMailboxRelease;
111 bool m_destructionInProgress;
112 bool m_rateLimitingEnabled;
113 bool m_isHidden;
114
115 friend class WTF::DoublyLinkedListNode<Canvas2DLayerBridge>;
116 friend class ::Canvas2DLayerBridgeTest;
117 Canvas2DLayerBridge* m_next;
118 Canvas2DLayerBridge* m_prev;
119
120 enum MailboxStatus {
121 MailboxInUse,
122 MailboxReleased,
123 MailboxAvailable,
124 };
125
126 struct MailboxInfo {
127 WebExternalTextureMailbox m_mailbox;
128 RefPtr<SkImage> m_image;
129 MailboxStatus m_status;
130 RefPtr<Canvas2DLayerBridge> m_parentLayerBridge;
131
132 MailboxInfo(const MailboxInfo&);
133 MailboxInfo() {}
134 };
135 MailboxInfo* createMailboxInfo();
136 MailboxInfo* releasedMailboxInfo();
137
138 uint32_t m_lastImageId;
139 Vector<MailboxInfo> m_mailboxes;
140 int m_releasedMailboxInfoIndex;
141 };
142
143 } // namespace blink
144
145 #endif // SKY_ENGINE_PLATFORM_GRAPHICS_CANVAS2DLAYERBRIDGE_H_
OLDNEW
« no previous file with comments | « sky/engine/platform/graphics/Canvas2DImageBufferSurface.h ('k') | sky/engine/platform/graphics/Canvas2DLayerBridge.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698