OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/android/compositor/layer/thumbnail_layer.h" | 5 #include "chrome/browser/android/compositor/layer/thumbnail_layer.h" |
6 | 6 |
7 #include "cc/layers/ui_resource_layer.h" | 7 #include "cc/layers/ui_resource_layer.h" |
8 #include "chrome/browser/android/thumbnail/thumbnail.h" | 8 #include "chrome/browser/android/thumbnail/thumbnail.h" |
9 #include "content/public/browser/android/compositor.h" | 9 #include "content/public/browser/android/compositor.h" |
10 #include "ui/gfx/geometry/size_conversions.h" | 10 #include "ui/gfx/geometry/size_conversions.h" |
11 | 11 |
12 namespace chrome { | 12 namespace chrome { |
13 namespace android { | 13 namespace android { |
14 | 14 |
15 // static | 15 // static |
16 scoped_refptr<ThumbnailLayer> ThumbnailLayer::Create() { | 16 scoped_refptr<ThumbnailLayer> ThumbnailLayer::Create() { |
17 return make_scoped_refptr(new ThumbnailLayer()); | 17 return make_scoped_refptr(new ThumbnailLayer()); |
18 } | 18 } |
19 | 19 |
20 void ThumbnailLayer::SetThumbnail(Thumbnail* thumbnail) { | 20 void ThumbnailLayer::SetThumbnail(Thumbnail* thumbnail) { |
21 layer_->SetUIResourceId(thumbnail->ui_resource_id()); | 21 layer_->SetUIResourceId(thumbnail->ui_resource_id()); |
22 UpdateSizes(thumbnail->scaled_content_size(), thumbnail->scaled_data_size()); | 22 UpdateSizes(thumbnail->scaled_content_size(), thumbnail->scaled_data_size()); |
23 } | 23 } |
24 | 24 |
25 void ThumbnailLayer::Clip(const gfx::Rect& clipping) { | 25 void ThumbnailLayer::Clip(const gfx::Rect& clipping) { |
26 last_clipping_ = clipping; | 26 last_clipping_ = clipping; |
27 gfx::Size clipped_content = | 27 gfx::Size clipped_content = gfx::Size(content_size_.width() - clipping.x(), |
28 gfx::ToCeiledSize(gfx::Size(content_size_.width() - clipping.x(), | 28 content_size_.height() - clipping.y()); |
29 content_size_.height() - clipping.y())); | |
30 clipped_content.SetToMin(clipping.size()); | 29 clipped_content.SetToMin(clipping.size()); |
31 layer_->SetBounds(clipped_content); | 30 layer_->SetBounds(clipped_content); |
32 | 31 |
33 layer_->SetUV( | 32 layer_->SetUV( |
34 gfx::PointF(clipping.x() / resource_size_.width(), | 33 gfx::PointF(clipping.x() / resource_size_.width(), |
35 clipping.y() / resource_size_.height()), | 34 clipping.y() / resource_size_.height()), |
36 gfx::PointF( | 35 gfx::PointF( |
37 (clipping.x() + clipped_content.width()) / resource_size_.width(), | 36 (clipping.x() + clipped_content.width()) / resource_size_.width(), |
38 (clipping.y() + clipped_content.height()) / resource_size_.height())); | 37 (clipping.y() + clipped_content.height()) / resource_size_.height())); |
39 } | 38 } |
(...skipping 23 matching lines...) Expand all Loading... |
63 const gfx::SizeF& resource_size) { | 62 const gfx::SizeF& resource_size) { |
64 if (content_size != content_size_ || resource_size != resource_size_) { | 63 if (content_size != content_size_ || resource_size != resource_size_) { |
65 content_size_ = content_size; | 64 content_size_ = content_size; |
66 resource_size_ = resource_size; | 65 resource_size_ = resource_size; |
67 Clip(last_clipping_); | 66 Clip(last_clipping_); |
68 } | 67 } |
69 } | 68 } |
70 | 69 |
71 } // namespace android | 70 } // namespace android |
72 } // namespace chrome | 71 } // namespace chrome |
OLD | NEW |