Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(166)

Unified Diff: third_party/WebKit/Source/platform/graphics/AcceleratedStaticBitmapImage.h

Issue 2455983005: Refactor AcceleratedStaticBitmapImage (Closed)
Patch Set: minor clean up Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..f2d8fba9a043c39436fe08de3150e6d36eb80557 100644
--- a/third_party/WebKit/Source/platform/graphics/AcceleratedStaticBitmapImage.h
+++ b/third_party/WebKit/Source/platform/graphics/AcceleratedStaticBitmapImage.h
@@ -6,9 +6,9 @@
#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 "wtf/WeakPtr.h"
#include <memory>
@@ -19,35 +19,32 @@ class SingleReleaseCallback;
}
namespace blink {
-class WebThread;
+class DrawingBuffer;
+class TextureHolder;
class PLATFORM_EXPORT AcceleratedStaticBitmapImage final
: public StaticBitmapImage {
public:
+ ~AcceleratedStaticBitmapImage() override;
// 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>);
- // 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&);
-
- ~AcceleratedStaticBitmapImage() override;
+ const gpu::SyncToken&,
+ unsigned textureId,
+ WeakPtr<DrawingBuffer>,
+ IntSize mailboxSize);
- // StaticBitmapImage overrides.
+ bool currentFrameKnownToBeOpaque(MetadataMode = UseCurrentMetadata) override;
+ IntSize size() const override;
sk_sp<SkImage> imageForCurrentFrame() override;
- void copyToTexture(WebGraphicsContext3DProvider*,
- GLuint destTextureId,
- GLenum destInternalFormat,
- GLenum destType,
- bool flipY) override;
+ bool isTextureBacked() final { return true; }
- // Image overrides.
void draw(SkCanvas*,
const SkPaint&,
const FloatRect& dstRect,
@@ -55,40 +52,35 @@ class PLATFORM_EXPORT AcceleratedStaticBitmapImage final
RespectImageOrientationEnum,
ImageClampingMode) override;
+ void copyToTexture(WebGraphicsContext3DProvider*,
+ GLuint destTextureId,
+ GLenum destInternalFormat,
+ GLenum destType,
+ bool flipY) override;
+
+ bool hasMailbox() final { return m_textureHolder->isMailboxTextureHolder(); }
// 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 mailbox() final { return m_textureHolder->mailbox(); }
+ gpu::SyncToken syncToken() final { return m_textureHolder->syncToken(); }
+ 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,
+ WeakPtr<DrawingBuffer>,
+ 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;
+
+ std::unique_ptr<TextureHolder> m_textureHolder;
base::ThreadChecker m_threadChecker;
bool m_detachThreadAtNextCheck = false;

Powered by Google App Engine
This is Rietveld 408576698