| 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 "public/platform/WebExternalTextureLayer.h" | 34 #include "public/platform/WebExternalTextureLayer.h" |
| 35 #include "public/platform/WebThread.h" | 35 #include "public/platform/WebThread.h" |
| 36 #include "third_party/khronos/GLES2/gl2.h" | 36 #include "third_party/khronos/GLES2/gl2.h" |
| 37 #include "third_party/skia/include/core/SkRefCnt.h" |
| 37 #include "third_party/skia/include/core/SkSurface.h" | 38 #include "third_party/skia/include/core/SkSurface.h" |
| 38 #include "wtf/Allocator.h" | 39 #include "wtf/Allocator.h" |
| 39 #include "wtf/Deque.h" | 40 #include "wtf/Deque.h" |
| 40 #include "wtf/RefCounted.h" | 41 #include "wtf/RefCounted.h" |
| 41 #include "wtf/RefPtr.h" | 42 #include "wtf/RefPtr.h" |
| 42 #include "wtf/Vector.h" | 43 #include "wtf/Vector.h" |
| 43 #include "wtf/WeakPtr.h" | 44 #include "wtf/WeakPtr.h" |
| 44 #include <memory> | 45 #include <memory> |
| 45 | 46 |
| 46 class SkImage; | 47 class SkImage; |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 void flushGpu(); | 119 void flushGpu(); |
| 119 void prepareSurfaceForPaintingIfNeeded(); | 120 void prepareSurfaceForPaintingIfNeeded(); |
| 120 bool isHidden() { return m_isHidden; } | 121 bool isHidden() { return m_isHidden; } |
| 121 OpacityMode opacityMode() { return m_opacityMode; } | 122 OpacityMode opacityMode() { return m_opacityMode; } |
| 122 | 123 |
| 123 void beginDestruction(); | 124 void beginDestruction(); |
| 124 void hibernate(); | 125 void hibernate(); |
| 125 bool isHibernating() const { return m_hibernationImage.get(); } | 126 bool isHibernating() const { return m_hibernationImage.get(); } |
| 126 sk_sp<SkColorSpace> colorSpace() const { return m_colorSpace; } | 127 sk_sp<SkColorSpace> colorSpace() const { return m_colorSpace; } |
| 127 | 128 |
| 128 PassRefPtr<SkImage> newImageSnapshot(AccelerationHint, SnapshotReason); | 129 sk_sp<SkImage> newImageSnapshot(AccelerationHint, SnapshotReason); |
| 129 | 130 |
| 130 // The values of the enum entries must not change because they are used for | 131 // The values of the enum entries must not change because they are used for |
| 131 // usage metrics histograms. New values can be added to the end. | 132 // usage metrics histograms. New values can be added to the end. |
| 132 enum HibernationEvent { | 133 enum HibernationEvent { |
| 133 HibernationScheduled = 0, | 134 HibernationScheduled = 0, |
| 134 HibernationAbortedDueToDestructionWhileHibernatePending = 1, | 135 HibernationAbortedDueToDestructionWhileHibernatePending = 1, |
| 135 HibernationAbortedDueToPendingDestruction = 2, | 136 HibernationAbortedDueToPendingDestruction = 2, |
| 136 HibernationAbortedDueToVisibilityChange = 3, | 137 HibernationAbortedDueToVisibilityChange = 3, |
| 137 HibernationAbortedDueGpuContextLoss = 4, | 138 HibernationAbortedDueGpuContextLoss = 4, |
| 138 HibernationAbortedDueToSwitchToUnacceleratedRendering = 5, | 139 HibernationAbortedDueToSwitchToUnacceleratedRendering = 5, |
| (...skipping 30 matching lines...) Expand all Loading... |
| 169 GLuint m_imageId = 0; | 170 GLuint m_imageId = 0; |
| 170 | 171 |
| 171 // The id of the texture bound to the CHROMIUM image. | 172 // The id of the texture bound to the CHROMIUM image. |
| 172 GLuint m_textureId = 0; | 173 GLuint m_textureId = 0; |
| 173 }; | 174 }; |
| 174 #endif // USE_IOSURFACE_FOR_2D_CANVAS | 175 #endif // USE_IOSURFACE_FOR_2D_CANVAS |
| 175 | 176 |
| 176 struct MailboxInfo { | 177 struct MailboxInfo { |
| 177 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | 178 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
| 178 gpu::Mailbox m_mailbox; | 179 gpu::Mailbox m_mailbox; |
| 179 RefPtr<SkImage> m_image; | 180 sk_sp<SkImage> m_image; |
| 180 RefPtr<Canvas2DLayerBridge> m_parentLayerBridge; | 181 RefPtr<Canvas2DLayerBridge> m_parentLayerBridge; |
| 181 | 182 |
| 182 #if USE_IOSURFACE_FOR_2D_CANVAS | 183 #if USE_IOSURFACE_FOR_2D_CANVAS |
| 183 // If this mailbox wraps an IOSurface-backed texture, the ids of the | 184 // If this mailbox wraps an IOSurface-backed texture, the ids of the |
| 184 // CHROMIUM image and the texture. | 185 // CHROMIUM image and the texture. |
| 185 ImageInfo m_imageInfo; | 186 ImageInfo m_imageInfo; |
| 186 #endif // USE_IOSURFACE_FOR_2D_CANVAS | 187 #endif // USE_IOSURFACE_FOR_2D_CANVAS |
| 187 | 188 |
| 188 MailboxInfo(const MailboxInfo&); | 189 MailboxInfo(const MailboxInfo&); |
| 189 MailboxInfo(); | 190 MailboxInfo(); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 | 224 |
| 224 // Releases all resources in the CHROMIUM image cache. | 225 // Releases all resources in the CHROMIUM image cache. |
| 225 void clearCHROMIUMImageCache(); | 226 void clearCHROMIUMImageCache(); |
| 226 #endif // USE_IOSURFACE_FOR_2D_CANVAS | 227 #endif // USE_IOSURFACE_FOR_2D_CANVAS |
| 227 | 228 |
| 228 // Prepends a new MailboxInfo object to |m_mailboxes|. | 229 // Prepends a new MailboxInfo object to |m_mailboxes|. |
| 229 void createMailboxInfo(); | 230 void createMailboxInfo(); |
| 230 | 231 |
| 231 // Returns whether the mailbox was successfully prepared from the SkImage. | 232 // Returns whether the mailbox was successfully prepared from the SkImage. |
| 232 // The mailbox is an out parameter only populated on success. | 233 // The mailbox is an out parameter only populated on success. |
| 233 bool prepareMailboxFromImage(PassRefPtr<SkImage>, cc::TextureMailbox*); | 234 bool prepareMailboxFromImage(sk_sp<SkImage>, cc::TextureMailbox*); |
| 234 | 235 |
| 235 // Resets Skia's texture bindings. This method should be called after | 236 // Resets Skia's texture bindings. This method should be called after |
| 236 // changing texture bindings. | 237 // changing texture bindings. |
| 237 void resetSkiaTextureBinding(); | 238 void resetSkiaTextureBinding(); |
| 238 | 239 |
| 239 std::unique_ptr<SkPictureRecorder> m_recorder; | 240 std::unique_ptr<SkPictureRecorder> m_recorder; |
| 240 RefPtr<SkSurface> m_surface; | 241 sk_sp<SkSurface> m_surface; |
| 241 RefPtr<SkImage> m_hibernationImage; | 242 sk_sp<SkImage> m_hibernationImage; |
| 242 int m_initialSurfaceSaveCount; | 243 int m_initialSurfaceSaveCount; |
| 243 std::unique_ptr<WebExternalTextureLayer> m_layer; | 244 std::unique_ptr<WebExternalTextureLayer> m_layer; |
| 244 std::unique_ptr<WebGraphicsContext3DProvider> m_contextProvider; | 245 std::unique_ptr<WebGraphicsContext3DProvider> m_contextProvider; |
| 245 std::unique_ptr<SharedContextRateLimiter> m_rateLimiter; | 246 std::unique_ptr<SharedContextRateLimiter> m_rateLimiter; |
| 246 std::unique_ptr<Logger> m_logger; | 247 std::unique_ptr<Logger> m_logger; |
| 247 WeakPtrFactory<Canvas2DLayerBridge> m_weakPtrFactory; | 248 WeakPtrFactory<Canvas2DLayerBridge> m_weakPtrFactory; |
| 248 ImageBuffer* m_imageBuffer; | 249 ImageBuffer* m_imageBuffer; |
| 249 int m_msaaSampleCount; | 250 int m_msaaSampleCount; |
| 250 size_t m_bytesAllocated; | 251 size_t m_bytesAllocated; |
| 251 bool m_haveRecordedDrawCommands; | 252 bool m_haveRecordedDrawCommands; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 // Each element in this vector represents an IOSurface backed texture that | 284 // Each element in this vector represents an IOSurface backed texture that |
| 284 // is ready to be reused. | 285 // is ready to be reused. |
| 285 // Elements in this vector can safely be purged in low memory conditions. | 286 // Elements in this vector can safely be purged in low memory conditions. |
| 286 Vector<ImageInfo> m_imageInfoCache; | 287 Vector<ImageInfo> m_imageInfoCache; |
| 287 #endif // USE_IOSURFACE_FOR_2D_CANVAS | 288 #endif // USE_IOSURFACE_FOR_2D_CANVAS |
| 288 }; | 289 }; |
| 289 | 290 |
| 290 } // namespace blink | 291 } // namespace blink |
| 291 | 292 |
| 292 #endif | 293 #endif |
| OLD | NEW |