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 16 matching lines...) Expand all Loading... |
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" | 34 #include "platform/graphics/paint/PaintRecorder.h" |
35 #include "platform/graphics/paint/PaintSurface.h" | 35 #include "platform/graphics/paint/PaintSurface.h" |
36 #include "public/platform/WebExternalTextureLayer.h" | 36 #include "public/platform/WebExternalTextureLayer.h" |
37 #include "public/platform/WebThread.h" | |
38 #include "third_party/khronos/GLES2/gl2.h" | 37 #include "third_party/khronos/GLES2/gl2.h" |
39 #include "third_party/skia/include/core/SkRefCnt.h" | 38 #include "third_party/skia/include/core/SkRefCnt.h" |
40 #include "ui/gfx/color_space.h" | 39 #include "ui/gfx/color_space.h" |
41 #include "wtf/Allocator.h" | 40 #include "wtf/Allocator.h" |
42 #include "wtf/Deque.h" | 41 #include "wtf/Deque.h" |
43 #include "wtf/RefCounted.h" | 42 #include "wtf/RefCounted.h" |
44 #include "wtf/RefPtr.h" | 43 #include "wtf/RefPtr.h" |
45 #include "wtf/Vector.h" | 44 #include "wtf/Vector.h" |
46 #include "wtf/WeakPtr.h" | 45 #include "wtf/WeakPtr.h" |
47 | 46 |
(...skipping 25 matching lines...) Expand all Loading... |
73 #else | 72 #else |
74 #define CANVAS2D_HIBERNATION_ENABLED 1 | 73 #define CANVAS2D_HIBERNATION_ENABLED 1 |
75 #define USE_IOSURFACE_FOR_2D_CANVAS 0 | 74 #define USE_IOSURFACE_FOR_2D_CANVAS 0 |
76 #endif | 75 #endif |
77 | 76 |
78 // TODO: Fix background rendering and remove this workaround. crbug.com/600386 | 77 // TODO: Fix background rendering and remove this workaround. crbug.com/600386 |
79 #define CANVAS2D_BACKGROUND_RENDER_SWITCH_TO_CPU 0 | 78 #define CANVAS2D_BACKGROUND_RENDER_SWITCH_TO_CPU 0 |
80 | 79 |
81 class PLATFORM_EXPORT Canvas2DLayerBridge | 80 class PLATFORM_EXPORT Canvas2DLayerBridge |
82 : public NON_EXPORTED_BASE(cc::TextureLayerClient), | 81 : public NON_EXPORTED_BASE(cc::TextureLayerClient), |
83 public WebThread::TaskObserver, | |
84 public RefCounted<Canvas2DLayerBridge> { | 82 public RefCounted<Canvas2DLayerBridge> { |
85 WTF_MAKE_NONCOPYABLE(Canvas2DLayerBridge); | 83 WTF_MAKE_NONCOPYABLE(Canvas2DLayerBridge); |
86 | 84 |
87 public: | 85 public: |
88 enum AccelerationMode { | 86 enum AccelerationMode { |
89 DisableAcceleration, | 87 DisableAcceleration, |
90 EnableAcceleration, | 88 EnableAcceleration, |
91 ForceAccelerationForTesting, | 89 ForceAccelerationForTesting, |
92 }; | 90 }; |
93 | 91 |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 #endif // USE_IOSURFACE_FOR_2D_CANVAS | 196 #endif // USE_IOSURFACE_FOR_2D_CANVAS |
199 | 197 |
200 MailboxInfo(const MailboxInfo&); | 198 MailboxInfo(const MailboxInfo&); |
201 MailboxInfo(); | 199 MailboxInfo(); |
202 }; | 200 }; |
203 | 201 |
204 gpu::gles2::GLES2Interface* contextGL(); | 202 gpu::gles2::GLES2Interface* contextGL(); |
205 void startRecording(); | 203 void startRecording(); |
206 void skipQueuedDrawCommands(); | 204 void skipQueuedDrawCommands(); |
207 void flushRecordingOnly(); | 205 void flushRecordingOnly(); |
208 void unregisterTaskObserver(); | |
209 void reportSurfaceCreationFailure(); | 206 void reportSurfaceCreationFailure(); |
210 | 207 |
211 // WebThread::TaskOberver implementation | |
212 void willProcessTask() override; | |
213 void didProcessTask() override; | |
214 | |
215 PaintSurface* getOrCreateSurface(AccelerationHint = PreferAcceleration); | 208 PaintSurface* getOrCreateSurface(AccelerationHint = PreferAcceleration); |
216 bool shouldAccelerate(AccelerationHint) const; | 209 bool shouldAccelerate(AccelerationHint) const; |
217 | 210 |
218 // Returns the GL filter associated with |m_filterQuality|. | 211 // Returns the GL filter associated with |m_filterQuality|. |
219 GLenum getGLFilter(); | 212 GLenum getGLFilter(); |
220 | 213 |
221 #if USE_IOSURFACE_FOR_2D_CANVAS | 214 #if USE_IOSURFACE_FOR_2D_CANVAS |
222 // Creates an IOSurface-backed texture. Copies |image| into the texture. | 215 // Creates an IOSurface-backed texture. Copies |image| into the texture. |
223 // Prepares a mailbox from the texture. The caller must have created a new | 216 // Prepares a mailbox from the texture. The caller must have created a new |
224 // MailboxInfo, and prepended it to |m_mailboxs|. Returns whether the | 217 // MailboxInfo, and prepended it to |m_mailboxs|. Returns whether the |
(...skipping 27 matching lines...) Expand all Loading... |
252 sk_sp<PaintSurface> m_surface; | 245 sk_sp<PaintSurface> m_surface; |
253 sk_sp<SkImage> m_hibernationImage; | 246 sk_sp<SkImage> m_hibernationImage; |
254 int m_initialSurfaceSaveCount; | 247 int m_initialSurfaceSaveCount; |
255 std::unique_ptr<WebExternalTextureLayer> m_layer; | 248 std::unique_ptr<WebExternalTextureLayer> m_layer; |
256 std::unique_ptr<WebGraphicsContext3DProvider> m_contextProvider; | 249 std::unique_ptr<WebGraphicsContext3DProvider> m_contextProvider; |
257 std::unique_ptr<SharedContextRateLimiter> m_rateLimiter; | 250 std::unique_ptr<SharedContextRateLimiter> m_rateLimiter; |
258 std::unique_ptr<Logger> m_logger; | 251 std::unique_ptr<Logger> m_logger; |
259 WeakPtrFactory<Canvas2DLayerBridge> m_weakPtrFactory; | 252 WeakPtrFactory<Canvas2DLayerBridge> m_weakPtrFactory; |
260 ImageBuffer* m_imageBuffer; | 253 ImageBuffer* m_imageBuffer; |
261 int m_msaaSampleCount; | 254 int m_msaaSampleCount; |
| 255 int m_framesSinceLastCommit = 0; |
262 size_t m_bytesAllocated; | 256 size_t m_bytesAllocated; |
263 bool m_haveRecordedDrawCommands; | 257 bool m_haveRecordedDrawCommands; |
264 bool m_destructionInProgress; | 258 bool m_destructionInProgress; |
265 SkFilterQuality m_filterQuality; | 259 SkFilterQuality m_filterQuality; |
266 bool m_isHidden; | 260 bool m_isHidden; |
267 bool m_isDeferralEnabled; | 261 bool m_isDeferralEnabled; |
268 bool m_isRegisteredTaskObserver; | |
269 bool m_renderingTaskCompletedForCurrentFrame; | |
270 bool m_softwareRenderingWhileHidden; | 262 bool m_softwareRenderingWhileHidden; |
271 bool m_surfaceCreationFailedAtLeastOnce = false; | 263 bool m_surfaceCreationFailedAtLeastOnce = false; |
272 bool m_hibernationScheduled = false; | 264 bool m_hibernationScheduled = false; |
273 bool m_dontUseIdleSchedulingForTesting = false; | 265 bool m_dontUseIdleSchedulingForTesting = false; |
274 bool m_didDrawSinceLastFlush = false; | 266 bool m_didDrawSinceLastFlush = false; |
275 bool m_didDrawSinceLastGpuFlush = false; | 267 bool m_didDrawSinceLastGpuFlush = false; |
276 | 268 |
277 friend class Canvas2DLayerBridgeTest; | 269 friend class Canvas2DLayerBridgeTest; |
278 friend class CanvasRenderingContext2DTest; | 270 friend class CanvasRenderingContext2DTest; |
279 friend class HTMLCanvasPainterTestForSPv2; | 271 friend class HTMLCanvasPainterTestForSPv2; |
(...skipping 23 matching lines...) Expand all Loading... |
303 // Each element in this vector represents an IOSurface backed texture that | 295 // Each element in this vector represents an IOSurface backed texture that |
304 // is ready to be reused. | 296 // is ready to be reused. |
305 // Elements in this vector can safely be purged in low memory conditions. | 297 // Elements in this vector can safely be purged in low memory conditions. |
306 Vector<RefPtr<ImageInfo>> m_imageInfoCache; | 298 Vector<RefPtr<ImageInfo>> m_imageInfoCache; |
307 #endif // USE_IOSURFACE_FOR_2D_CANVAS | 299 #endif // USE_IOSURFACE_FOR_2D_CANVAS |
308 }; | 300 }; |
309 | 301 |
310 } // namespace blink | 302 } // namespace blink |
311 | 303 |
312 #endif | 304 #endif |
OLD | NEW |