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 e423490f14e67e3027cbb1ed728176d82528de23..aa8b38e9d46e78c4cc772c0f529a1e1d25c3a860 100644 |
--- a/third_party/WebKit/Source/platform/graphics/AcceleratedStaticBitmapImage.h |
+++ b/third_party/WebKit/Source/platform/graphics/AcceleratedStaticBitmapImage.h |
@@ -5,7 +5,6 @@ |
#ifndef AcceleratedStaticBitmapImage_h |
#define AcceleratedStaticBitmapImage_h |
-#include "base/threading/thread_checker.h" |
#include "gpu/command_buffer/common/mailbox.h" |
#include "gpu/command_buffer/common/sync_token.h" |
#include "platform/geometry/IntSize.h" |
@@ -21,15 +20,14 @@ |
} |
namespace blink { |
-class WebThread; |
class PLATFORM_EXPORT AcceleratedStaticBitmapImage final : public StaticBitmapImage { |
public: |
- // SkImage with a texture backing that is assumed to be from the shared context of the current thread. |
- static PassRefPtr<AcceleratedStaticBitmapImage> createFromSharedContextImage(sk_sp<SkImage>); |
+ // SkImage with a texture backing that is assumed to be from the shared main thread context. |
+ static PassRefPtr<AcceleratedStaticBitmapImage> create(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. |
- static PassRefPtr<AcceleratedStaticBitmapImage> createFromWebGLContextImage(sk_sp<SkImage>, const gpu::Mailbox&, const gpu::SyncToken&); |
+ static PassRefPtr<AcceleratedStaticBitmapImage> create(sk_sp<SkImage>, sk_sp<GrContext>, const gpu::Mailbox&, const gpu::SyncToken&); |
~AcceleratedStaticBitmapImage() override; |
@@ -37,38 +35,28 @@ |
sk_sp<SkImage> imageForCurrentFrame() override; |
void copyToTexture(WebGraphicsContext3DProvider*, GLuint destTextureId, GLenum destInternalFormat, GLenum destType, bool flipY) override; |
- // Image overrides. |
- void draw(SkCanvas*, const SkPaint&, const FloatRect& dstRect, const FloatRect& srcRect, RespectImageOrientationEnum, ImageClampingMode) override; |
- |
- // To be called on sender thread before performing a transfer |
- void transfer() final; |
- |
private: |
AcceleratedStaticBitmapImage(sk_sp<SkImage>); |
- AcceleratedStaticBitmapImage(sk_sp<SkImage>, const gpu::Mailbox&, const gpu::SyncToken&); |
+ AcceleratedStaticBitmapImage(sk_sp<SkImage>, sk_sp<GrContext>, const gpu::Mailbox&, const gpu::SyncToken&); |
+ |
+ bool switchStorageToMailbox(WebGraphicsContext3DProvider*); |
+ GLuint switchStorageToSkImageForWebGL(WebGraphicsContext3DProvider*); |
+ GLuint switchStorageToSkImage(WebGraphicsContext3DProvider*); |
void ensureMailbox(); |
- 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 |m_image| has a texture id backing it from the shared main thread context. |
+ 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. |
+ sk_sp<GrContext> m_grContext; |
// 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 belong to the same thread |
- // as this AcceleratedStaticBitmapImage. Should only be non-null after a transfer. |
- WebThread* m_imageThread = nullptr; |
- |
- base::ThreadChecker m_threadChecker; |
- bool m_detachThreadAtNextCheck = false; |
}; |
} // namespace blink |