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

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

Issue 16888015: Reland r206537 - cc: Don't return mailboxes if the TextureLayer is removed from the tree. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nits Created 7 years, 6 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 | « no previous file | 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 "cc/base/cc_export.h" 11 #include "cc/base/cc_export.h"
12 #include "cc/layers/layer.h" 12 #include "cc/layers/layer.h"
13 #include "cc/resources/texture_mailbox.h" 13 #include "cc/resources/texture_mailbox.h"
14 14
15 namespace WebKit { class WebGraphicsContext3D; } 15 namespace WebKit { class WebGraphicsContext3D; }
16 16
17 namespace base {
18 class MessageLoopProxy;
19 }
20
17 namespace cc { 21 namespace cc {
18 22
19 class TextureLayerClient; 23 class TextureLayerClient;
20 24
21 // A Layer containing a the rendered output of a plugin instance. 25 // A Layer containing a the rendered output of a plugin instance.
22 class CC_EXPORT TextureLayer : public Layer { 26 class CC_EXPORT TextureLayer : public Layer {
23 public: 27 public:
24 // If this texture layer requires special preparation logic for each frame 28 // If this texture layer requires special preparation logic for each frame
25 // driven by the compositor, pass in a non-nil client. Pass in a nil client 29 // driven by the compositor, pass in a non-nil client. Pass in a nil client
26 // pointer if texture updates are driven by an external process. 30 // pointer if texture updates are driven by an external process.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE; 81 virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE;
78 virtual bool BlocksPendingCommit() const OVERRIDE; 82 virtual bool BlocksPendingCommit() const OVERRIDE;
79 83
80 virtual bool CanClipSelf() const OVERRIDE; 84 virtual bool CanClipSelf() const OVERRIDE;
81 85
82 protected: 86 protected:
83 TextureLayer(TextureLayerClient* client, bool uses_mailbox); 87 TextureLayer(TextureLayerClient* client, bool uses_mailbox);
84 virtual ~TextureLayer(); 88 virtual ~TextureLayer();
85 89
86 private: 90 private:
91 class MailboxHolder : public base::RefCountedThreadSafe<MailboxHolder> {
92 public:
93 class MainThreadReference {
94 public:
95 explicit MainThreadReference(MailboxHolder* holder);
96 ~MainThreadReference();
97 MailboxHolder* holder() { return holder_; }
98
99 private:
100 scoped_refptr<MailboxHolder> holder_;
101 DISALLOW_COPY_AND_ASSIGN(MainThreadReference);
102 };
103
104 static scoped_ptr<MainThreadReference> Create(
105 const TextureMailbox& mailbox);
106
107 const TextureMailbox& mailbox() const { return mailbox_; }
108 void Return(unsigned sync_point, bool is_lost);
109
110 // Gets a ReleaseCallback that can be called from another thread. Note: the
111 // caller must ensure the callback is called.
112 TextureMailbox::ReleaseCallback GetCallbackForImplThread();
113
114 private:
115 friend class base::RefCountedThreadSafe<MailboxHolder>;
116 friend class MainThreadReference;
117 explicit MailboxHolder(const TextureMailbox& mailbox);
118 ~MailboxHolder();
119 void InternalAddRef();
120 void InternalRelease();
121 void ReturnAndReleaseOnMainThread(unsigned sync_point, bool is_lost);
122 void ReturnAndReleaseOnImplThread(unsigned sync_point, bool is_lost);
123
124 // Thread safety notes: except for the thread-safe message_loop_, all fields
125 // are only used on the main thread, or on the impl thread during commit
126 // where the main thread is blocked.
127 const scoped_refptr<base::MessageLoopProxy> message_loop_;
128 unsigned internal_references_;
129 TextureMailbox mailbox_;
130 unsigned sync_point_;
131 bool is_lost_;
132 DISALLOW_COPY_AND_ASSIGN(MailboxHolder);
133 };
134
87 TextureLayerClient* client_; 135 TextureLayerClient* client_;
88 bool uses_mailbox_; 136 bool uses_mailbox_;
89 137
90 bool flipped_; 138 bool flipped_;
91 gfx::PointF uv_top_left_; 139 gfx::PointF uv_top_left_;
92 gfx::PointF uv_bottom_right_; 140 gfx::PointF uv_bottom_right_;
93 // [bottom left, top left, top right, bottom right] 141 // [bottom left, top left, top right, bottom right]
94 float vertex_opacity_[4]; 142 float vertex_opacity_[4];
95 bool premultiplied_alpha_; 143 bool premultiplied_alpha_;
96 bool rate_limit_context_; 144 bool rate_limit_context_;
97 bool context_lost_; 145 bool context_lost_;
98 bool content_committed_; 146 bool content_committed_;
99 147
100 unsigned texture_id_; 148 unsigned texture_id_;
101 TextureMailbox texture_mailbox_; 149 scoped_ptr<MailboxHolder::MainThreadReference> holder_ref_;
102 bool own_mailbox_; 150 bool needs_set_mailbox_;
103 151
104 DISALLOW_COPY_AND_ASSIGN(TextureLayer); 152 DISALLOW_COPY_AND_ASSIGN(TextureLayer);
105 }; 153 };
106 154
107 } // namespace cc 155 } // namespace cc
108 #endif // CC_LAYERS_TEXTURE_LAYER_H_ 156 #endif // CC_LAYERS_TEXTURE_LAYER_H_
OLDNEW
« no previous file with comments | « no previous file | cc/layers/texture_layer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698