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

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

Issue 2455983005: Refactor AcceleratedStaticBitmapImage (Closed)
Patch Set: rebase 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/SkiaTextureHolder.h
diff --git a/third_party/WebKit/Source/platform/graphics/SkiaTextureHolder.h b/third_party/WebKit/Source/platform/graphics/SkiaTextureHolder.h
new file mode 100644
index 0000000000000000000000000000000000000000..ab808dae88972ea4498b06a6d949b5bf1b685ba5
--- /dev/null
+++ b/third_party/WebKit/Source/platform/graphics/SkiaTextureHolder.h
@@ -0,0 +1,66 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SkiaTextureHolder_h
+#define SkiaTextureHolder_h
+
+#include "platform/PlatformExport.h"
+#include "platform/graphics/TextureHolder.h"
+
+namespace blink {
+
+class PLATFORM_EXPORT SkiaTextureHolder final : public TextureHolder {
+ public:
+ ~SkiaTextureHolder() override;
+
+ bool isSkiaTextureHolder() final { return true; }
+ bool isMailboxTextureHolder() final { return false; }
+ unsigned sharedContextId() final;
+ IntSize size() const final {
+ return IntSize(m_image->width(), m_image->height());
+ }
+ bool currentFrameKnownToBeOpaque(Image::MetadataMode) final {
+ return m_image->isOpaque();
+ }
+ WebThread* imageThread() final { return m_imageThreadDoNotCall; }
+
+ sk_sp<SkImage> skImage() final { return m_image; }
+ void setSharedContextId(unsigned contextId) final {
+ m_sharedContextId = contextId;
+ }
+ void setImageThread(WebThread* thread) { m_imageThreadDoNotCall = thread; }
+ void setImageThreadTaskRunner(
+ std::unique_ptr<WebTaskRunner> taskRunner) final {
+ m_imageThreadTaskRunner = std::move(taskRunner);
+ }
+
+ // When creating a AcceleratedStaticBitmap from a texture-backed SkImage, this
+ // function will be called to create a TextureHolder object.
+ SkiaTextureHolder(sk_sp<SkImage>);
+ // This function consumes the mailbox in the input parameter and turn it into
+ // a texture-backed SkImage.
+ SkiaTextureHolder(std::unique_ptr<TextureHolder>);
+
+ private:
+ void releaseImageThreadSafe();
+
+ // The m_image should always be texture-backed
+ sk_sp<SkImage> m_image;
+ // Id of the shared context where m_image was created
+ unsigned m_sharedContextId = 0;
+ // Thread that |m_image| belongs to. Set to null when |m_image| belongs to the
+ // same thread as the AcceleratedStaticBitmapImage. Should only be non-null
+ // after a transfer.
+ // VERY IMPORTANT: Used for pointer comparisons only. DO NOT call any of its
+ // API because that would potentially CRASH.
+ WebThread* m_imageThreadDoNotCall;
+ // Keep a clone of the WebTaskRunner for m_imageThread. This is to handle
+ // the case where |m_imageThread| goes out of scope, and we still need to use
+ // the WebTaskRunner for the |m_imageThread|.
+ std::unique_ptr<WebTaskRunner> m_imageThreadTaskRunner;
+};
+
+} // namespace blink
+
+#endif // SkiaTextureHolder_h

Powered by Google App Engine
This is Rietveld 408576698