Chromium Code Reviews| 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 PLATFORM_EXPORT SkiaTextureHolder final : public TextureHolder { | |
| 14 public: | |
| 15 ~SkiaTextureHolder() override; | |
| 16 | |
| 17 bool isSkiaTextureHolder() final { return true; } | |
| 18 bool isMailboxTextureHolder() final { return false; } | |
| 19 unsigned sharedContextId() final; | |
| 20 IntSize size() const final { | |
| 21 return IntSize(m_image->width(), m_image->height()); | |
| 22 } | |
| 23 bool currentFrameKnownToBeOpaque(Image::MetadataMode) final { | |
| 24 return m_image->isOpaque(); | |
| 25 } | |
| 26 WebTaskRunner* imageThreadTaskRunner() final { | |
| 27 return m_imageThreadTaskRunner.get(); | |
| 28 } | |
| 29 | |
| 30 sk_sp<SkImage> skImage() final { return m_image; } | |
| 31 void setSharedContextId(unsigned contextId) final { | |
| 32 m_sharedContextId = contextId; | |
| 33 } | |
| 34 void setImageThreadTaskRunner( | |
| 35 std::unique_ptr<WebTaskRunner> taskRunner) final { | |
| 36 m_imageThreadTaskRunner = std::move(taskRunner); | |
| 37 } | |
| 38 | |
| 39 // When creating a AcceleratedStaticBitmap from a texture-backed SkImage, this | |
| 40 // function will be called to create a TextureHolder object. | |
| 41 SkiaTextureHolder(sk_sp<SkImage>); | |
| 42 // This function consumes the mailbox in the input parameter and turn it into | |
| 43 // a texture-backed SkImage. | |
| 44 SkiaTextureHolder(std::unique_ptr<TextureHolder>); | |
| 45 | |
| 46 private: | |
| 47 void releaseImageThreadSafe(); | |
| 48 | |
| 49 // The m_image should always be texture-backed | |
| 50 sk_sp<SkImage> m_image; | |
| 51 // Id of the shared context where m_image was created | |
| 52 unsigned m_sharedContextId = 0; | |
| 53 // Thread that |m_image| belongs to. Set to null when |m_image| belongs to the | |
| 54 // same thread as the AcceleratedStaticBitmapImage. Should only be non-null | |
| 55 // after a transfer. | |
| 56 std::unique_ptr<WebTaskRunner> m_imageThreadTaskRunner; | |
|
xidachen
2016/11/04 02:23:35
haraken@: yes, we are keeping a clone of the taskR
| |
| 57 }; | |
| 58 | |
| 59 } // namespace blink | |
| 60 | |
| 61 #endif // SkiaTextureHolder_h | |
| OLD | NEW |