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

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

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

Powered by Google App Engine
This is Rietveld 408576698