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

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

Issue 10824270: Revert 151153 - Partial revert of 146621 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 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"
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 void Layer::SetExternalTexture(Texture* texture) { 364 void Layer::SetExternalTexture(Texture* texture) {
365 DCHECK_EQ(type_, LAYER_TEXTURED); 365 DCHECK_EQ(type_, LAYER_TEXTURED);
366 layer_updated_externally_ = !!texture; 366 layer_updated_externally_ = !!texture;
367 texture_ = texture; 367 texture_ = texture;
368 if (web_layer_is_accelerated_ != layer_updated_externally_) { 368 if (web_layer_is_accelerated_ != layer_updated_externally_) {
369 // Switch to a different type of layer. 369 // Switch to a different type of layer.
370 web_layer_.removeAllChildren(); 370 web_layer_.removeAllChildren();
371 WebKit::WebLayer new_layer; 371 WebKit::WebLayer new_layer;
372 if (layer_updated_externally_) { 372 if (layer_updated_externally_) {
373 WebKit::WebExternalTextureLayer texture_layer = 373 WebKit::WebExternalTextureLayer texture_layer =
374 WebKit::WebExternalTextureLayer::create(); 374 WebKit::WebExternalTextureLayer::create(this);
375 texture_layer.setFlipped(texture_->flipped()); 375 texture_layer.setFlipped(texture_->flipped());
376 new_layer = texture_layer; 376 new_layer = texture_layer;
377 } else { 377 } else {
378 // Tell the compositor to clear references to the old texture.
379 WebKit::WebExternalTextureLayer texture_layer =
380 web_layer_.to<WebKit::WebExternalTextureLayer>();
381 texture_layer.willModifyTexture();
378 new_layer = WebKit::WebContentLayer::create(this); 382 new_layer = WebKit::WebContentLayer::create(this);
379 } 383 }
380 if (parent_) { 384 if (parent_) {
381 DCHECK(!parent_->web_layer_.isNull()); 385 DCHECK(!parent_->web_layer_.isNull());
382 parent_->web_layer_.replaceChild(web_layer_, new_layer); 386 parent_->web_layer_.replaceChild(web_layer_, new_layer);
383 } 387 }
384 web_layer_ = new_layer; 388 web_layer_ = new_layer;
385 web_layer_is_accelerated_ = layer_updated_externally_; 389 web_layer_is_accelerated_ = layer_updated_externally_;
386 for (size_t i = 0; i < children_.size(); ++i) { 390 for (size_t i = 0; i < children_.size(); ++i) {
387 DCHECK(!children_[i]->web_layer_.isNull()); 391 DCHECK(!children_[i]->web_layer_.isNull());
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 canvas->sk_canvas()->scale(SkFloatToScalar(device_scale_factor_), 500 canvas->sk_canvas()->scale(SkFloatToScalar(device_scale_factor_),
497 SkFloatToScalar(device_scale_factor_)); 501 SkFloatToScalar(device_scale_factor_));
498 } 502 }
499 503
500 if (delegate_) 504 if (delegate_)
501 delegate_->OnPaintLayer(canvas.get()); 505 delegate_->OnPaintLayer(canvas.get());
502 if (scale_content_) 506 if (scale_content_)
503 canvas->Restore(); 507 canvas->Restore();
504 } 508 }
505 509
510 unsigned Layer::prepareTexture(WebKit::WebTextureUpdater& /* updater */) {
511 DCHECK(layer_updated_externally_);
512 return texture_->texture_id();
513 }
514
515 WebKit::WebGraphicsContext3D* Layer::context() {
516 DCHECK(layer_updated_externally_);
517 return texture_->HostContext3D();
518 }
519
506 void Layer::SetForceRenderSurface(bool force) { 520 void Layer::SetForceRenderSurface(bool force) {
507 if (force_render_surface_ == force) 521 if (force_render_surface_ == force)
508 return; 522 return;
509 523
510 force_render_surface_ = force; 524 force_render_surface_ = force;
511 web_layer_.setForceRenderSurface(force_render_surface_); 525 web_layer_.setForceRenderSurface(force_render_surface_);
512 } 526 }
513 527
514 float Layer::GetCombinedOpacity() const { 528 float Layer::GetCombinedOpacity() const {
515 float opacity = opacity_; 529 float opacity = opacity_;
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 734
721 void Layer::RecomputeDrawsContentAndUVRect() { 735 void Layer::RecomputeDrawsContentAndUVRect() {
722 DCHECK(!web_layer_.isNull()); 736 DCHECK(!web_layer_.isNull());
723 bool should_draw = type_ != LAYER_NOT_DRAWN; 737 bool should_draw = type_ != LAYER_NOT_DRAWN;
724 if (!web_layer_is_accelerated_) { 738 if (!web_layer_is_accelerated_) {
725 if (type_ != LAYER_SOLID_COLOR) 739 if (type_ != LAYER_SOLID_COLOR)
726 web_layer_.to<WebKit::WebContentLayer>().setDrawsContent(should_draw); 740 web_layer_.to<WebKit::WebContentLayer>().setDrawsContent(should_draw);
727 web_layer_.setBounds(ConvertSizeToPixel(this, bounds_.size())); 741 web_layer_.setBounds(ConvertSizeToPixel(this, bounds_.size()));
728 } else { 742 } else {
729 DCHECK(texture_); 743 DCHECK(texture_);
730 unsigned int texture_id = texture_->texture_id();
731 WebKit::WebExternalTextureLayer texture_layer = 744 WebKit::WebExternalTextureLayer texture_layer =
732 web_layer_.to<WebKit::WebExternalTextureLayer>(); 745 web_layer_.to<WebKit::WebExternalTextureLayer>();
733 texture_layer.setTextureId(should_draw ? texture_id : 0);
734 746
735 gfx::Size texture_size; 747 gfx::Size texture_size;
736 if (scale_content_) 748 if (scale_content_)
737 texture_size = texture_->size(); 749 texture_size = texture_->size();
738 else 750 else
739 texture_size = ConvertSizeToDIP(this, texture_->size()); 751 texture_size = ConvertSizeToDIP(this, texture_->size());
740 752
741 gfx::Size size(std::min(bounds().width(), texture_size.width()), 753 gfx::Size size(std::min(bounds().width(), texture_size.width()),
742 std::min(bounds().height(), texture_size.height())); 754 std::min(bounds().height(), texture_size.height()));
743 WebKit::WebFloatRect rect( 755 WebKit::WebFloatRect rect(
(...skipping 13 matching lines...) Expand all
757 return; 769 return;
758 unsigned int color = 0xFF000000; 770 unsigned int color = 0xFF000000;
759 color |= web_layer_is_accelerated_ ? 0x0000FF00 : 0x00FF0000; 771 color |= web_layer_is_accelerated_ ? 0x0000FF00 : 0x00FF0000;
760 bool opaque = fills_bounds_opaquely_ && (GetCombinedOpacity() == 1.f); 772 bool opaque = fills_bounds_opaquely_ && (GetCombinedOpacity() == 1.f);
761 if (!opaque) 773 if (!opaque)
762 color |= 0xFF; 774 color |= 0xFF;
763 web_layer_.setDebugBorderColor(color); 775 web_layer_.setDebugBorderColor(color);
764 } 776 }
765 777
766 } // namespace ui 778 } // 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