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

Side by Side Diff: cc/layers/texture_layer.h

Issue 23648014: cc: Move TextureMailbox::ReleaseCallback to SingleReleaseCallback. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: releasecallback: SingleReleaseCallback Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « cc/cc.gyp ('k') | cc/layers/texture_layer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 The Chromium Authors. All rights reserved. 1 // Copyright 2010 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 CC_LAYERS_TEXTURE_LAYER_H_ 5 #ifndef CC_LAYERS_TEXTURE_LAYER_H_
6 #define CC_LAYERS_TEXTURE_LAYER_H_ 6 #define CC_LAYERS_TEXTURE_LAYER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/synchronization/lock.h" 11 #include "base/synchronization/lock.h"
12 #include "cc/base/cc_export.h" 12 #include "cc/base/cc_export.h"
13 #include "cc/layers/layer.h" 13 #include "cc/layers/layer.h"
14 #include "cc/resources/texture_mailbox.h" 14 #include "cc/resources/texture_mailbox.h"
15 15
16 namespace WebKit { class WebGraphicsContext3D; } 16 namespace WebKit { class WebGraphicsContext3D; }
17 17
18 namespace cc { 18 namespace cc {
19 class BlockingTaskRunner; 19 class BlockingTaskRunner;
20 class SingleReleaseCallback;
20 class TextureLayerClient; 21 class TextureLayerClient;
21 22
22 // A Layer containing a the rendered output of a plugin instance. 23 // A Layer containing a the rendered output of a plugin instance.
23 class CC_EXPORT TextureLayer : public Layer { 24 class CC_EXPORT TextureLayer : public Layer {
24 public: 25 public:
25 class CC_EXPORT MailboxHolder 26 class CC_EXPORT MailboxHolder
26 : public base::RefCountedThreadSafe<MailboxHolder> { 27 : public base::RefCountedThreadSafe<MailboxHolder> {
27 public: 28 public:
28 class CC_EXPORT MainThreadReference { 29 class CC_EXPORT MainThreadReference {
29 public: 30 public:
30 explicit MainThreadReference(MailboxHolder* holder); 31 explicit MainThreadReference(MailboxHolder* holder);
31 ~MainThreadReference(); 32 ~MainThreadReference();
32 MailboxHolder* holder() { return holder_.get(); } 33 MailboxHolder* holder() { return holder_.get(); }
33 34
34 private: 35 private:
35 scoped_refptr<MailboxHolder> holder_; 36 scoped_refptr<MailboxHolder> holder_;
36 DISALLOW_COPY_AND_ASSIGN(MainThreadReference); 37 DISALLOW_COPY_AND_ASSIGN(MainThreadReference);
37 }; 38 };
38 39
39 const TextureMailbox& mailbox() const { return mailbox_; } 40 const TextureMailbox& mailbox() const { return mailbox_; }
40 void Return(unsigned sync_point, bool is_lost); 41 void Return(unsigned sync_point, bool is_lost);
41 42
42 // Gets a ReleaseCallback that can be called from another thread. Note: the 43 // Gets a ReleaseCallback that can be called from another thread. Note: the
43 // caller must ensure the callback is called. 44 // caller must ensure the callback is called.
44 TextureMailbox::ReleaseCallback GetCallbackForImplThread(); 45 scoped_ptr<SingleReleaseCallback> GetCallbackForImplThread();
45 46
46 protected: 47 protected:
47 friend class TextureLayer; 48 friend class TextureLayer;
48 49
49 // Protected visiblity so only TextureLayer and unit tests can create these. 50 // Protected visiblity so only TextureLayer and unit tests can create these.
50 static scoped_ptr<MainThreadReference> Create( 51 static scoped_ptr<MainThreadReference> Create(
51 const TextureMailbox& mailbox); 52 const TextureMailbox& mailbox,
53 scoped_ptr<SingleReleaseCallback> release_callback);
52 virtual ~MailboxHolder(); 54 virtual ~MailboxHolder();
53 55
54 private: 56 private:
55 friend class base::RefCountedThreadSafe<MailboxHolder>; 57 friend class base::RefCountedThreadSafe<MailboxHolder>;
56 friend class MainThreadReference; 58 friend class MainThreadReference;
57 explicit MailboxHolder(const TextureMailbox& mailbox); 59 explicit MailboxHolder(const TextureMailbox& mailbox,
60 scoped_ptr<SingleReleaseCallback> release_callback);
58 61
59 void InternalAddRef(); 62 void InternalAddRef();
60 void InternalRelease(); 63 void InternalRelease();
61 void ReturnAndReleaseOnImplThread(unsigned sync_point, bool is_lost); 64 void ReturnAndReleaseOnImplThread(unsigned sync_point, bool is_lost);
62 65
63 // This member is thread safe, and is accessed on main and impl threads. 66 // This member is thread safe, and is accessed on main and impl threads.
64 const scoped_refptr<BlockingTaskRunner> message_loop_; 67 const scoped_refptr<BlockingTaskRunner> message_loop_;
65 68
66 // These members are only accessed on the main thread, or on the impl thread 69 // These members are only accessed on the main thread, or on the impl thread
67 // during commit where the main thread is blocked. 70 // during commit where the main thread is blocked.
68 unsigned internal_references_; 71 unsigned internal_references_;
69 TextureMailbox mailbox_; 72 TextureMailbox mailbox_;
73 scoped_ptr<SingleReleaseCallback> release_callback_;
70 74
71 // This lock guards the sync_point_ and is_lost_ fields because they can be 75 // This lock guards the sync_point_ and is_lost_ fields because they can be
72 // accessed on both the impl and main thread. We do this to ensure that the 76 // accessed on both the impl and main thread. We do this to ensure that the
73 // values of these fields are well-ordered such that the last call to 77 // values of these fields are well-ordered such that the last call to
74 // ReturnAndReleaseOnImplThread() defines their values. 78 // ReturnAndReleaseOnImplThread() defines their values.
75 base::Lock arguments_lock_; 79 base::Lock arguments_lock_;
76 unsigned sync_point_; 80 unsigned sync_point_;
77 bool is_lost_; 81 bool is_lost_;
78 DISALLOW_COPY_AND_ASSIGN(MailboxHolder); 82 DISALLOW_COPY_AND_ASSIGN(MailboxHolder);
79 }; 83 };
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 // frames from being queued up before the compositor gets a chance to run. 122 // frames from being queued up before the compositor gets a chance to run.
119 // Requires a non-nil client. Defaults to false. 123 // Requires a non-nil client. Defaults to false.
120 void SetRateLimitContext(bool rate_limit); 124 void SetRateLimitContext(bool rate_limit);
121 125
122 // Code path for plugins which supply their own texture ID. 126 // Code path for plugins which supply their own texture ID.
123 // DEPRECATED. DO NOT USE. 127 // DEPRECATED. DO NOT USE.
124 void SetTextureId(unsigned texture_id); 128 void SetTextureId(unsigned texture_id);
125 129
126 // Code path for plugins which supply their own mailbox. 130 // Code path for plugins which supply their own mailbox.
127 bool uses_mailbox() const { return uses_mailbox_; } 131 bool uses_mailbox() const { return uses_mailbox_; }
128 void SetTextureMailbox(const TextureMailbox& mailbox); 132 void SetTextureMailbox(const TextureMailbox& mailbox,
133 scoped_ptr<SingleReleaseCallback> release_callback);
129 134
130 void WillModifyTexture(); 135 void WillModifyTexture();
131 136
132 virtual void SetNeedsDisplayRect(const gfx::RectF& dirty_rect) OVERRIDE; 137 virtual void SetNeedsDisplayRect(const gfx::RectF& dirty_rect) OVERRIDE;
133 138
134 virtual void SetLayerTreeHost(LayerTreeHost* layer_tree_host) OVERRIDE; 139 virtual void SetLayerTreeHost(LayerTreeHost* layer_tree_host) OVERRIDE;
135 virtual bool DrawsContent() const OVERRIDE; 140 virtual bool DrawsContent() const OVERRIDE;
136 virtual bool Update(ResourceUpdateQueue* queue, 141 virtual bool Update(ResourceUpdateQueue* queue,
137 const OcclusionTracker* occlusion) OVERRIDE; 142 const OcclusionTracker* occlusion) OVERRIDE;
138 virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE; 143 virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE;
(...skipping 21 matching lines...) Expand all
160 165
161 unsigned texture_id_; 166 unsigned texture_id_;
162 scoped_ptr<MailboxHolder::MainThreadReference> holder_ref_; 167 scoped_ptr<MailboxHolder::MainThreadReference> holder_ref_;
163 bool needs_set_mailbox_; 168 bool needs_set_mailbox_;
164 169
165 DISALLOW_COPY_AND_ASSIGN(TextureLayer); 170 DISALLOW_COPY_AND_ASSIGN(TextureLayer);
166 }; 171 };
167 172
168 } // namespace cc 173 } // namespace cc
169 #endif // CC_LAYERS_TEXTURE_LAYER_H_ 174 #endif // CC_LAYERS_TEXTURE_LAYER_H_
OLDNEW
« no previous file with comments | « cc/cc.gyp ('k') | cc/layers/texture_layer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698