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 50987401a5268a9bc51240aa95f2da6c45cbdcff..8b9ce92ab52d0bd71a104205c50ba1c494aff8cc 100644 |
| --- a/third_party/WebKit/Source/platform/graphics/AcceleratedStaticBitmapImage.h |
| +++ b/third_party/WebKit/Source/platform/graphics/AcceleratedStaticBitmapImage.h |
| @@ -6,9 +6,8 @@ |
| #define AcceleratedStaticBitmapImage_h |
| #include "base/threading/thread_checker.h" |
| -#include "platform/geometry/IntSize.h" |
| #include "platform/graphics/StaticBitmapImage.h" |
| -#include "third_party/skia/include/core/SkRefCnt.h" |
| +#include "platform/graphics/TextureHolder.h" |
| #include <memory> |
| @@ -18,8 +17,14 @@ namespace cc { |
| class SingleReleaseCallback; |
| } |
| +namespace gpu { |
| +namespace gles2 { |
| +class GLES2Interface; |
| +} |
| +} |
| + |
| namespace blink { |
| -class WebThread; |
| +class TextureHolder; |
| class PLATFORM_EXPORT AcceleratedStaticBitmapImage final |
| : public StaticBitmapImage { |
| @@ -28,17 +33,19 @@ class PLATFORM_EXPORT AcceleratedStaticBitmapImage final |
| // context of the current thread. |
| static PassRefPtr<AcceleratedStaticBitmapImage> createFromSharedContextImage( |
| sk_sp<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. |
| + // Can specify the GrContext that created the texture backing. Ideally all |
| + // callers would use this option. The |mailbox| is a name for the texture |
| + // backing, allowing other contexts to use the same backing. |
| static PassRefPtr<AcceleratedStaticBitmapImage> createFromWebGLContextImage( |
| - sk_sp<SkImage>, |
| const gpu::Mailbox&, |
| - const gpu::SyncToken&); |
| + const gpu::SyncToken&, |
| + unsigned textureId, |
| + gpu::gles2::GLES2Interface*, |
| + IntSize mailboxSize); |
| ~AcceleratedStaticBitmapImage() override; |
| + IntSize size() const override; |
| // StaticBitmapImage overrides. |
| sk_sp<SkImage> imageForCurrentFrame() override; |
| void copyToTexture(WebGraphicsContext3DProvider*, |
| @@ -55,40 +62,30 @@ class PLATFORM_EXPORT AcceleratedStaticBitmapImage final |
| RespectImageOrientationEnum, |
| ImageClampingMode) override; |
| + bool isTextureBacked() final { return true; } |
| + bool hasMailbox() final { return !m_texture->isSkiaTextureHolder(); } |
|
Justin Novosad
2016/10/28 21:58:41
This is fragile code: it assumes there are only tw
|
| // To be called on sender thread before performing a transfer |
| void transfer() final; |
| void ensureMailbox() final; |
| - gpu::Mailbox getMailbox() final { return m_mailbox; } |
| - gpu::SyncToken getSyncToken() final { return m_syncToken; } |
| + gpu::Mailbox getMailbox() final { return m_texture->getMailbox(); } |
| + gpu::SyncToken getSyncToken() final { return m_texture->getSyncToken(); } |
| + void updateSyncToken(gpu::SyncToken) final; |
| private: |
| AcceleratedStaticBitmapImage(sk_sp<SkImage>); |
| - AcceleratedStaticBitmapImage(sk_sp<SkImage>, |
| - const gpu::Mailbox&, |
| - const gpu::SyncToken&); |
| + AcceleratedStaticBitmapImage(const gpu::Mailbox&, |
| + const gpu::SyncToken&, |
| + unsigned textureId, |
| + gpu::gles2::GLES2Interface*, |
| + IntSize mailboxSize); |
| void createImageFromMailboxIfNeeded(); |
| void checkThread(); |
| void waitSyncTokenIfNeeded(); |
| bool isValid(); |
| - void releaseImageThreadSafe(); |
| - bool imageBelongsToSharedContext(); |
| - |
| - // Id of the shared context where m_image was created |
| - unsigned m_sharedContextId; |
| - // 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; |
| - // Thread that |m_image| belongs to. Set to null when |m_image| belongs to the |
| - // same thread as this AcceleratedStaticBitmapImage. Should only be non-null |
| - // after a transfer. |
| - WebThread* m_imageThread = nullptr; |
| + |
| + TextureHolder* m_texture; |
|
Justin Novosad
2016/10/28 21:58:41
Should call the m_textureHolder for clarity
|
| base::ThreadChecker m_threadChecker; |
| bool m_detachThreadAtNextCheck = false; |