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 13 matching lines...) Expand all Loading... |
24 */ | 24 */ |
25 | 25 |
26 #ifndef Canvas2DLayerBridge_h | 26 #ifndef Canvas2DLayerBridge_h |
27 #define Canvas2DLayerBridge_h | 27 #define Canvas2DLayerBridge_h |
28 | 28 |
29 #include "cc/layers/texture_layer_client.h" | 29 #include "cc/layers/texture_layer_client.h" |
30 #include "cc/resources/texture_mailbox.h" | 30 #include "cc/resources/texture_mailbox.h" |
31 #include "platform/PlatformExport.h" | 31 #include "platform/PlatformExport.h" |
32 #include "platform/geometry/IntSize.h" | 32 #include "platform/geometry/IntSize.h" |
33 #include "platform/graphics/ImageBufferSurface.h" | 33 #include "platform/graphics/ImageBufferSurface.h" |
| 34 #include "platform/graphics/paint/PaintRecorder.h" |
| 35 #include "platform/graphics/paint/PaintSurface.h" |
34 #include "public/platform/WebExternalTextureLayer.h" | 36 #include "public/platform/WebExternalTextureLayer.h" |
35 #include "public/platform/WebThread.h" | 37 #include "public/platform/WebThread.h" |
36 #include "third_party/khronos/GLES2/gl2.h" | 38 #include "third_party/khronos/GLES2/gl2.h" |
37 #include "third_party/skia/include/core/SkRefCnt.h" | 39 #include "third_party/skia/include/core/SkRefCnt.h" |
38 #include "third_party/skia/include/core/SkSurface.h" | |
39 #include "wtf/Allocator.h" | 40 #include "wtf/Allocator.h" |
40 #include "wtf/Deque.h" | 41 #include "wtf/Deque.h" |
41 #include "wtf/RefCounted.h" | 42 #include "wtf/RefCounted.h" |
42 #include "wtf/RefPtr.h" | 43 #include "wtf/RefPtr.h" |
43 #include "wtf/Vector.h" | 44 #include "wtf/Vector.h" |
44 #include "wtf/WeakPtr.h" | 45 #include "wtf/WeakPtr.h" |
45 #include <memory> | 46 #include <memory> |
46 | 47 |
47 class SkImage; | 48 class SkImage; |
48 struct SkImageInfo; | 49 struct SkImageInfo; |
49 class SkPictureRecorder; | |
50 | 50 |
51 namespace gpu { | 51 namespace gpu { |
52 namespace gles2 { | 52 namespace gles2 { |
53 class GLES2Interface; | 53 class GLES2Interface; |
54 } | 54 } |
55 } | 55 } |
56 | 56 |
57 namespace blink { | 57 namespace blink { |
58 | 58 |
59 class Canvas2DLayerBridgeTest; | 59 class Canvas2DLayerBridgeTest; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 // Callback for mailboxes given to the compositor from PrepareTextureMailbox. | 107 // Callback for mailboxes given to the compositor from PrepareTextureMailbox. |
108 void mailboxReleased(const gpu::Mailbox&, | 108 void mailboxReleased(const gpu::Mailbox&, |
109 const gpu::SyncToken&, | 109 const gpu::SyncToken&, |
110 bool lostResource); | 110 bool lostResource); |
111 | 111 |
112 // ImageBufferSurface implementation | 112 // ImageBufferSurface implementation |
113 void finalizeFrame(const FloatRect& dirtyRect); | 113 void finalizeFrame(const FloatRect& dirtyRect); |
114 void willWritePixels(); | 114 void willWritePixels(); |
115 void willOverwriteAllPixels(); | 115 void willOverwriteAllPixels(); |
116 void willOverwriteCanvas(); | 116 void willOverwriteCanvas(); |
117 SkCanvas* canvas(); | 117 PaintCanvas* canvas(); |
118 void disableDeferral(DisableDeferralReason); | 118 void disableDeferral(DisableDeferralReason); |
119 bool checkSurfaceValid(); | 119 bool checkSurfaceValid(); |
120 bool restoreSurface(); | 120 bool restoreSurface(); |
121 WebLayer* layer() const; | 121 WebLayer* layer() const; |
122 bool isAccelerated() const; | 122 bool isAccelerated() const; |
123 void setFilterQuality(SkFilterQuality); | 123 void setFilterQuality(SkFilterQuality); |
124 void setIsHidden(bool); | 124 void setIsHidden(bool); |
125 void setImageBuffer(ImageBuffer*); | 125 void setImageBuffer(ImageBuffer*); |
126 void didDraw(const FloatRect&); | 126 void didDraw(const FloatRect&); |
127 bool writePixels(const SkImageInfo&, | 127 bool writePixels(const SkImageInfo&, |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 void startRecording(); | 202 void startRecording(); |
203 void skipQueuedDrawCommands(); | 203 void skipQueuedDrawCommands(); |
204 void flushRecordingOnly(); | 204 void flushRecordingOnly(); |
205 void unregisterTaskObserver(); | 205 void unregisterTaskObserver(); |
206 void reportSurfaceCreationFailure(); | 206 void reportSurfaceCreationFailure(); |
207 | 207 |
208 // WebThread::TaskOberver implementation | 208 // WebThread::TaskOberver implementation |
209 void willProcessTask() override; | 209 void willProcessTask() override; |
210 void didProcessTask() override; | 210 void didProcessTask() override; |
211 | 211 |
212 SkSurface* getOrCreateSurface(AccelerationHint = PreferAcceleration); | 212 PaintSurface* getOrCreateSurface(AccelerationHint = PreferAcceleration); |
213 bool shouldAccelerate(AccelerationHint) const; | 213 bool shouldAccelerate(AccelerationHint) const; |
214 | 214 |
215 // Returns the GL filter associated with |m_filterQuality|. | 215 // Returns the GL filter associated with |m_filterQuality|. |
216 GLenum getGLFilter(); | 216 GLenum getGLFilter(); |
217 | 217 |
218 #if USE_IOSURFACE_FOR_2D_CANVAS | 218 #if USE_IOSURFACE_FOR_2D_CANVAS |
219 // Creates an IOSurface-backed texture. Copies |image| into the texture. | 219 // Creates an IOSurface-backed texture. Copies |image| into the texture. |
220 // Prepares a mailbox from the texture. The caller must have created a new | 220 // Prepares a mailbox from the texture. The caller must have created a new |
221 // MailboxInfo, and prepended it to |m_mailboxs|. Returns whether the | 221 // MailboxInfo, and prepended it to |m_mailboxs|. Returns whether the |
222 // mailbox was successfully prepared. |mailbox| is an out parameter only | 222 // mailbox was successfully prepared. |mailbox| is an out parameter only |
(...skipping 15 matching lines...) Expand all Loading... |
238 void createMailboxInfo(); | 238 void createMailboxInfo(); |
239 | 239 |
240 // Returns whether the mailbox was successfully prepared from the SkImage. | 240 // Returns whether the mailbox was successfully prepared from the SkImage. |
241 // The mailbox is an out parameter only populated on success. | 241 // The mailbox is an out parameter only populated on success. |
242 bool prepareMailboxFromImage(sk_sp<SkImage>, cc::TextureMailbox*); | 242 bool prepareMailboxFromImage(sk_sp<SkImage>, cc::TextureMailbox*); |
243 | 243 |
244 // Resets Skia's texture bindings. This method should be called after | 244 // Resets Skia's texture bindings. This method should be called after |
245 // changing texture bindings. | 245 // changing texture bindings. |
246 void resetSkiaTextureBinding(); | 246 void resetSkiaTextureBinding(); |
247 | 247 |
248 std::unique_ptr<SkPictureRecorder> m_recorder; | 248 std::unique_ptr<PaintRecorder> m_recorder; |
249 sk_sp<SkSurface> m_surface; | 249 sk_sp<PaintSurface> m_surface; |
250 sk_sp<SkImage> m_hibernationImage; | 250 sk_sp<SkImage> m_hibernationImage; |
251 int m_initialSurfaceSaveCount; | 251 int m_initialSurfaceSaveCount; |
252 std::unique_ptr<WebExternalTextureLayer> m_layer; | 252 std::unique_ptr<WebExternalTextureLayer> m_layer; |
253 std::unique_ptr<WebGraphicsContext3DProvider> m_contextProvider; | 253 std::unique_ptr<WebGraphicsContext3DProvider> m_contextProvider; |
254 std::unique_ptr<SharedContextRateLimiter> m_rateLimiter; | 254 std::unique_ptr<SharedContextRateLimiter> m_rateLimiter; |
255 std::unique_ptr<Logger> m_logger; | 255 std::unique_ptr<Logger> m_logger; |
256 WeakPtrFactory<Canvas2DLayerBridge> m_weakPtrFactory; | 256 WeakPtrFactory<Canvas2DLayerBridge> m_weakPtrFactory; |
257 ImageBuffer* m_imageBuffer; | 257 ImageBuffer* m_imageBuffer; |
258 int m_msaaSampleCount; | 258 int m_msaaSampleCount; |
259 size_t m_bytesAllocated; | 259 size_t m_bytesAllocated; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 // Each element in this vector represents an IOSurface backed texture that | 297 // Each element in this vector represents an IOSurface backed texture that |
298 // is ready to be reused. | 298 // is ready to be reused. |
299 // Elements in this vector can safely be purged in low memory conditions. | 299 // Elements in this vector can safely be purged in low memory conditions. |
300 Vector<RefPtr<ImageInfo>> m_imageInfoCache; | 300 Vector<RefPtr<ImageInfo>> m_imageInfoCache; |
301 #endif // USE_IOSURFACE_FOR_2D_CANVAS | 301 #endif // USE_IOSURFACE_FOR_2D_CANVAS |
302 }; | 302 }; |
303 | 303 |
304 } // namespace blink | 304 } // namespace blink |
305 | 305 |
306 #endif | 306 #endif |
OLD | NEW |