| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef SkiaTextureHolder_h | 5 #ifndef SkiaTextureHolder_h |
| 6 #define SkiaTextureHolder_h | 6 #define SkiaTextureHolder_h |
| 7 | 7 |
| 8 #include "platform/PlatformExport.h" | 8 #include "platform/PlatformExport.h" |
| 9 #include "platform/graphics/TextureHolder.h" | 9 #include "platform/graphics/TextureHolder.h" |
| 10 | 10 |
| 11 namespace blink { | 11 namespace blink { |
| 12 | 12 |
| 13 class PLATFORM_EXPORT SkiaTextureHolder final : public TextureHolder { | 13 class PLATFORM_EXPORT SkiaTextureHolder final : public TextureHolder { |
| 14 public: | 14 public: |
| 15 ~SkiaTextureHolder() override; | 15 ~SkiaTextureHolder() override; |
| 16 | 16 |
| 17 // Methods overriding TextureHolder | 17 // Methods overriding TextureHolder |
| 18 void updateSyncToken(gpu::SyncToken) override {} | |
| 19 | |
| 20 bool isSkiaTextureHolder() final { return true; } | 18 bool isSkiaTextureHolder() final { return true; } |
| 21 bool isMailboxTextureHolder() final { return false; } | 19 bool isMailboxTextureHolder() final { return false; } |
| 22 unsigned sharedContextId() final; | 20 unsigned sharedContextId() final; |
| 23 IntSize size() const final { | 21 IntSize size() const final { |
| 24 return IntSize(m_image->width(), m_image->height()); | 22 return IntSize(m_image->width(), m_image->height()); |
| 25 } | 23 } |
| 26 bool currentFrameKnownToBeOpaque(Image::MetadataMode) final { | 24 bool currentFrameKnownToBeOpaque(Image::MetadataMode) final { |
| 27 return m_image->isOpaque(); | 25 return m_image->isOpaque(); |
| 28 } | 26 } |
| 29 | |
| 30 sk_sp<SkImage> skImage() final { return m_image; } | 27 sk_sp<SkImage> skImage() final { return m_image; } |
| 31 void setSharedContextId(unsigned contextId) final { | 28 void setSharedContextId(unsigned contextId) final { |
| 32 m_sharedContextId = contextId; | 29 m_sharedContextId = contextId; |
| 33 } | 30 } |
| 34 | 31 |
| 35 // When creating a AcceleratedStaticBitmap from a texture-backed SkImage, this | 32 // When creating a AcceleratedStaticBitmap from a texture-backed SkImage, this |
| 36 // function will be called to create a TextureHolder object. | 33 // function will be called to create a TextureHolder object. |
| 37 SkiaTextureHolder(sk_sp<SkImage>); | 34 SkiaTextureHolder(sk_sp<SkImage>); |
| 38 // This function consumes the mailbox in the input parameter and turn it into | 35 // This function consumes the mailbox in the input parameter and turn it into |
| 39 // a texture-backed SkImage. | 36 // a texture-backed SkImage. |
| 40 SkiaTextureHolder(std::unique_ptr<TextureHolder>); | 37 SkiaTextureHolder(std::unique_ptr<TextureHolder>); |
| 41 | 38 |
| 42 private: | 39 private: |
| 43 void releaseImageThreadSafe(); | 40 void releaseImageThreadSafe(); |
| 44 | 41 |
| 45 // The m_image should always be texture-backed | 42 // The m_image should always be texture-backed |
| 46 sk_sp<SkImage> m_image; | 43 sk_sp<SkImage> m_image; |
| 47 // Id of the shared context where m_image was created | 44 // Id of the shared context where m_image was created |
| 48 unsigned m_sharedContextId = 0; | 45 unsigned m_sharedContextId = 0; |
| 49 }; | 46 }; |
| 50 | 47 |
| 51 } // namespace blink | 48 } // namespace blink |
| 52 | 49 |
| 53 #endif // SkiaTextureHolder_h | 50 #endif // SkiaTextureHolder_h |
| OLD | NEW |