Chromium Code Reviews| Index: third_party/WebKit/Source/platform/graphics/AcceleratedStaticBitmapImage.h |
| diff --git a/third_party/WebKit/Source/platform/graphics/AcceleratedStaticBitmapImage.h b/third_party/WebKit/Source/platform/graphics/AcceleratedStaticBitmapImage.h |
| index b5a418d95f1da386a140a4d4491aef76ca1d339b..dee5ee0bdfc2700f9de550b146972413c0732c69 100644 |
| --- a/third_party/WebKit/Source/platform/graphics/AcceleratedStaticBitmapImage.h |
| +++ b/third_party/WebKit/Source/platform/graphics/AcceleratedStaticBitmapImage.h |
| @@ -5,30 +5,57 @@ |
| #ifndef AcceleratedStaticBitmapImage_h |
| #define AcceleratedStaticBitmapImage_h |
| +#include "gpu/command_buffer/common/mailbox.h" |
| +#include "gpu/command_buffer/common/sync_token.h" |
| +#include "platform/geometry/IntSize.h" |
| #include "platform/graphics/StaticBitmapImage.h" |
| -#include "public/platform/WebExternalTextureMailbox.h" |
| + |
| +#include <memory> |
| + |
| +class GrContext; |
| + |
| +namespace cc { |
| +class SingleReleaseCallback; |
| +} |
| namespace blink { |
| class PLATFORM_EXPORT AcceleratedStaticBitmapImage final : public StaticBitmapImage { |
| public: |
| - ~AcceleratedStaticBitmapImage() override { }; |
| + // SkImage with a texture backing that is assumed to be from the shared main thread context. |
| + static PassRefPtr<AcceleratedStaticBitmapImage> create(PassRefPtr<SkImage>); |
| + // Can specify the GrContext that created the texture backing the for the given SkImage. Ideally all callers would use this option. |
| + // The |mailbox| is a name for the texture backing the SkImage, allowing other contexts to use the same backing. |
| + static PassRefPtr<AcceleratedStaticBitmapImage> create(PassRefPtr<SkImage>, PassRefPtr<GrContext>, const gpu::Mailbox&, const gpu::SyncToken&); |
|
Justin Novosad
2016/08/19 21:51:18
If it's not too inconvenient, in new code we shoul
danakj
2016/08/19 21:57:57
Oh I wasn't sure and went out of my way to RefPtr.
danakj
2016/08/19 22:06:20
Done.
|
| + |
| + ~AcceleratedStaticBitmapImage() override; |
| - IntSize size() const override; |
| + // StaticBitmapImage overrides. |
| PassRefPtr<SkImage> imageForCurrentFrame() override; |
| - static PassRefPtr<AcceleratedStaticBitmapImage> create(PassRefPtr<SkImage>); |
| - static PassRefPtr<AcceleratedStaticBitmapImage> create(WebExternalTextureMailbox&); |
| - void copyToTexture(WebGraphicsContext3DProvider*, GLuint, GLenum, GLenum, bool) override; |
| - bool hasMailbox() override { return m_mailbox.textureSize.width != 0 && m_mailbox.textureSize.height != 0; } |
| + void copyToTexture(WebGraphicsContext3DProvider*, GLuint destTextureId, GLenum destInternalFormat, GLenum destType, bool flipY) override; |
| private: |
| AcceleratedStaticBitmapImage(PassRefPtr<SkImage>); |
| - AcceleratedStaticBitmapImage(WebExternalTextureMailbox&); |
| + AcceleratedStaticBitmapImage(PassRefPtr<SkImage>, PassRefPtr<GrContext>, const gpu::Mailbox&, const gpu::SyncToken&); |
| + |
| bool switchStorageToMailbox(WebGraphicsContext3DProvider*); |
| GLuint switchStorageToSkImageForWebGL(WebGraphicsContext3DProvider*); |
| GLuint switchStorageToSkImage(WebGraphicsContext3DProvider*); |
| - WebExternalTextureMailbox m_mailbox; |
| + void ensureMailbox(); |
| + |
| + // True when the |m_image| has a texture id backing it from the shared main thread context. |
| + const bool m_imageIsForSharedMainThreadContext; |
| + |
| + // Keeps the context alive that the SkImage is associated with. Not used if the SkImage is coming from the shared main |
| + // thread context as we assume that context is kept alive elsewhere since it is globally shared in the process. |
| + RefPtr<GrContext> m_grContext; |
|
Justin Novosad
2016/08/19 21:51:18
What are the use case where taking a ref here is n
danakj
2016/08/19 21:57:57
When the m_image is from the non-main-thread-share
danakj
2016/08/19 22:06:20
Done.
|
| + // True when the below mailbox and sync token are valid for getting at the texture backing the object's SkImage. |
| + bool m_hasMailbox = false; |
| + // A mailbox referring to the texture id backing the SkImage. The mailbox is valid as long as the SkImage is held alive. |
| + gpu::Mailbox m_mailbox; |
| + // This token must be waited for before using the mailbox. |
| + gpu::SyncToken m_syncToken; |
| }; |
| } // namespace blink |