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

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

Issue 15001027: [Aura] Added Support for rendering software compositor frames as cc::TextureLayers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
« ui/compositor/layer.h ('K') | « 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"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 background_blur_radius_(0), 79 background_blur_radius_(0),
80 layer_saturation_(0.0f), 80 layer_saturation_(0.0f),
81 layer_brightness_(0.0f), 81 layer_brightness_(0.0f),
82 layer_grayscale_(0.0f), 82 layer_grayscale_(0.0f),
83 layer_inverted_(false), 83 layer_inverted_(false),
84 layer_mask_(NULL), 84 layer_mask_(NULL),
85 layer_mask_back_link_(NULL), 85 layer_mask_back_link_(NULL),
86 zoom_(1), 86 zoom_(1),
87 zoom_inset_(0), 87 zoom_inset_(0),
88 delegate_(NULL), 88 delegate_(NULL),
89 cc_layer_(NULL),
89 scale_content_(true), 90 scale_content_(true),
90 device_scale_factor_(1.0f) { 91 device_scale_factor_(1.0f) {
91 CreateWebLayer(); 92 CreateWebLayer();
92 } 93 }
93 94
94 Layer::~Layer() { 95 Layer::~Layer() {
95 // Destroying the animator may cause observers to use the layer (and 96 // Destroying the animator may cause observers to use the layer (and
96 // indirectly the WebLayer). Destroy the animator first so that the WebLayer 97 // indirectly the WebLayer). Destroy the animator first so that the WebLayer
97 // is still around. 98 // is still around.
98 if (animator_) 99 if (animator_)
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 } else { 508 } else {
508 scoped_refptr<cc::ContentLayer> new_layer = 509 scoped_refptr<cc::ContentLayer> new_layer =
509 cc::ContentLayer::Create(this); 510 cc::ContentLayer::Create(this);
510 SwitchToLayer(new_layer); 511 SwitchToLayer(new_layer);
511 content_layer_ = new_layer; 512 content_layer_ = new_layer;
512 } 513 }
513 } 514 }
514 RecomputeDrawsContentAndUVRect(); 515 RecomputeDrawsContentAndUVRect();
515 } 516 }
516 517
518 void Layer::SetTextureMailbox(const cc::TextureMailbox& mailbox,
519 float device_scale_factor) {
520 DCHECK_EQ(type_, LAYER_TEXTURED);
521 DCHECK(!solid_color_layer_);
522 layer_updated_externally_ = true;
523 texture_ = NULL;
524 if (!texture_layer_ || !texture_layer_->uses_mailbox()) {
525 scoped_refptr<cc::TextureLayer> new_layer =
526 cc::TextureLayer::CreateForMailbox(this);
527 new_layer->SetFlipped(false);
528 SwitchToLayer(new_layer);
529 texture_layer_ = new_layer;
530 }
531 texture_layer_->SetTextureMailbox(mailbox);
532 mailbox_ = mailbox;
533 mailbox_scale_factor_ = device_scale_factor;
534 RecomputeDrawsContentAndUVRect();
535 }
piman 2013/05/28 20:58:57 So, one missing piece here is Window::RecreateLaye
slavi 2013/05/29 18:31:48 Done.
536
517 void Layer::SetDelegatedFrame(scoped_ptr<cc::DelegatedFrameData> frame, 537 void Layer::SetDelegatedFrame(scoped_ptr<cc::DelegatedFrameData> frame,
518 gfx::Size frame_size_in_dip) { 538 gfx::Size frame_size_in_dip) {
519 DCHECK_EQ(type_, LAYER_TEXTURED); 539 DCHECK_EQ(type_, LAYER_TEXTURED);
520 bool has_frame = frame.get() && !frame->render_pass_list.empty(); 540 bool has_frame = frame.get() && !frame->render_pass_list.empty();
521 layer_updated_externally_ = has_frame; 541 layer_updated_externally_ = has_frame;
522 delegated_frame_size_in_dip_ = frame_size_in_dip; 542 delegated_frame_size_in_dip_ = frame_size_in_dip;
523 if (!!delegated_renderer_layer_ != has_frame) { 543 if (!!delegated_renderer_layer_ != has_frame) {
524 if (has_frame) { 544 if (has_frame) {
525 scoped_refptr<cc::DelegatedRendererLayer> new_layer = 545 scoped_refptr<cc::DelegatedRendererLayer> new_layer =
526 cc::DelegatedRendererLayer::Create(NULL); 546 cc::DelegatedRendererLayer::Create(NULL);
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 } 649 }
630 650
631 if (delegate_) 651 if (delegate_)
632 delegate_->OnPaintLayer(canvas.get()); 652 delegate_->OnPaintLayer(canvas.get());
633 if (scale_content) 653 if (scale_content)
634 canvas->Restore(); 654 canvas->Restore();
635 } 655 }
636 656
637 unsigned Layer::PrepareTexture(cc::ResourceUpdateQueue* queue) { 657 unsigned Layer::PrepareTexture(cc::ResourceUpdateQueue* queue) {
638 DCHECK(texture_layer_); 658 DCHECK(texture_layer_);
639 return texture_->PrepareTexture(); 659 if (texture_)
660 return texture_->PrepareTexture();
661 return 0;
640 } 662 }
641 663
642 WebKit::WebGraphicsContext3D* Layer::Context3d() { 664 WebKit::WebGraphicsContext3D* Layer::Context3d() {
643 DCHECK(texture_layer_); 665 DCHECK(texture_layer_);
644 return texture_->HostContext3D(); 666 if (texture_)
667 return texture_->HostContext3D();
668 return NULL;
645 } 669 }
646 670
647 bool Layer::PrepareTextureMailbox(cc::TextureMailbox* mailbox) { 671 bool Layer::PrepareTextureMailbox(cc::TextureMailbox* mailbox) {
648 return false; 672 return false;
649 } 673 }
650 674
651 void Layer::SetForceRenderSurface(bool force) { 675 void Layer::SetForceRenderSurface(bool force) {
652 if (force_render_surface_ == force) 676 if (force_render_surface_ == force)
653 return; 677 return;
654 678
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
912 transform.Scale(1.0f / device_scale_factor_, 1.0f / device_scale_factor_); 936 transform.Scale(1.0f / device_scale_factor_, 1.0f / device_scale_factor_);
913 transform.PreconcatTransform(cc_layer_->transform()); 937 transform.PreconcatTransform(cc_layer_->transform());
914 transform.Scale(device_scale_factor_, device_scale_factor_); 938 transform.Scale(device_scale_factor_, device_scale_factor_);
915 return transform; 939 return transform;
916 } 940 }
917 941
918 void Layer::RecomputeDrawsContentAndUVRect() { 942 void Layer::RecomputeDrawsContentAndUVRect() {
919 DCHECK(cc_layer_); 943 DCHECK(cc_layer_);
920 gfx::Size size(bounds_.size()); 944 gfx::Size size(bounds_.size());
921 if (texture_layer_.get()) { 945 if (texture_layer_.get()) {
922 DCHECK(texture_); 946 gfx::Size texture_size;
923 947 if (!texture_layer_->uses_mailbox()) {
924 float texture_scale_factor = 1.0f / texture_->device_scale_factor(); 948 DCHECK(texture_);
925 gfx::Size texture_size = gfx::ToFlooredSize( 949 float texture_scale_factor = 1.0f / texture_->device_scale_factor();
926 gfx::ScaleSize(texture_->size(), texture_scale_factor)); 950 texture_size = gfx::ToFlooredSize(
951 gfx::ScaleSize(texture_->size(), texture_scale_factor));
952 } else {
953 float texture_scale_factor = 1.0f / mailbox_scale_factor_;
954 texture_size = gfx::ToFlooredSize(
955 gfx::ScaleSize(mailbox_.size(), texture_scale_factor));
956 }
927 size.ClampToMax(texture_size); 957 size.ClampToMax(texture_size);
928 958
929 gfx::PointF uv_top_left(0.f, 0.f); 959 gfx::PointF uv_top_left(0.f, 0.f);
930 gfx::PointF uv_bottom_right( 960 gfx::PointF uv_bottom_right(
931 static_cast<float>(size.width())/texture_size.width(), 961 static_cast<float>(size.width())/texture_size.width(),
932 static_cast<float>(size.height())/texture_size.height()); 962 static_cast<float>(size.height())/texture_size.height());
933 texture_layer_->SetUV(uv_top_left, uv_bottom_right); 963 texture_layer_->SetUV(uv_top_left, uv_bottom_right);
934 } else if (delegated_renderer_layer_.get()) { 964 } else if (delegated_renderer_layer_.get()) {
935 delegated_renderer_layer_->SetDisplaySize( 965 delegated_renderer_layer_->SetDisplaySize(
936 ConvertSizeToPixel(this, delegated_frame_size_in_dip_)); 966 ConvertSizeToPixel(this, delegated_frame_size_in_dip_));
937 size.ClampToMax(delegated_frame_size_in_dip_); 967 size.ClampToMax(delegated_frame_size_in_dip_);
938 } 968 }
939 cc_layer_->SetBounds(ConvertSizeToPixel(this, size)); 969 cc_layer_->SetBounds(ConvertSizeToPixel(this, size));
940 } 970 }
941 971
942 void Layer::RecomputePosition() { 972 void Layer::RecomputePosition() {
943 cc_layer_->SetPosition(gfx::ScalePoint( 973 cc_layer_->SetPosition(gfx::ScalePoint(
944 gfx::PointF(bounds_.x(), bounds_.y()), 974 gfx::PointF(bounds_.x(), bounds_.y()),
945 device_scale_factor_)); 975 device_scale_factor_));
946 } 976 }
947 977
948 } // namespace ui 978 } // namespace ui
OLDNEW
« ui/compositor/layer.h ('K') | « ui/compositor/layer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698