Chromium Code Reviews| Index: third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.h |
| diff --git a/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.h b/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.h |
| index 19565bd1afd2e83127ad8df3f855fcc3b1783bde..acc36a349fa75df543ed6e48699c37e207917dc8 100644 |
| --- a/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.h |
| +++ b/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.h |
| @@ -40,8 +40,16 @@ |
| #include "wtf/PassOwnPtr.h" |
| #include "wtf/RefCounted.h" |
| #include "wtf/RefPtr.h" |
| +#include "wtf/Vector.h" |
| #include "wtf/WeakPtr.h" |
| +// IOSurfaces are a primitive only present on OS X. |
| +#if OS(MACOSX) |
|
Justin Novosad
2016/03/09 23:13:11
I just landed this minutes ago: https://codereview
erikchen
2016/03/09 23:42:24
Done.
|
| +#define USE_IOSURFACE_FOR_2D_CANVAS 1 |
| +#else |
| +#define USE_IOSURFACE_FOR_2D_CANVAS 0 |
| +#endif |
| + |
| class SkPictureRecorder; |
| namespace blink { |
| @@ -126,12 +134,35 @@ public: |
| void setLoggerForTesting(PassOwnPtr<Logger>); |
| private: |
| +#if USE_IOSURFACE_FOR_2D_CANVAS |
| + // All information associated with a CHROMIUM image. |
| + struct ImageInfo { |
| + ImageInfo() {} |
| + ImageInfo(GLuint imageId, GLuint textureId); |
| + |
| + // Whether this structure holds references to a CHROMIUM image. |
| + bool empty(); |
| + |
| + // The id of the CHROMIUM image. |
| + GLuint m_imageId = 0; |
| + |
| + // The id of the texture bound to the CHROMIUM image. |
| + GLuint m_textureId = 0; |
| + }; |
| +#endif // USE_IOSURFACE_FOR_2D_CANVAS |
| + |
| struct MailboxInfo { |
| DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
| WebExternalTextureMailbox m_mailbox; |
| RefPtr<SkImage> m_image; |
| RefPtr<Canvas2DLayerBridge> m_parentLayerBridge; |
| +#if USE_IOSURFACE_FOR_2D_CANVAS |
| + // If this mailbox wraps an IOSurface-backed texture, the ids of the |
| + // CHROMIUM image and the texture. |
| + ImageInfo m_imageInfo; |
| +#endif // USE_IOSURFACE_FOR_2D_CANVAS |
| + |
| MailboxInfo(const MailboxInfo&); |
| MailboxInfo() {} |
| }; |
| @@ -154,15 +185,36 @@ private: |
| // Returns the GL filter associated with |m_filterQuality|. |
| GLenum getGLFilter(); |
| - // Prepends a new MailboxInfo object to |m_mailboxes|, and returns a |
| - // reference. The reference is no longer valid after |m_mailboxes| is |
| - // mutated. |
| - MailboxInfo& createMailboxInfo(); |
| +#if USE_IOSURFACE_FOR_2D_CANVAS |
| + // Creates an IOSurface-backed texture. Copies |image| into the texture. |
| + // Prepares a mailbox from the texture. The caller must have created a new |
| + // MailboxInfo, and prepended it to |m_mailboxs|. Returns whether the |
| + // mailbox was successfully prepared. |mailbox| is an out parameter only |
| + // populated on success. |
| + bool prepareIOSurfaceMailboxFromImage(SkImage*, WebExternalTextureMailbox*); |
| + |
| + // Creates an IOSurface-backed texture. Returns an ImageInfo, which is empty |
| + // on failure. The caller takes ownership of both the texture and the image. |
| + ImageInfo createIOSurfaceBackedTexture(); |
| + |
| + // Releases all resources associated with a CHROMIUM image. |
| + void deleteCHROMIUMImage(ImageInfo); |
| + |
| + // Releases all resources in the CHROMIUM image cache. |
| + void clearCHROMIUMImageCache(); |
| +#endif // USE_IOSURFACE_FOR_2D_CANVAS |
| + |
| + // Prepends a new MailboxInfo object to |m_mailboxes|. |
| + void createMailboxInfo(); |
| // Returns whether the mailbox was successfully prepared from the SkImage. |
| // The mailbox is an out parameter only populated on success. |
| bool prepareMailboxFromImage(PassRefPtr<SkImage>, WebExternalTextureMailbox*); |
| + // Resets Skia's texture bindings. This method should be called after |
| + // changing texture bindings. |
| + void resetSkiaTextureBinding(); |
| + |
| OwnPtr<SkPictureRecorder> m_recorder; |
| RefPtr<SkSurface> m_surface; |
| RefPtr<SkImage> m_hibernationImage; |
| @@ -200,8 +252,15 @@ private: |
| GLenum m_lastFilter; |
| AccelerationMode m_accelerationMode; |
| OpacityMode m_opacityMode; |
| - IntSize m_size; |
| + const IntSize m_size; |
| int m_recordingPixelCount; |
| + |
| +#if USE_IOSURFACE_FOR_2D_CANVAS |
| + // Each element in this vector represents an IOSurface backed texture that |
| + // is ready to be reused. |
| + // Elements in this vector can safely be purged in low memory conditions. |
| + Vector<ImageInfo> m_imageInfoCache; |
| +#endif // USE_IOSURFACE_FOR_2D_CANVAS |
| }; |
| } // namespace blink |