| OLD | NEW |
| 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 "content/browser/renderer_host/render_widget_host_view_android.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_android.h" |
| 6 | 6 |
| 7 #include <android/bitmap.h> | 7 #include <android/bitmap.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 896 ClipContents(gfx::Rect(gfx::Point(), content_size_in_layer_), | 896 ClipContents(gfx::Rect(gfx::Point(), content_size_in_layer_), |
| 897 content_size_in_layer_); | 897 content_size_in_layer_); |
| 898 } | 898 } |
| 899 | 899 |
| 900 void RenderWidgetHostViewAndroid::ClipContents(const gfx::Rect& clipping, | 900 void RenderWidgetHostViewAndroid::ClipContents(const gfx::Rect& clipping, |
| 901 const gfx::Size& content_size) { | 901 const gfx::Size& content_size) { |
| 902 if (!texture_id_in_layer_ || content_size_in_layer_.IsEmpty()) | 902 if (!texture_id_in_layer_ || content_size_in_layer_.IsEmpty()) |
| 903 return; | 903 return; |
| 904 | 904 |
| 905 gfx::Size clipped_content(content_size_in_layer_); | 905 gfx::Size clipped_content(content_size_in_layer_); |
| 906 clipped_content.ClampToMax(clipping.size()); | 906 clipped_content.SetToMin(clipping.size()); |
| 907 texture_layer_->SetBounds(clipped_content); | 907 texture_layer_->SetBounds(clipped_content); |
| 908 texture_layer_->SetNeedsDisplay(); | 908 texture_layer_->SetNeedsDisplay(); |
| 909 | 909 |
| 910 if (texture_size_in_layer_.IsEmpty()) { | 910 if (texture_size_in_layer_.IsEmpty()) { |
| 911 texture_layer_->SetUV(gfx::PointF(), gfx::PointF()); | 911 texture_layer_->SetUV(gfx::PointF(), gfx::PointF()); |
| 912 return; | 912 return; |
| 913 } | 913 } |
| 914 | 914 |
| 915 gfx::PointF offset( | 915 gfx::PointF offset( |
| 916 clipping.x() + content_size_in_layer_.width() - content_size.width(), | 916 clipping.x() + content_size_in_layer_.width() - content_size.width(), |
| 917 clipping.y() + content_size_in_layer_.height() - content_size.height()); | 917 clipping.y() + content_size_in_layer_.height() - content_size.height()); |
| 918 offset.ClampToMin(gfx::PointF()); | 918 offset.SetToMax(gfx::PointF()); |
| 919 | 919 |
| 920 gfx::Vector2dF uv_scale(1.f / texture_size_in_layer_.width(), | 920 gfx::Vector2dF uv_scale(1.f / texture_size_in_layer_.width(), |
| 921 1.f / texture_size_in_layer_.height()); | 921 1.f / texture_size_in_layer_.height()); |
| 922 texture_layer_->SetUV( | 922 texture_layer_->SetUV( |
| 923 gfx::PointF(offset.x() * uv_scale.x(), | 923 gfx::PointF(offset.x() * uv_scale.x(), |
| 924 offset.y() * uv_scale.y()), | 924 offset.y() * uv_scale.y()), |
| 925 gfx::PointF((offset.x() + clipped_content.width()) * uv_scale.x(), | 925 gfx::PointF((offset.x() + clipped_content.width()) * uv_scale.x(), |
| 926 (offset.y() + clipped_content.height()) * uv_scale.y())); | 926 (offset.y() + clipped_content.height()) * uv_scale.y())); |
| 927 } | 927 } |
| 928 | 928 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1005 // RenderWidgetHostView, public: | 1005 // RenderWidgetHostView, public: |
| 1006 | 1006 |
| 1007 // static | 1007 // static |
| 1008 RenderWidgetHostView* | 1008 RenderWidgetHostView* |
| 1009 RenderWidgetHostView::CreateViewForWidget(RenderWidgetHost* widget) { | 1009 RenderWidgetHostView::CreateViewForWidget(RenderWidgetHost* widget) { |
| 1010 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(widget); | 1010 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(widget); |
| 1011 return new RenderWidgetHostViewAndroid(rwhi, NULL); | 1011 return new RenderWidgetHostViewAndroid(rwhi, NULL); |
| 1012 } | 1012 } |
| 1013 | 1013 |
| 1014 } // namespace content | 1014 } // namespace content |
| OLD | NEW |