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

Side by Side Diff: webkit/compositor_bindings/web_external_texture_layer_impl.cc

Issue 12374028: Allow WebExternalTextureLayerClient to work with mailboxes. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase Created 7 years, 8 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
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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 #include "webkit/compositor_bindings/web_external_texture_layer_impl.h" 5 #include "webkit/compositor_bindings/web_external_texture_layer_impl.h"
6 6
7 #include "cc/layers/texture_layer.h" 7 #include "cc/layers/texture_layer.h"
8 #include "cc/resources/resource_update_queue.h" 8 #include "cc/resources/resource_update_queue.h"
9 #include "third_party/WebKit/Source/Platform/chromium/public/WebExternalTextureL ayerClient.h" 9 #include "third_party/WebKit/Source/Platform/chromium/public/WebExternalTextureL ayerClient.h"
10 #include "third_party/WebKit/Source/Platform/chromium/public/WebExternalTextureM ailbox.h"
10 #include "third_party/WebKit/Source/Platform/chromium/public/WebFloatRect.h" 11 #include "third_party/WebKit/Source/Platform/chromium/public/WebFloatRect.h"
11 #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h" 12 #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h"
12 #include "webkit/compositor_bindings/web_layer_impl.h" 13 #include "webkit/compositor_bindings/web_layer_impl.h"
13 14
14 using cc::TextureLayer; 15 using cc::TextureLayer;
15 using cc::ResourceUpdateQueue; 16 using cc::ResourceUpdateQueue;
16 17
17 namespace webkit { 18 namespace webkit {
18 19
19 WebExternalTextureLayerImpl::WebExternalTextureLayerImpl( 20 WebExternalTextureLayerImpl::WebExternalTextureLayerImpl(
20 WebKit::WebExternalTextureLayerClient* client) 21 WebKit::WebExternalTextureLayerClient* client,
21 : client_(client) { 22 bool mailbox)
23 : client_(client),
24 uses_mailbox_(mailbox) {
22 scoped_refptr<TextureLayer> layer; 25 scoped_refptr<TextureLayer> layer;
23 if (client_) 26 cc::TextureLayerClient* cc_client = client_ ? this : NULL;
24 layer = TextureLayer::Create(this); 27 if (mailbox)
28 layer = TextureLayer::CreateForMailbox(cc_client);
25 else 29 else
26 layer = TextureLayer::Create(NULL); 30 layer = TextureLayer::Create(cc_client);
27 layer->SetIsDrawable(true); 31 layer->SetIsDrawable(true);
28 layer_.reset(new WebLayerImpl(layer)); 32 layer_.reset(new WebLayerImpl(layer));
29 } 33 }
30 34
31 WebExternalTextureLayerImpl::~WebExternalTextureLayerImpl() { 35 WebExternalTextureLayerImpl::~WebExternalTextureLayerImpl() {
32 static_cast<TextureLayer*>(layer_->layer())->ClearClient(); 36 static_cast<TextureLayer*>(layer_->layer())->ClearClient();
33 } 37 }
34 38
35 WebKit::WebLayer* WebExternalTextureLayerImpl::layer() { return layer_.get(); } 39 WebKit::WebLayer* WebExternalTextureLayerImpl::layer() { return layer_.get(); }
36 40
41 void WebExternalTextureLayerImpl::clearTexture() {
42 if (uses_mailbox_) {
43 static_cast<TextureLayer*>(layer_->layer())->SetTextureMailbox(
44 cc::TextureMailbox());
45 } else {
46 static_cast<TextureLayer*>(layer_->layer())->SetTextureId(0);
47 }
48 }
49
37 void WebExternalTextureLayerImpl::setTextureId(unsigned id) { 50 void WebExternalTextureLayerImpl::setTextureId(unsigned id) {
38 static_cast<TextureLayer*>(layer_->layer())->SetTextureId(id); 51 static_cast<TextureLayer*>(layer_->layer())->SetTextureId(id);
39 } 52 }
40 53
41 void WebExternalTextureLayerImpl::setFlipped(bool flipped) { 54 void WebExternalTextureLayerImpl::setFlipped(bool flipped) {
42 static_cast<TextureLayer*>(layer_->layer())->SetFlipped(flipped); 55 static_cast<TextureLayer*>(layer_->layer())->SetFlipped(flipped);
43 } 56 }
44 57
45 void WebExternalTextureLayerImpl::setUVRect(const WebKit::WebFloatRect& rect) { 58 void WebExternalTextureLayerImpl::setUVRect(const WebKit::WebFloatRect& rect) {
46 static_cast<TextureLayer*>(layer_->layer())->SetUV( 59 static_cast<TextureLayer*>(layer_->layer())->SetUV(
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 DCHECK(client_); 100 DCHECK(client_);
88 WebTextureUpdaterImpl updater_impl(queue); 101 WebTextureUpdaterImpl updater_impl(queue);
89 return client_->prepareTexture(updater_impl); 102 return client_->prepareTexture(updater_impl);
90 } 103 }
91 104
92 WebKit::WebGraphicsContext3D* WebExternalTextureLayerImpl::Context3d() { 105 WebKit::WebGraphicsContext3D* WebExternalTextureLayerImpl::Context3d() {
93 DCHECK(client_); 106 DCHECK(client_);
94 return client_->context(); 107 return client_->context();
95 } 108 }
96 109
97 } // namespace webkit 110 bool WebExternalTextureLayerImpl::PrepareTextureMailbox(
111 cc::TextureMailbox* out_mailbox) {
112 WebKit::WebExternalTextureMailbox mailbox;
113 if (!client_->prepareMailbox(&mailbox)) {
114 return false;
115 }
116 gpu::Mailbox name;
117 name.SetName(mailbox.name);
118 cc::TextureMailbox::ReleaseCallback callback =
119 base::Bind(&WebExternalTextureLayerImpl::mailboxReleased,
120 this->AsWeakPtr(),
121 mailbox);
122 *out_mailbox = cc::TextureMailbox(name, callback, mailbox.syncPoint);
123 return true;
124 }
125
126 void WebExternalTextureLayerImpl::mailboxReleased(
127 const WebKit::WebExternalTextureMailbox &mailbox,
jamesr 2013/04/11 17:36:58 & goes with the type, not the variable name
alexst (slow to review) 2013/04/11 18:03:12 Done.
128 unsigned sync_point,
129 bool lost_resource) {
130 if (lost_resource)
jamesr 2013/04/11 17:36:58 why is the callback invoked with lost_resource=tru
alexst (slow to review) 2013/04/11 18:03:12 In this case, lost resources are already handled i
131 return;
132
133 WebKit::WebExternalTextureMailbox available_mailbox;
134 memcpy(available_mailbox.name, mailbox.name, sizeof(available_mailbox.name));
135 available_mailbox.syncPoint = sync_point;
136 client_->mailboxReleased(available_mailbox);
137 }
138
139 } // namespace webkit
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698