| 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 AcceleratedStaticBitmapImage_h | 5 #ifndef AcceleratedStaticBitmapImage_h |
| 6 #define AcceleratedStaticBitmapImage_h | 6 #define AcceleratedStaticBitmapImage_h |
| 7 | 7 |
| 8 #include "base/threading/thread_checker.h" | 8 #include "base/threading/thread_checker.h" |
| 9 #include "platform/geometry/IntSize.h" | 9 #include "platform/geometry/IntSize.h" |
| 10 #include "platform/graphics/StaticBitmapImage.h" | 10 #include "platform/graphics/StaticBitmapImage.h" |
| 11 #include "third_party/skia/include/core/SkRefCnt.h" | 11 #include "third_party/skia/include/core/SkRefCnt.h" |
| 12 | 12 |
| 13 #include <memory> | 13 #include <memory> |
| 14 | 14 |
| 15 class GrContext; | 15 class GrContext; |
| 16 | 16 |
| 17 namespace cc { | 17 namespace cc { |
| 18 class SingleReleaseCallback; | 18 class SingleReleaseCallback; |
| 19 } | 19 } |
| 20 | 20 |
| 21 namespace blink { | 21 namespace blink { |
| 22 class WebThread; | 22 class WebThread; |
| 23 | 23 |
| 24 class PLATFORM_EXPORT AcceleratedStaticBitmapImage final | 24 class PLATFORM_EXPORT AcceleratedStaticBitmapImage final |
| 25 : public StaticBitmapImage { | 25 : public StaticBitmapImage { |
| 26 public: | 26 public: |
| 27 // SkImage with a texture backing that is assumed to be from the shared contex
t of the current thread. | 27 // SkImage with a texture backing that is assumed to be from the shared |
| 28 // context of the current thread. |
| 28 static PassRefPtr<AcceleratedStaticBitmapImage> createFromSharedContextImage( | 29 static PassRefPtr<AcceleratedStaticBitmapImage> createFromSharedContextImage( |
| 29 sk_sp<SkImage>); | 30 sk_sp<SkImage>); |
| 30 // Can specify the GrContext that created the texture backing the for the give
n SkImage. Ideally all callers would use this option. | 31 // Can specify the GrContext that created the texture backing the for the |
| 31 // The |mailbox| is a name for the texture backing the SkImage, allowing other
contexts to use the same backing. | 32 // given SkImage. Ideally all callers would use this option. The |mailbox| is |
| 33 // a name for the texture backing the SkImage, allowing other contexts to use |
| 34 // the same backing. |
| 32 static PassRefPtr<AcceleratedStaticBitmapImage> createFromWebGLContextImage( | 35 static PassRefPtr<AcceleratedStaticBitmapImage> createFromWebGLContextImage( |
| 33 sk_sp<SkImage>, | 36 sk_sp<SkImage>, |
| 34 const gpu::Mailbox&, | 37 const gpu::Mailbox&, |
| 35 const gpu::SyncToken&); | 38 const gpu::SyncToken&); |
| 36 | 39 |
| 37 ~AcceleratedStaticBitmapImage() override; | 40 ~AcceleratedStaticBitmapImage() override; |
| 38 | 41 |
| 39 // StaticBitmapImage overrides. | 42 // StaticBitmapImage overrides. |
| 40 sk_sp<SkImage> imageForCurrentFrame() override; | 43 sk_sp<SkImage> imageForCurrentFrame() override; |
| 41 void copyToTexture(WebGraphicsContext3DProvider*, | 44 void copyToTexture(WebGraphicsContext3DProvider*, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 67 | 70 |
| 68 void createImageFromMailboxIfNeeded(); | 71 void createImageFromMailboxIfNeeded(); |
| 69 void checkThread(); | 72 void checkThread(); |
| 70 void waitSyncTokenIfNeeded(); | 73 void waitSyncTokenIfNeeded(); |
| 71 bool isValid(); | 74 bool isValid(); |
| 72 void releaseImageThreadSafe(); | 75 void releaseImageThreadSafe(); |
| 73 bool imageBelongsToSharedContext(); | 76 bool imageBelongsToSharedContext(); |
| 74 | 77 |
| 75 // Id of the shared context where m_image was created | 78 // Id of the shared context where m_image was created |
| 76 unsigned m_sharedContextId; | 79 unsigned m_sharedContextId; |
| 77 // True when the below mailbox and sync token are valid for getting at the tex
ture backing the object's SkImage. | 80 // True when the below mailbox and sync token are valid for getting at the |
| 81 // texture backing the object's SkImage. |
| 78 bool m_hasMailbox = false; | 82 bool m_hasMailbox = false; |
| 79 // A mailbox referring to the texture id backing the SkImage. The mailbox is v
alid as long as the SkImage is held alive. | 83 // A mailbox referring to the texture id backing the SkImage. The mailbox is |
| 84 // valid as long as the SkImage is held alive. |
| 80 gpu::Mailbox m_mailbox; | 85 gpu::Mailbox m_mailbox; |
| 81 // This token must be waited for before using the mailbox. | 86 // This token must be waited for before using the mailbox. |
| 82 gpu::SyncToken m_syncToken; | 87 gpu::SyncToken m_syncToken; |
| 83 // Thread that m_image belongs to. Set to null when m_image belong to the same
thread | 88 // Thread that |m_image| belongs to. Set to null when |m_image| belongs to the |
| 84 // as this AcceleratedStaticBitmapImage. Should only be non-null after a tran
sfer. | 89 // same thread as this AcceleratedStaticBitmapImage. Should only be non-null |
| 90 // after a transfer. |
| 85 WebThread* m_imageThread = nullptr; | 91 WebThread* m_imageThread = nullptr; |
| 86 | 92 |
| 87 base::ThreadChecker m_threadChecker; | 93 base::ThreadChecker m_threadChecker; |
| 88 bool m_detachThreadAtNextCheck = false; | 94 bool m_detachThreadAtNextCheck = false; |
| 89 }; | 95 }; |
| 90 | 96 |
| 91 } // namespace blink | 97 } // namespace blink |
| 92 | 98 |
| 93 #endif | 99 #endif |
| OLD | NEW |