OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef SkiaTextureHolder_h |
| 6 #define SkiaTextureHolder_h |
| 7 |
| 8 #include "platform/PlatformExport.h" |
| 9 #include "platform/graphics/TextureHolder.h" |
| 10 |
| 11 namespace blink { |
| 12 |
| 13 class MailboxTextureHolder; |
| 14 |
| 15 class PLATFORM_EXPORT SkiaTextureHolder final : public TextureHolder { |
| 16 public: |
| 17 ~SkiaTextureHolder() override; |
| 18 |
| 19 bool isSkiaTextureHolder() final { return true; } |
| 20 unsigned sharedContextId() final; |
| 21 gpu::Mailbox getMailbox() final { return gpu::Mailbox(); } |
| 22 gpu::SyncToken getSyncToken() final { return gpu::SyncToken(); } |
| 23 IntSize getMailboxSize() final { return IntSize(); } |
| 24 void releaseImageThreadSafe() final; |
| 25 sk_sp<SkImage> getSkImage() final { return m_image; } |
| 26 WebThread* getImageThread() final { return m_imageThread; } |
| 27 IntSize size() const final { |
| 28 return IntSize(m_image->width(), m_image->height()); |
| 29 } |
| 30 void setSharedContextId(unsigned contextId) final { |
| 31 m_sharedContextId = contextId; |
| 32 } |
| 33 void setImageThread(WebThread* thread) { m_imageThread = thread; } |
| 34 void updateSyncToken(gpu::SyncToken) final {} |
| 35 |
| 36 // When creating a AcceleratedStaticBitmap from a texture-backed SkImage, this |
| 37 // function will be called to create a TextureHolder object. |
| 38 SkiaTextureHolder(sk_sp<SkImage>); |
| 39 // This function consumes the mailbox in the input parameter and turn it into |
| 40 // a texture-backed SkImage. |
| 41 SkiaTextureHolder(const gpu::Mailbox&, |
| 42 const gpu::SyncToken&, |
| 43 IntSize mailboxSize); |
| 44 |
| 45 private: |
| 46 // The m_image should always be texture-backed |
| 47 sk_sp<SkImage> m_image; |
| 48 // Id of the shared context where m_image was created |
| 49 unsigned m_sharedContextId = 0; |
| 50 // Thread that |m_image| belongs to. Set to null when |m_image| belongs to the |
| 51 // same thread as the AcceleratedStaticBitmapImage. Should only be non-null |
| 52 // after a transfer. |
| 53 WebThread* m_imageThread = nullptr; |
| 54 }; |
| 55 |
| 56 } // namespace blink |
| 57 |
| 58 #endif // SkiaTextureHolder_h |
OLD | NEW |