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

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

Issue 2455983005: Refactor AcceleratedStaticBitmapImage (Closed)
Patch Set: Keep a unique_ptr<WebGraphicsContext3DProvider>, otherwise crashes 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 TextureHolder_h
6 #define TextureHolder_h
7
8 #include "gpu/command_buffer/common/mailbox.h"
9 #include "gpu/command_buffer/common/sync_token.h"
10 #include "platform/PlatformExport.h"
11 #include "platform/WebTaskRunner.h"
12 #include "platform/geometry/IntSize.h"
13 #include "platform/graphics/Image.h"
14 #include "third_party/skia/include/core/SkImage.h"
15 #include "third_party/skia/include/core/SkRefCnt.h"
16
17 namespace blink {
18
19 class PLATFORM_EXPORT TextureHolder {
20 public:
21 virtual ~TextureHolder() {}
22
23 // Methods overrided by all sub-classes
24 virtual bool isSkiaTextureHolder() = 0;
25 virtual bool isMailboxTextureHolder() = 0;
26 virtual unsigned sharedContextId() = 0;
27 virtual IntSize size() const = 0;
28 virtual bool currentFrameKnownToBeOpaque(Image::MetadataMode) = 0;
29
30 // Methods overrided by MailboxTextureHolder
31 virtual gpu::Mailbox mailbox() {
32 NOTREACHED();
33 return gpu::Mailbox();
34 }
35 virtual gpu::SyncToken syncToken() {
36 NOTREACHED();
37 return gpu::SyncToken();
38 }
39 virtual void updateSyncToken(gpu::SyncToken) { NOTREACHED(); }
40
41 // Methods overrided by SkiaTextureHolder
42 virtual sk_sp<SkImage> skImage() {
43 NOTREACHED();
44 return nullptr;
45 }
46 virtual void setSharedContextId(unsigned) { NOTREACHED(); }
47 virtual void setImageThread(WebThread*) { NOTREACHED(); }
48 virtual void setImageThreadTaskRunner(std::unique_ptr<WebTaskRunner>) {
49 NOTREACHED();
50 }
51
52 // Methods that have exactly the same impelmentation for all sub-classes
53 bool wasTransferred() { return m_wasTransferred; }
54 WebTaskRunner* textureThreadTaskRunner() {
55 return m_textureThreadTaskRunner.get();
56 }
57 void setWasTransferred(bool flag) { m_wasTransferred = flag; }
58 void setTextureThreadTaskRunner(std::unique_ptr<WebTaskRunner> taskRunner) {
59 m_textureThreadTaskRunner = std::move(taskRunner);
60 }
61
62 private:
63 // Wether the AcceleratedStaticBitmapImage that holds the |m_texture| was
64 // transferred to another thread or not. Set to false when the
65 // AcceleratedStaticBitmapImage remain on the same thread as it was craeted.
66 bool m_wasTransferred = false;
67 // Keep a clone of the WebTaskRunner. This is to handle the case where the
68 // AcceleratedStaticBitmapImage was created on one thread and transferred to
69 // another thread, and the original thread gone out of scope, and that we need
70 // to clear the resouces associated with that AcceleratedStaticBitmapImage on
71 // the original thread.
72 std::unique_ptr<WebTaskRunner> m_textureThreadTaskRunner;
73 };
74
75 } // namespace blink
76
77 #endif // TextureHolder_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698