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

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

Issue 485043003: cc: Use correct message loop proxy in BlockingTaskRunner (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Nits. Created 6 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/layers/delegated_renderer_layer.cc ('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 "base/threading/thread_checker.h"
12 #include "cc/base/cc_export.h" 13 #include "cc/base/cc_export.h"
13 #include "cc/layers/layer.h" 14 #include "cc/layers/layer.h"
14 #include "cc/resources/texture_mailbox.h" 15 #include "cc/resources/texture_mailbox.h"
15 16
16 namespace cc { 17 namespace cc {
17 class BlockingTaskRunner; 18 class BlockingTaskRunner;
18 class SingleReleaseCallback; 19 class SingleReleaseCallback;
20 class SingleReleaseCallbackImpl;
19 class TextureLayerClient; 21 class TextureLayerClient;
20 22
21 // A Layer containing a the rendered output of a plugin instance. 23 // A Layer containing a the rendered output of a plugin instance.
22 class CC_EXPORT TextureLayer : public Layer { 24 class CC_EXPORT TextureLayer : public Layer {
23 public: 25 public:
24 class CC_EXPORT TextureMailboxHolder 26 class CC_EXPORT TextureMailboxHolder
25 : public base::RefCountedThreadSafe<TextureMailboxHolder> { 27 : public base::RefCountedThreadSafe<TextureMailboxHolder> {
26 public: 28 public:
27 class CC_EXPORT MainThreadReference { 29 class CC_EXPORT MainThreadReference {
28 public: 30 public:
29 explicit MainThreadReference(TextureMailboxHolder* holder); 31 explicit MainThreadReference(TextureMailboxHolder* holder);
30 ~MainThreadReference(); 32 ~MainThreadReference();
31 TextureMailboxHolder* holder() { return holder_.get(); } 33 TextureMailboxHolder* holder() { return holder_.get(); }
32 34
33 private: 35 private:
34 scoped_refptr<TextureMailboxHolder> holder_; 36 scoped_refptr<TextureMailboxHolder> holder_;
35 DISALLOW_COPY_AND_ASSIGN(MainThreadReference); 37 DISALLOW_COPY_AND_ASSIGN(MainThreadReference);
36 }; 38 };
37 39
38 const TextureMailbox& mailbox() const { return mailbox_; } 40 const TextureMailbox& mailbox() const { return mailbox_; }
39 void Return(uint32 sync_point, bool is_lost); 41 void Return(uint32 sync_point, bool is_lost);
40 42
41 // 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
42 // caller must ensure the callback is called. 44 // caller must ensure the callback is called.
43 scoped_ptr<SingleReleaseCallback> GetCallbackForImplThread(); 45 scoped_ptr<SingleReleaseCallbackImpl> GetCallbackForImplThread();
44 46
45 protected: 47 protected:
46 friend class TextureLayer; 48 friend class TextureLayer;
47 49
48 // Protected visiblity so only TextureLayer and unit tests can create these. 50 // Protected visiblity so only TextureLayer and unit tests can create these.
49 static scoped_ptr<MainThreadReference> Create( 51 static scoped_ptr<MainThreadReference> Create(
50 const TextureMailbox& mailbox, 52 const TextureMailbox& mailbox,
51 scoped_ptr<SingleReleaseCallback> release_callback); 53 scoped_ptr<SingleReleaseCallback> release_callback);
52 virtual ~TextureMailboxHolder(); 54 virtual ~TextureMailboxHolder();
53 55
54 private: 56 private:
55 friend class base::RefCountedThreadSafe<TextureMailboxHolder>; 57 friend class base::RefCountedThreadSafe<TextureMailboxHolder>;
56 friend class MainThreadReference; 58 friend class MainThreadReference;
57 explicit TextureMailboxHolder( 59 explicit TextureMailboxHolder(
58 const TextureMailbox& mailbox, 60 const TextureMailbox& mailbox,
59 scoped_ptr<SingleReleaseCallback> release_callback); 61 scoped_ptr<SingleReleaseCallback> release_callback);
60 62
61 void InternalAddRef(); 63 void InternalAddRef();
62 void InternalRelease(); 64 void InternalRelease();
63 void ReturnAndReleaseOnImplThread(uint32 sync_point, bool is_lost); 65 void ReturnAndReleaseOnImplThread(
64 66 uint32 sync_point,
65 // This member is thread safe, and is accessed on main and impl threads. 67 bool is_lost,
66 const scoped_refptr<BlockingTaskRunner> message_loop_; 68 BlockingTaskRunner* main_thread_task_runner);
67 69
68 // These members are only accessed on the main thread, or on the impl thread 70 // These members are only accessed on the main thread, or on the impl thread
69 // during commit where the main thread is blocked. 71 // during commit where the main thread is blocked.
70 unsigned internal_references_; 72 unsigned internal_references_;
71 TextureMailbox mailbox_; 73 TextureMailbox mailbox_;
72 scoped_ptr<SingleReleaseCallback> release_callback_; 74 scoped_ptr<SingleReleaseCallback> release_callback_;
73 75
74 // This lock guards the sync_point_ and is_lost_ fields because they can be 76 // This lock guards the sync_point_ and is_lost_ fields because they can be
75 // accessed on both the impl and main thread. We do this to ensure that the 77 // accessed on both the impl and main thread. We do this to ensure that the
76 // values of these fields are well-ordered such that the last call to 78 // values of these fields are well-ordered such that the last call to
77 // ReturnAndReleaseOnImplThread() defines their values. 79 // ReturnAndReleaseOnImplThread() defines their values.
78 base::Lock arguments_lock_; 80 base::Lock arguments_lock_;
79 uint32 sync_point_; 81 uint32 sync_point_;
80 bool is_lost_; 82 bool is_lost_;
83 base::ThreadChecker main_thread_checker_;
81 DISALLOW_COPY_AND_ASSIGN(TextureMailboxHolder); 84 DISALLOW_COPY_AND_ASSIGN(TextureMailboxHolder);
82 }; 85 };
83 86
84 // Used when mailbox names are specified instead of texture IDs. 87 // Used when mailbox names are specified instead of texture IDs.
85 static scoped_refptr<TextureLayer> CreateForMailbox( 88 static scoped_refptr<TextureLayer> CreateForMailbox(
86 TextureLayerClient* client); 89 TextureLayerClient* client);
87 90
88 // Resets the client, which also resets the texture. 91 // Resets the client, which also resets the texture.
89 void ClearClient(); 92 void ClearClient();
90 93
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 bool rate_limit_context_; 166 bool rate_limit_context_;
164 167
165 scoped_ptr<TextureMailboxHolder::MainThreadReference> holder_ref_; 168 scoped_ptr<TextureMailboxHolder::MainThreadReference> holder_ref_;
166 bool needs_set_mailbox_; 169 bool needs_set_mailbox_;
167 170
168 DISALLOW_COPY_AND_ASSIGN(TextureLayer); 171 DISALLOW_COPY_AND_ASSIGN(TextureLayer);
169 }; 172 };
170 173
171 } // namespace cc 174 } // namespace cc
172 #endif // CC_LAYERS_TEXTURE_LAYER_H_ 175 #endif // CC_LAYERS_TEXTURE_LAYER_H_
OLDNEW
« no previous file with comments | « cc/layers/delegated_renderer_layer.cc ('k') | cc/layers/texture_layer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698