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

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

Issue 2455983005: Refactor AcceleratedStaticBitmapImage (Closed)
Patch Set: WeakPtr, still figuring out why one layout test timed out Created 4 years, 1 month 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
(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 WebThread* imageThread() final { return m_imageThread; }
21 IntSize size() const final {
22 return IntSize(m_image->width(), m_image->height());
23 }
24
25 sk_sp<SkImage> skImage() final { return m_image; }
26 void setSharedContextId(unsigned contextId) final {
27 m_sharedContextId = contextId;
28 }
29 void setImageThread(WebThread* thread) { m_imageThread = thread; }
30 bool originClean() final { return m_isOriginClean; }
31 void setOriginClean(bool flag) final { m_isOriginClean = flag; }
32 bool isPremultiplied() final { return m_isPremultiplied; }
33 void setPremultiplied(bool flag) final { m_isPremultiplied = flag; }
34
35 // When creating a AcceleratedStaticBitmap from a texture-backed SkImage, this
36 // function will be called to create a TextureHolder object.
37 SkiaTextureHolder(sk_sp<SkImage>);
38 // This function consumes the mailbox in the input parameter and turn it into
39 // a texture-backed SkImage.
40 SkiaTextureHolder(std::unique_ptr<TextureHolder>);
41
42 private:
43 void releaseImageThreadSafe();
44
45 // The m_image should always be texture-backed
46 sk_sp<SkImage> m_image;
47 // Id of the shared context where m_image was created
48 unsigned m_sharedContextId = 0;
49 // Thread that |m_image| belongs to. Set to null when |m_image| belongs to the
50 // same thread as the AcceleratedStaticBitmapImage. Should only be non-null
51 // after a transfer.
52 WebThread* m_imageThread = nullptr;
53 bool m_isOriginClean = true;
54 bool m_isPremultiplied = true;
55 };
56
57 } // namespace blink
58
59 #endif // SkiaTextureHolder_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698