| 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 "gpu/command_buffer/common/mailbox.h" | 8 #include "gpu/command_buffer/common/mailbox.h" |
| 9 #include "gpu/command_buffer/common/sync_token.h" | 9 #include "gpu/command_buffer/common/sync_token.h" |
| 10 #include "platform/geometry/IntSize.h" | 10 #include "platform/geometry/IntSize.h" |
| 11 #include "platform/graphics/StaticBitmapImage.h" | 11 #include "platform/graphics/StaticBitmapImage.h" |
| 12 #include "third_party/skia/include/core/SkRefCnt.h" |
| 12 | 13 |
| 13 #include <memory> | 14 #include <memory> |
| 14 | 15 |
| 15 class GrContext; | 16 class GrContext; |
| 16 | 17 |
| 17 namespace cc { | 18 namespace cc { |
| 18 class SingleReleaseCallback; | 19 class SingleReleaseCallback; |
| 19 } | 20 } |
| 20 | 21 |
| 21 namespace blink { | 22 namespace blink { |
| 22 | 23 |
| 23 class PLATFORM_EXPORT AcceleratedStaticBitmapImage final : public StaticBitmapIm
age { | 24 class PLATFORM_EXPORT AcceleratedStaticBitmapImage final : public StaticBitmapIm
age { |
| 24 public: | 25 public: |
| 25 // SkImage with a texture backing that is assumed to be from the shared main
thread context. | 26 // SkImage with a texture backing that is assumed to be from the shared main
thread context. |
| 26 static PassRefPtr<AcceleratedStaticBitmapImage> create(PassRefPtr<SkImage>); | 27 static PassRefPtr<AcceleratedStaticBitmapImage> create(sk_sp<SkImage>); |
| 27 // Can specify the GrContext that created the texture backing the for the gi
ven SkImage. Ideally all callers would use this option. | 28 // Can specify the GrContext that created the texture backing the for the gi
ven SkImage. Ideally all callers would use this option. |
| 28 // The |mailbox| is a name for the texture backing the SkImage, allowing oth
er contexts to use the same backing. | 29 // The |mailbox| is a name for the texture backing the SkImage, allowing oth
er contexts to use the same backing. |
| 29 static PassRefPtr<AcceleratedStaticBitmapImage> create(PassRefPtr<SkImage>,
sk_sp<GrContext>, const gpu::Mailbox&, const gpu::SyncToken&); | 30 static PassRefPtr<AcceleratedStaticBitmapImage> create(sk_sp<SkImage>, sk_sp
<GrContext>, const gpu::Mailbox&, const gpu::SyncToken&); |
| 30 | 31 |
| 31 ~AcceleratedStaticBitmapImage() override; | 32 ~AcceleratedStaticBitmapImage() override; |
| 32 | 33 |
| 33 // StaticBitmapImage overrides. | 34 // StaticBitmapImage overrides. |
| 34 PassRefPtr<SkImage> imageForCurrentFrame() override; | 35 sk_sp<SkImage> imageForCurrentFrame() override; |
| 35 void copyToTexture(WebGraphicsContext3DProvider*, GLuint destTextureId, GLen
um destInternalFormat, GLenum destType, bool flipY) override; | 36 void copyToTexture(WebGraphicsContext3DProvider*, GLuint destTextureId, GLen
um destInternalFormat, GLenum destType, bool flipY) override; |
| 36 | 37 |
| 37 private: | 38 private: |
| 38 AcceleratedStaticBitmapImage(PassRefPtr<SkImage>); | 39 AcceleratedStaticBitmapImage(sk_sp<SkImage>); |
| 39 AcceleratedStaticBitmapImage(PassRefPtr<SkImage>, sk_sp<GrContext>, const gp
u::Mailbox&, const gpu::SyncToken&); | 40 AcceleratedStaticBitmapImage(sk_sp<SkImage>, sk_sp<GrContext>, const gpu::Ma
ilbox&, const gpu::SyncToken&); |
| 40 | 41 |
| 41 bool switchStorageToMailbox(WebGraphicsContext3DProvider*); | 42 bool switchStorageToMailbox(WebGraphicsContext3DProvider*); |
| 42 GLuint switchStorageToSkImageForWebGL(WebGraphicsContext3DProvider*); | 43 GLuint switchStorageToSkImageForWebGL(WebGraphicsContext3DProvider*); |
| 43 GLuint switchStorageToSkImage(WebGraphicsContext3DProvider*); | 44 GLuint switchStorageToSkImage(WebGraphicsContext3DProvider*); |
| 44 | 45 |
| 45 void ensureMailbox(); | 46 void ensureMailbox(); |
| 46 | 47 |
| 47 // True when the |m_image| has a texture id backing it from the shared main
thread context. | 48 // True when the |m_image| has a texture id backing it from the shared main
thread context. |
| 48 bool m_imageIsForSharedMainThreadContext; | 49 bool m_imageIsForSharedMainThreadContext; |
| 49 | 50 |
| 50 // Keeps the context alive that the SkImage is associated with. Not used if
the SkImage is coming from the shared main | 51 // Keeps the context alive that the SkImage is associated with. Not used if
the SkImage is coming from the shared main |
| 51 // thread context as we assume that context is kept alive elsewhere since it
is globally shared in the process. | 52 // thread context as we assume that context is kept alive elsewhere since it
is globally shared in the process. |
| 52 sk_sp<GrContext> m_grContext; | 53 sk_sp<GrContext> m_grContext; |
| 53 // True when the below mailbox and sync token are valid for getting at the t
exture backing the object's SkImage. | 54 // True when the below mailbox and sync token are valid for getting at the t
exture backing the object's SkImage. |
| 54 bool m_hasMailbox = false; | 55 bool m_hasMailbox = false; |
| 55 // A mailbox referring to the texture id backing the SkImage. The mailbox is
valid as long as the SkImage is held alive. | 56 // A mailbox referring to the texture id backing the SkImage. The mailbox is
valid as long as the SkImage is held alive. |
| 56 gpu::Mailbox m_mailbox; | 57 gpu::Mailbox m_mailbox; |
| 57 // This token must be waited for before using the mailbox. | 58 // This token must be waited for before using the mailbox. |
| 58 gpu::SyncToken m_syncToken; | 59 gpu::SyncToken m_syncToken; |
| 59 }; | 60 }; |
| 60 | 61 |
| 61 } // namespace blink | 62 } // namespace blink |
| 62 | 63 |
| 63 #endif | 64 #endif |
| OLD | NEW |