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

Side by Side Diff: ui/compositor/layer.cc

Issue 417943004: Use Surfaces to hold delegated renderer contents. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 | « ui/compositor/layer.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/compositor/layer.h" 5 #include "ui/compositor/layer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
11 #include "base/json/json_writer.h" 11 #include "base/json/json_writer.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "cc/base/scoped_ptr_algorithm.h" 14 #include "cc/base/scoped_ptr_algorithm.h"
15 #include "cc/layers/content_layer.h" 15 #include "cc/layers/content_layer.h"
16 #include "cc/layers/delegated_renderer_layer.h" 16 #include "cc/layers/delegated_renderer_layer.h"
17 #include "cc/layers/nine_patch_layer.h" 17 #include "cc/layers/nine_patch_layer.h"
18 #include "cc/layers/picture_layer.h" 18 #include "cc/layers/picture_layer.h"
19 #include "cc/layers/solid_color_layer.h" 19 #include "cc/layers/solid_color_layer.h"
20 #include "cc/layers/surface_layer.h"
20 #include "cc/layers/texture_layer.h" 21 #include "cc/layers/texture_layer.h"
21 #include "cc/output/copy_output_request.h" 22 #include "cc/output/copy_output_request.h"
22 #include "cc/output/delegated_frame_data.h" 23 #include "cc/output/delegated_frame_data.h"
23 #include "cc/output/filter_operation.h" 24 #include "cc/output/filter_operation.h"
24 #include "cc/output/filter_operations.h" 25 #include "cc/output/filter_operations.h"
25 #include "cc/resources/transferable_resource.h" 26 #include "cc/resources/transferable_resource.h"
26 #include "ui/compositor/compositor_switches.h" 27 #include "ui/compositor/compositor_switches.h"
27 #include "ui/compositor/dip_util.h" 28 #include "ui/compositor/dip_util.h"
28 #include "ui/compositor/layer_animator.h" 29 #include "ui/compositor/layer_animator.h"
29 #include "ui/gfx/animation/animation.h" 30 #include "ui/gfx/animation/animation.h"
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 cc_layer_->RemoveLayerAnimationEventObserver(this); 490 cc_layer_->RemoveLayerAnimationEventObserver(this);
490 new_layer->SetOpacity(cc_layer_->opacity()); 491 new_layer->SetOpacity(cc_layer_->opacity());
491 new_layer->SetTransform(cc_layer_->transform()); 492 new_layer->SetTransform(cc_layer_->transform());
492 new_layer->SetPosition(cc_layer_->position()); 493 new_layer->SetPosition(cc_layer_->position());
493 494
494 cc_layer_ = new_layer.get(); 495 cc_layer_ = new_layer.get();
495 content_layer_ = NULL; 496 content_layer_ = NULL;
496 solid_color_layer_ = NULL; 497 solid_color_layer_ = NULL;
497 texture_layer_ = NULL; 498 texture_layer_ = NULL;
498 delegated_renderer_layer_ = NULL; 499 delegated_renderer_layer_ = NULL;
500 surface_layer_ = NULL;
499 501
500 cc_layer_->AddLayerAnimationEventObserver(this); 502 cc_layer_->AddLayerAnimationEventObserver(this);
501 for (size_t i = 0; i < children_.size(); ++i) { 503 for (size_t i = 0; i < children_.size(); ++i) {
502 DCHECK(children_[i]->cc_layer_); 504 DCHECK(children_[i]->cc_layer_);
503 cc_layer_->AddChild(children_[i]->cc_layer_); 505 cc_layer_->AddChild(children_[i]->cc_layer_);
504 } 506 }
505 cc_layer_->SetLayerClient(this); 507 cc_layer_->SetLayerClient(this);
506 cc_layer_->SetTransformOrigin(gfx::Point3F()); 508 cc_layer_->SetTransformOrigin(gfx::Point3F());
507 cc_layer_->SetContentsOpaque(fills_bounds_opaquely_); 509 cc_layer_->SetContentsOpaque(fills_bounds_opaquely_);
508 cc_layer_->SetForceRenderSurface(force_render_surface_); 510 cc_layer_->SetForceRenderSurface(force_render_surface_);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 559
558 scoped_refptr<cc::DelegatedRendererLayer> new_layer = 560 scoped_refptr<cc::DelegatedRendererLayer> new_layer =
559 cc::DelegatedRendererLayer::Create(frame_provider); 561 cc::DelegatedRendererLayer::Create(frame_provider);
560 SwitchToLayer(new_layer); 562 SwitchToLayer(new_layer);
561 delegated_renderer_layer_ = new_layer; 563 delegated_renderer_layer_ = new_layer;
562 564
563 frame_size_in_dip_ = frame_size_in_dip; 565 frame_size_in_dip_ = frame_size_in_dip;
564 RecomputeDrawsContentAndUVRect(); 566 RecomputeDrawsContentAndUVRect();
565 } 567 }
566 568
569 void Layer::SetShowSurface(cc::SurfaceId id, gfx::Size frame_size_in_dip) {
570 DCHECK_EQ(type_, LAYER_TEXTURED);
571
572 scoped_refptr<cc::SurfaceLayer> new_layer = cc::SurfaceLayer::Create();
573 new_layer->SetSurfaceId(id);
574 SwitchToLayer(new_layer);
575 surface_layer_ = new_layer;
576
577 frame_size_in_dip_ = frame_size_in_dip;
578 RecomputeDrawsContentAndUVRect();
579 }
580
567 void Layer::SetShowPaintedContent() { 581 void Layer::SetShowPaintedContent() {
568 if (content_layer_.get()) 582 if (content_layer_.get())
569 return; 583 return;
570 584
571 scoped_refptr<cc::Layer> new_layer; 585 scoped_refptr<cc::Layer> new_layer;
572 if (Layer::UsingPictureLayer()) 586 if (Layer::UsingPictureLayer())
573 new_layer = cc::PictureLayer::Create(this); 587 new_layer = cc::PictureLayer::Create(this);
574 else 588 else
575 new_layer = cc::ContentLayer::Create(this); 589 new_layer = cc::ContentLayer::Create(this);
576 SwitchToLayer(new_layer); 590 SwitchToLayer(new_layer);
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
975 void Layer::RecomputeDrawsContentAndUVRect() { 989 void Layer::RecomputeDrawsContentAndUVRect() {
976 DCHECK(cc_layer_); 990 DCHECK(cc_layer_);
977 gfx::Size size(bounds_.size()); 991 gfx::Size size(bounds_.size());
978 if (texture_layer_.get()) { 992 if (texture_layer_.get()) {
979 size.SetToMin(frame_size_in_dip_); 993 size.SetToMin(frame_size_in_dip_);
980 gfx::PointF uv_top_left(0.f, 0.f); 994 gfx::PointF uv_top_left(0.f, 0.f);
981 gfx::PointF uv_bottom_right( 995 gfx::PointF uv_bottom_right(
982 static_cast<float>(size.width()) / frame_size_in_dip_.width(), 996 static_cast<float>(size.width()) / frame_size_in_dip_.width(),
983 static_cast<float>(size.height()) / frame_size_in_dip_.height()); 997 static_cast<float>(size.height()) / frame_size_in_dip_.height());
984 texture_layer_->SetUV(uv_top_left, uv_bottom_right); 998 texture_layer_->SetUV(uv_top_left, uv_bottom_right);
985 } else if (delegated_renderer_layer_.get()) { 999 } else if (delegated_renderer_layer_.get() || surface_layer_.get()) {
986 size.SetToMin(frame_size_in_dip_); 1000 size.SetToMin(frame_size_in_dip_);
987 } 1001 }
988 cc_layer_->SetBounds(size); 1002 cc_layer_->SetBounds(size);
989 } 1003 }
990 1004
991 void Layer::RecomputePosition() { 1005 void Layer::RecomputePosition() {
992 cc_layer_->SetPosition(bounds_.origin() + subpixel_position_offset_); 1006 cc_layer_->SetPosition(bounds_.origin() + subpixel_position_offset_);
993 } 1007 }
994 1008
995 void Layer::AddAnimatorsInTreeToCollection( 1009 void Layer::AddAnimatorsInTreeToCollection(
(...skipping 18 matching lines...) Expand all
1014 children_.end(), 1028 children_.end(),
1015 std::bind2nd(std::mem_fun(&Layer::RemoveAnimatorsInTreeFromCollection), 1029 std::bind2nd(std::mem_fun(&Layer::RemoveAnimatorsInTreeFromCollection),
1016 collection)); 1030 collection));
1017 } 1031 }
1018 1032
1019 bool Layer::IsAnimating() const { 1033 bool Layer::IsAnimating() const {
1020 return animator_ && animator_->is_animating(); 1034 return animator_ && animator_->is_animating();
1021 } 1035 }
1022 1036
1023 } // namespace ui 1037 } // namespace ui
OLDNEW
« no previous file with comments | « ui/compositor/layer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698