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

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

Issue 2455983005: Refactor AcceleratedStaticBitmapImage (Closed)
Patch Set: No long keep WeakPtr<DrawingBuffer> 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 WebThread;
20
21 class PLATFORM_EXPORT TextureHolder {
22 public:
23 virtual ~TextureHolder() {}
24
25 // Methods overrided by all sub-classes
26 virtual bool isSkiaTextureHolder() = 0;
27 virtual bool isMailboxTextureHolder() = 0;
28 virtual unsigned sharedContextId() = 0;
29 virtual IntSize size() const = 0;
30 virtual bool currentFrameKnownToBeOpaque(Image::MetadataMode) = 0;
31
32 // Methods overrided by MailboxTextureHolder
33 virtual gpu::Mailbox mailbox() {
34 NOTREACHED();
35 return gpu::Mailbox();
36 }
37 virtual gpu::SyncToken syncToken() {
38 NOTREACHED();
39 return gpu::SyncToken();
40 }
41 virtual void updateSyncToken(gpu::SyncToken) { NOTREACHED(); }
42
43 // Methods overrided by SkiaTextureHolder
44 virtual sk_sp<SkImage> skImage() {
45 NOTREACHED();
46 return nullptr;
47 }
48 virtual void setSharedContextId(unsigned) { NOTREACHED(); }
49 virtual void setImageThread(WebThread*) { NOTREACHED(); }
50 virtual void setImageThreadTaskRunner(std::unique_ptr<WebTaskRunner>) {
51 NOTREACHED();
52 }
53
54 // Methods that have exactly the same impelmentation for all sub-classes
55 WebThread* textureThread() { return m_textureThreadDoNotCall; }
Justin Novosad 2016/11/08 19:38:54 This is never called, but it should be. make the d
xidachen 2016/11/08 20:30:58 Done.
56 void setTextureThread(WebThread* thread) {
57 m_textureThreadDoNotCall = thread;
Justin Novosad 2016/11/08 19:38:54 The only thing we ever do with this value, as far
xidachen 2016/11/08 20:30:58 Done.
58 }
59 void setTextureThreadTaskRunner(std::unique_ptr<WebTaskRunner> taskRunner) {
60 m_textureThreadTaskRunner = std::move(taskRunner);
61 }
62
63 protected:
64 // Thread that |m_texture| in the AcceleratedStaticBitmapImage belongs to. Set
65 // to null when |m_texture| belongs to the same thread as the
66 // AcceleratedStaticBitmapImage. Should only be non-null after a transfer.
67 // VERY IMPORTANT: Used for pointer comparisons only. DO NOT call any of its
68 // API because that would potentially CRASH.
69 WebThread* m_textureThreadDoNotCall = nullptr;
70 // Keep a clone of the WebTaskRunner for m_textureThread. This is to handle
71 // the case where |m_textureThread| goes out of scope, and we still need to
72 // use
73 // the WebTaskRunner for the |m_textureThread|.
74 std::unique_ptr<WebTaskRunner> m_textureThreadTaskRunner;
75 };
76
77 } // namespace blink
78
79 #endif // TextureHolder_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698