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

Side by Side Diff: content/renderer/pepper/pepper_compositor_host.cc

Issue 1122393003: CC: Plumb LayerSettings parameter for cc::Layer construction. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 7 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/renderer/pepper/pepper_compositor_host.h" 5 #include "content/renderer/pepper/pepper_compositor_host.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/shared_memory.h" 10 #include "base/memory/shared_memory.h"
11 #include "cc/blink/web_layer_impl.h"
11 #include "cc/layers/layer.h" 12 #include "cc/layers/layer.h"
12 #include "cc/layers/solid_color_layer.h" 13 #include "cc/layers/solid_color_layer.h"
13 #include "cc/layers/texture_layer.h" 14 #include "cc/layers/texture_layer.h"
14 #include "cc/resources/texture_mailbox.h" 15 #include "cc/resources/texture_mailbox.h"
15 #include "cc/trees/layer_tree_host.h" 16 #include "cc/trees/layer_tree_host.h"
16 #include "content/child/child_shared_bitmap_manager.h" 17 #include "content/child/child_shared_bitmap_manager.h"
17 #include "content/child/child_thread_impl.h" 18 #include "content/child/child_thread_impl.h"
18 #include "content/public/renderer/renderer_ppapi_host.h" 19 #include "content/public/renderer/renderer_ppapi_host.h"
19 #include "content/renderer/pepper/gfx_conversion.h" 20 #include "content/renderer/pepper/gfx_conversion.h"
20 #include "content/renderer/pepper/host_globals.h" 21 #include "content/renderer/pepper/host_globals.h"
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 154
154 PepperCompositorHost::LayerData::~LayerData() {} 155 PepperCompositorHost::LayerData::~LayerData() {}
155 156
156 PepperCompositorHost::PepperCompositorHost( 157 PepperCompositorHost::PepperCompositorHost(
157 RendererPpapiHost* host, 158 RendererPpapiHost* host,
158 PP_Instance instance, 159 PP_Instance instance,
159 PP_Resource resource) 160 PP_Resource resource)
160 : ResourceHost(host->GetPpapiHost(), instance, resource), 161 : ResourceHost(host->GetPpapiHost(), instance, resource),
161 bound_instance_(NULL), 162 bound_instance_(NULL),
162 weak_factory_(this) { 163 weak_factory_(this) {
163 layer_ = cc::Layer::Create(); 164 layer_ = cc::Layer::Create(cc_blink::WebLayerImpl::LayerSettings());
164 // TODO(penghuang): SetMasksToBounds() can be expensive if the layer is 165 // TODO(penghuang): SetMasksToBounds() can be expensive if the layer is
165 // transformed. Possibly better could be to explicitly clip the child layers 166 // transformed. Possibly better could be to explicitly clip the child layers
166 // (by modifying their bounds). 167 // (by modifying their bounds).
167 layer_->SetMasksToBounds(true); 168 layer_->SetMasksToBounds(true);
168 layer_->SetIsDrawable(true); 169 layer_->SetIsDrawable(true);
169 } 170 }
170 171
171 PepperCompositorHost::~PepperCompositorHost() { 172 PepperCompositorHost::~PepperCompositorHost() {
172 // Unbind from the instance when destroyed if we're still bound. 173 // Unbind from the instance when destroyed if we're still bound.
173 if (bound_instance_) 174 if (bound_instance_)
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 layer->SetTransform(transform); 241 layer->SetTransform(transform);
241 242
242 // Consider a (0,0,0,0) rect as no clip rect. 243 // Consider a (0,0,0,0) rect as no clip rect.
243 if (new_layer->common.clip_rect.point.x != 0 || 244 if (new_layer->common.clip_rect.point.x != 0 ||
244 new_layer->common.clip_rect.point.y != 0 || 245 new_layer->common.clip_rect.point.y != 0 ||
245 new_layer->common.clip_rect.size.width != 0 || 246 new_layer->common.clip_rect.size.width != 0 ||
246 new_layer->common.clip_rect.size.height != 0) { 247 new_layer->common.clip_rect.size.height != 0) {
247 scoped_refptr<cc::Layer> clip_parent = layer->parent(); 248 scoped_refptr<cc::Layer> clip_parent = layer->parent();
248 if (clip_parent.get() == layer_.get()) { 249 if (clip_parent.get() == layer_.get()) {
249 // Create a clip parent layer, if it does not exist. 250 // Create a clip parent layer, if it does not exist.
250 clip_parent = cc::Layer::Create(); 251 clip_parent = cc::Layer::Create(cc_blink::WebLayerImpl::LayerSettings());
251 clip_parent->SetMasksToBounds(true); 252 clip_parent->SetMasksToBounds(true);
252 clip_parent->SetIsDrawable(true); 253 clip_parent->SetIsDrawable(true);
253 layer_->ReplaceChild(layer.get(), clip_parent); 254 layer_->ReplaceChild(layer.get(), clip_parent);
254 clip_parent->AddChild(layer); 255 clip_parent->AddChild(layer);
255 } 256 }
256 gfx::Point position = PP_ToGfxPoint(new_layer->common.clip_rect.point); 257 gfx::Point position = PP_ToGfxPoint(new_layer->common.clip_rect.point);
257 clip_parent->SetPosition(position); 258 clip_parent->SetPosition(position);
258 clip_parent->SetBounds(PP_ToGfxSize(new_layer->common.clip_rect.size)); 259 clip_parent->SetBounds(PP_ToGfxSize(new_layer->common.clip_rect.size));
259 layer->SetPosition(gfx::Point(-position.x(), -position.y())); 260 layer->SetPosition(gfx::Point(-position.x(), -position.y()));
260 } else if (layer->parent() != layer_.get()) { 261 } else if (layer->parent() != layer_.get()) {
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 383
383 for (size_t i = 0; i < layers.size(); ++i) { 384 for (size_t i = 0; i < layers.size(); ++i) {
384 const ppapi::CompositorLayerData* pp_layer = &layers[i]; 385 const ppapi::CompositorLayerData* pp_layer = &layers[i];
385 LayerData* data = i >= layers_.size() ? NULL : &layers_[i]; 386 LayerData* data = i >= layers_.size() ? NULL : &layers_[i];
386 DCHECK(!data || data->cc_layer.get()); 387 DCHECK(!data || data->cc_layer.get());
387 scoped_refptr<cc::Layer> cc_layer = data ? data->cc_layer : NULL; 388 scoped_refptr<cc::Layer> cc_layer = data ? data->cc_layer : NULL;
388 ppapi::CompositorLayerData* old_layer = data ? &data->pp_layer : NULL; 389 ppapi::CompositorLayerData* old_layer = data ? &data->pp_layer : NULL;
389 390
390 if (!cc_layer.get()) { 391 if (!cc_layer.get()) {
391 if (pp_layer->color) 392 if (pp_layer->color)
392 cc_layer = cc::SolidColorLayer::Create(); 393 cc_layer = cc::SolidColorLayer::Create(
394 cc_blink::WebLayerImpl::LayerSettings());
393 else if (pp_layer->texture || pp_layer->image) 395 else if (pp_layer->texture || pp_layer->image)
394 cc_layer = cc::TextureLayer::CreateForMailbox(NULL); 396 cc_layer = cc::TextureLayer::CreateForMailbox(
397 cc_blink::WebLayerImpl::LayerSettings(), NULL);
395 layer_->AddChild(cc_layer); 398 layer_->AddChild(cc_layer);
396 } 399 }
397 400
398 UpdateLayer(cc_layer, old_layer, pp_layer, image_shms[i].Pass()); 401 UpdateLayer(cc_layer, old_layer, pp_layer, image_shms[i].Pass());
399 402
400 if (old_layer) 403 if (old_layer)
401 *old_layer = *pp_layer; 404 *old_layer = *pp_layer;
402 else 405 else
403 layers_.push_back(LayerData(cc_layer, *pp_layer)); 406 layers_.push_back(LayerData(cc_layer, *pp_layer));
404 } 407 }
405 408
406 // We need to force a commit for each CommitLayers() call, even if no layers 409 // We need to force a commit for each CommitLayers() call, even if no layers
407 // changed since the last call to CommitLayers(). This is so 410 // changed since the last call to CommitLayers(). This is so
408 // WiewInitiatedPaint() will always be called. 411 // WiewInitiatedPaint() will always be called.
409 if (layer_->layer_tree_host()) 412 if (layer_->layer_tree_host())
410 layer_->layer_tree_host()->SetNeedsCommit(); 413 layer_->layer_tree_host()->SetNeedsCommit();
411 414
412 // If the host is not bound to the instance, return PP_OK immediately. 415 // If the host is not bound to the instance, return PP_OK immediately.
413 if (!bound_instance_) 416 if (!bound_instance_)
414 return PP_OK; 417 return PP_OK;
415 418
416 commit_layers_reply_context_ = context->MakeReplyMessageContext(); 419 commit_layers_reply_context_ = context->MakeReplyMessageContext();
417 return PP_OK_COMPLETIONPENDING; 420 return PP_OK_COMPLETIONPENDING;
418 } 421 }
419 422
420 } // namespace content 423 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/npapi/webplugin_impl.cc ('k') | content/renderer/pepper/pepper_plugin_instance_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698