Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(88)

Side by Side Diff: third_party/WebKit/Source/platform/graphics/AcceleratedStaticBitmapImage.h

Issue 2261623002: Make DrawingBuffer and Canvas2DLayerBridge be cc::TextureLayerClients. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: webmailbox: windows-exports Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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>, PassRefPtr<GrContext>, const gpu::Mailbox&, const gpu::SyncToken&);
Justin Novosad 2016/08/19 21:51:18 If it's not too inconvenient, in new code we shoul
danakj 2016/08/19 21:57:57 Oh I wasn't sure and went out of my way to RefPtr.
danakj 2016/08/19 22:06:20 Done.
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>, PassRefPtr<GrContext>, con st gpu::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 const 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 RefPtr<GrContext> m_grContext;
Justin Novosad 2016/08/19 21:51:18 What are the use case where taking a ref here is n
danakj 2016/08/19 21:57:57 When the m_image is from the non-main-thread-share
danakj 2016/08/19 22:06:20 Done.
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698