| 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" |
| 9 #include "gpu/command_buffer/common/sync_token.h" |
| 10 #include "platform/geometry/IntSize.h" |
| 8 #include "platform/graphics/StaticBitmapImage.h" | 11 #include "platform/graphics/StaticBitmapImage.h" |
| 9 #include "public/platform/WebExternalTextureMailbox.h" | 12 |
| 13 #include <memory> |
| 14 |
| 15 class GrContext; |
| 16 |
| 17 namespace cc { |
| 18 class SingleReleaseCallback; |
| 19 } |
| 10 | 20 |
| 11 namespace blink { | 21 namespace blink { |
| 12 | 22 |
| 13 class PLATFORM_EXPORT AcceleratedStaticBitmapImage final : public StaticBitmapIm
age { | 23 class PLATFORM_EXPORT AcceleratedStaticBitmapImage final : public StaticBitmapIm
age { |
| 14 public: | 24 public: |
| 15 ~AcceleratedStaticBitmapImage() override { }; | 25 // SkImage with a texture backing that is assumed to be from the shared main
thread context. |
| 26 static PassRefPtr<AcceleratedStaticBitmapImage> create(PassRefPtr<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 // 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&); |
| 16 | 30 |
| 17 IntSize size() const override; | 31 ~AcceleratedStaticBitmapImage() override; |
| 32 |
| 33 // StaticBitmapImage overrides. |
| 18 PassRefPtr<SkImage> imageForCurrentFrame() override; | 34 PassRefPtr<SkImage> imageForCurrentFrame() override; |
| 19 static PassRefPtr<AcceleratedStaticBitmapImage> create(PassRefPtr<SkImage>); | 35 void copyToTexture(WebGraphicsContext3DProvider*, GLuint destTextureId, GLen
um destInternalFormat, GLenum destType, bool flipY) override; |
| 20 static PassRefPtr<AcceleratedStaticBitmapImage> create(WebExternalTextureMai
lbox&); | |
| 21 void copyToTexture(WebGraphicsContext3DProvider*, GLuint, GLenum, GLenum, bo
ol) override; | |
| 22 bool hasMailbox() override { return m_mailbox.textureSize.width != 0 && m_ma
ilbox.textureSize.height != 0; } | |
| 23 | 36 |
| 24 private: | 37 private: |
| 25 AcceleratedStaticBitmapImage(PassRefPtr<SkImage>); | 38 AcceleratedStaticBitmapImage(PassRefPtr<SkImage>); |
| 26 AcceleratedStaticBitmapImage(WebExternalTextureMailbox&); | 39 AcceleratedStaticBitmapImage(PassRefPtr<SkImage>, sk_sp<GrContext>, const gp
u::Mailbox&, const gpu::SyncToken&); |
| 40 |
| 27 bool switchStorageToMailbox(WebGraphicsContext3DProvider*); | 41 bool switchStorageToMailbox(WebGraphicsContext3DProvider*); |
| 28 GLuint switchStorageToSkImageForWebGL(WebGraphicsContext3DProvider*); | 42 GLuint switchStorageToSkImageForWebGL(WebGraphicsContext3DProvider*); |
| 29 GLuint switchStorageToSkImage(WebGraphicsContext3DProvider*); | 43 GLuint switchStorageToSkImage(WebGraphicsContext3DProvider*); |
| 30 | 44 |
| 31 WebExternalTextureMailbox m_mailbox; | 45 void ensureMailbox(); |
| 46 |
| 47 // True when the |m_image| has a texture id backing it from the shared main
thread context. |
| 48 bool m_imageIsForSharedMainThreadContext; |
| 49 |
| 50 // 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 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 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 gpu::Mailbox m_mailbox; |
| 57 // This token must be waited for before using the mailbox. |
| 58 gpu::SyncToken m_syncToken; |
| 32 }; | 59 }; |
| 33 | 60 |
| 34 } // namespace blink | 61 } // namespace blink |
| 35 | 62 |
| 36 #endif | 63 #endif |
| OLD | NEW |