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

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

Issue 8590021: aura/cc: clip webkit layer size to external texture dimensions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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 | « no previous file | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/gfx/compositor/layer.h" 5 #include "ui/gfx/compositor/layer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 } 278 }
279 web_layer_ = new_layer; 279 web_layer_ = new_layer;
280 web_layer_is_accelerated_ = true; 280 web_layer_is_accelerated_ = true;
281 for (size_t i = 0; i < children_.size(); ++i) { 281 for (size_t i = 0; i < children_.size(); ++i) {
282 DCHECK(!children_[i]->web_layer_.isNull()); 282 DCHECK(!children_[i]->web_layer_.isNull());
283 web_layer_.addChild(children_[i]->web_layer_); 283 web_layer_.addChild(children_[i]->web_layer_);
284 } 284 }
285 web_layer_.setAnchorPoint(WebKit::WebFloatPoint(0.f, 0.f)); 285 web_layer_.setAnchorPoint(WebKit::WebFloatPoint(0.f, 0.f));
286 web_layer_.setOpaque(fills_bounds_opaquely_); 286 web_layer_.setOpaque(fills_bounds_opaquely_);
287 web_layer_.setOpacity(visible_ ? opacity_ : 0.f); 287 web_layer_.setOpacity(visible_ ? opacity_ : 0.f);
288 web_layer_.setBounds(bounds_.size());
289 RecomputeTransform(); 288 RecomputeTransform();
290 } 289 }
291 TextureCC* texture_cc = static_cast<TextureCC*>(texture); 290 TextureCC* texture_cc = static_cast<TextureCC*>(texture);
292 texture_cc->Update(); 291 texture_cc->Update();
293 WebKit::WebExternalTextureLayer texture_layer = 292 WebKit::WebExternalTextureLayer texture_layer =
294 web_layer_.to<WebKit::WebExternalTextureLayer>(); 293 web_layer_.to<WebKit::WebExternalTextureLayer>();
295 texture_layer.setFlipped(texture_cc->flipped()); 294 texture_layer.setFlipped(texture_cc->flipped());
296 RecomputeDrawsContentAndUVRect(); 295 RecomputeDrawsContentAndUVRect();
297 #endif 296 #endif
298 } 297 }
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 bounds_ = bounds; 630 bounds_ = bounds;
632 if (IsDrawn()) { 631 if (IsDrawn()) {
633 if (was_move) 632 if (was_move)
634 ScheduleDraw(); 633 ScheduleDraw();
635 else 634 else
636 SchedulePaint(gfx::Rect(bounds.size())); 635 SchedulePaint(gfx::Rect(bounds.size()));
637 } 636 }
638 637
639 SetNeedsToRecomputeHole(); 638 SetNeedsToRecomputeHole();
640 #if defined(USE_WEBKIT_COMPOSITOR) 639 #if defined(USE_WEBKIT_COMPOSITOR)
641 web_layer_.setBounds(bounds.size());
642 RecomputeTransform(); 640 RecomputeTransform();
643 RecomputeDrawsContentAndUVRect(); 641 RecomputeDrawsContentAndUVRect();
644 #endif 642 #endif
645 } 643 }
646 644
647 void Layer::SetTransformImmediately(const ui::Transform& transform) { 645 void Layer::SetTransformImmediately(const ui::Transform& transform) {
648 transform_ = transform; 646 transform_ = transform;
649 647
650 SetNeedsToRecomputeHole(); 648 SetNeedsToRecomputeHole();
651 #if defined(USE_WEBKIT_COMPOSITOR) 649 #if defined(USE_WEBKIT_COMPOSITOR)
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 transform.ConcatTranslate(bounds_.x(), bounds_.y()); 711 transform.ConcatTranslate(bounds_.x(), bounds_.y());
714 web_layer_.setTransform(transform.matrix()); 712 web_layer_.setTransform(transform.matrix());
715 } 713 }
716 714
717 void Layer::RecomputeDrawsContentAndUVRect() { 715 void Layer::RecomputeDrawsContentAndUVRect() {
718 DCHECK(!web_layer_.isNull()); 716 DCHECK(!web_layer_.isNull());
719 bool should_draw = type_ == LAYER_HAS_TEXTURE && 717 bool should_draw = type_ == LAYER_HAS_TEXTURE &&
720 !hole_rect_.Contains(gfx::Rect(gfx::Point(0, 0), bounds_.size())); 718 !hole_rect_.Contains(gfx::Rect(gfx::Point(0, 0), bounds_.size()));
721 if (!web_layer_is_accelerated_) { 719 if (!web_layer_is_accelerated_) {
722 web_layer_.to<WebKit::WebContentLayer>().setDrawsContent(should_draw); 720 web_layer_.to<WebKit::WebContentLayer>().setDrawsContent(should_draw);
721 web_layer_.setBounds(bounds_.size());
723 } else { 722 } else {
724 DCHECK(texture_); 723 DCHECK(texture_);
725 TextureCC* texture_cc = static_cast<TextureCC*>(texture_.get()); 724 TextureCC* texture_cc = static_cast<TextureCC*>(texture_.get());
726 unsigned int texture_id = texture_cc->texture_id(); 725 unsigned int texture_id = texture_cc->texture_id();
727 WebKit::WebExternalTextureLayer texture_layer = 726 WebKit::WebExternalTextureLayer texture_layer =
728 web_layer_.to<WebKit::WebExternalTextureLayer>(); 727 web_layer_.to<WebKit::WebExternalTextureLayer>();
729 texture_layer.setTextureId(should_draw ? texture_id : 0); 728 texture_layer.setTextureId(should_draw ? texture_id : 0);
729 gfx::Size size(std::min(bounds_.width(), texture_cc->size().width()),
730 std::min(bounds_.height(), texture_cc->size().height()));
730 WebKit::WebFloatRect rect( 731 WebKit::WebFloatRect rect(
731 0, 732 0,
732 0, 733 0,
733 static_cast<float>(bounds_.width())/texture_cc->size().width(), 734 static_cast<float>(size.width())/texture_cc->size().width(),
734 static_cast<float>(bounds_.height())/texture_cc->size().height()); 735 static_cast<float>(size.height())/texture_cc->size().height());
735 texture_layer.setUVRect(rect); 736 texture_layer.setUVRect(rect);
737 web_layer_.setBounds(size);
736 } 738 }
737 } 739 }
738 #endif 740 #endif
739 741
740 } // namespace ui 742 } // namespace ui
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698