| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "cc/layers/ui_resource_layer.h" | 5 #include "cc/layers/ui_resource_layer.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" |
| 7 #include "base/trace_event/trace_event.h" | 8 #include "base/trace_event/trace_event.h" |
| 8 #include "cc/layers/ui_resource_layer_impl.h" | 9 #include "cc/layers/ui_resource_layer_impl.h" |
| 9 #include "cc/resources/scoped_ui_resource.h" | 10 #include "cc/resources/scoped_ui_resource.h" |
| 10 #include "cc/resources/ui_resource_bitmap.h" | 11 #include "cc/resources/ui_resource_bitmap.h" |
| 11 #include "cc/trees/layer_tree_host.h" | 12 #include "cc/trees/layer_tree_host.h" |
| 12 | 13 |
| 13 namespace cc { | 14 namespace cc { |
| 14 | 15 |
| 15 | 16 |
| 16 namespace { | 17 namespace { |
| 17 | 18 |
| 18 class ScopedUIResourceHolder : public UIResourceLayer::UIResourceHolder { | 19 class ScopedUIResourceHolder : public UIResourceLayer::UIResourceHolder { |
| 19 public: | 20 public: |
| 20 static scoped_ptr<ScopedUIResourceHolder> Create(LayerTreeHost* host, | 21 static std::unique_ptr<ScopedUIResourceHolder> Create( |
| 21 const SkBitmap& skbitmap) { | 22 LayerTreeHost* host, |
| 22 return make_scoped_ptr(new ScopedUIResourceHolder(host, skbitmap)); | 23 const SkBitmap& skbitmap) { |
| 24 return base::WrapUnique(new ScopedUIResourceHolder(host, skbitmap)); |
| 23 } | 25 } |
| 24 UIResourceId id() override { return resource_->id(); } | 26 UIResourceId id() override { return resource_->id(); } |
| 25 | 27 |
| 26 private: | 28 private: |
| 27 ScopedUIResourceHolder(LayerTreeHost* host, const SkBitmap& skbitmap) { | 29 ScopedUIResourceHolder(LayerTreeHost* host, const SkBitmap& skbitmap) { |
| 28 resource_ = ScopedUIResource::Create(host, UIResourceBitmap(skbitmap)); | 30 resource_ = ScopedUIResource::Create(host, UIResourceBitmap(skbitmap)); |
| 29 } | 31 } |
| 30 | 32 |
| 31 scoped_ptr<ScopedUIResource> resource_; | 33 std::unique_ptr<ScopedUIResource> resource_; |
| 32 }; | 34 }; |
| 33 | 35 |
| 34 class SharedUIResourceHolder : public UIResourceLayer::UIResourceHolder { | 36 class SharedUIResourceHolder : public UIResourceLayer::UIResourceHolder { |
| 35 public: | 37 public: |
| 36 static scoped_ptr<SharedUIResourceHolder> Create(UIResourceId id) { | 38 static std::unique_ptr<SharedUIResourceHolder> Create(UIResourceId id) { |
| 37 return make_scoped_ptr(new SharedUIResourceHolder(id)); | 39 return base::WrapUnique(new SharedUIResourceHolder(id)); |
| 38 } | 40 } |
| 39 | 41 |
| 40 UIResourceId id() override { return id_; } | 42 UIResourceId id() override { return id_; } |
| 41 | 43 |
| 42 private: | 44 private: |
| 43 explicit SharedUIResourceHolder(UIResourceId id) : id_(id) {} | 45 explicit SharedUIResourceHolder(UIResourceId id) : id_(id) {} |
| 44 | 46 |
| 45 UIResourceId id_; | 47 UIResourceId id_; |
| 46 }; | 48 }; |
| 47 | 49 |
| 48 } // anonymous namespace | 50 } // anonymous namespace |
| 49 | 51 |
| 50 UIResourceLayer::UIResourceHolder::~UIResourceHolder() {} | 52 UIResourceLayer::UIResourceHolder::~UIResourceHolder() {} |
| 51 | 53 |
| 52 scoped_refptr<UIResourceLayer> UIResourceLayer::Create() { | 54 scoped_refptr<UIResourceLayer> UIResourceLayer::Create() { |
| 53 return make_scoped_refptr(new UIResourceLayer()); | 55 return make_scoped_refptr(new UIResourceLayer()); |
| 54 } | 56 } |
| 55 | 57 |
| 56 UIResourceLayer::UIResourceLayer() | 58 UIResourceLayer::UIResourceLayer() |
| 57 : uv_top_left_(0.f, 0.f), uv_bottom_right_(1.f, 1.f) { | 59 : uv_top_left_(0.f, 0.f), uv_bottom_right_(1.f, 1.f) { |
| 58 vertex_opacity_[0] = 1.0f; | 60 vertex_opacity_[0] = 1.0f; |
| 59 vertex_opacity_[1] = 1.0f; | 61 vertex_opacity_[1] = 1.0f; |
| 60 vertex_opacity_[2] = 1.0f; | 62 vertex_opacity_[2] = 1.0f; |
| 61 vertex_opacity_[3] = 1.0f; | 63 vertex_opacity_[3] = 1.0f; |
| 62 } | 64 } |
| 63 | 65 |
| 64 UIResourceLayer::~UIResourceLayer() {} | 66 UIResourceLayer::~UIResourceLayer() {} |
| 65 | 67 |
| 66 scoped_ptr<LayerImpl> UIResourceLayer::CreateLayerImpl( | 68 std::unique_ptr<LayerImpl> UIResourceLayer::CreateLayerImpl( |
| 67 LayerTreeImpl* tree_impl) { | 69 LayerTreeImpl* tree_impl) { |
| 68 return UIResourceLayerImpl::Create(tree_impl, id()); | 70 return UIResourceLayerImpl::Create(tree_impl, id()); |
| 69 } | 71 } |
| 70 | 72 |
| 71 void UIResourceLayer::SetUV(const gfx::PointF& top_left, | 73 void UIResourceLayer::SetUV(const gfx::PointF& top_left, |
| 72 const gfx::PointF& bottom_right) { | 74 const gfx::PointF& bottom_right) { |
| 73 if (uv_top_left_ == top_left && uv_bottom_right_ == bottom_right) | 75 if (uv_top_left_ == top_left && uv_bottom_right_ == bottom_right) |
| 74 return; | 76 return; |
| 75 uv_top_left_ = top_left; | 77 uv_top_left_ = top_left; |
| 76 uv_bottom_right_ = bottom_right; | 78 uv_bottom_right_ = bottom_right; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 gfx::Size image_size = | 162 gfx::Size image_size = |
| 161 layer_tree_host()->GetUIResourceSize(ui_resource_holder_->id()); | 163 layer_tree_host()->GetUIResourceSize(ui_resource_holder_->id()); |
| 162 layer_impl->SetUIResourceId(ui_resource_holder_->id()); | 164 layer_impl->SetUIResourceId(ui_resource_holder_->id()); |
| 163 layer_impl->SetImageBounds(image_size); | 165 layer_impl->SetImageBounds(image_size); |
| 164 layer_impl->SetUV(uv_top_left_, uv_bottom_right_); | 166 layer_impl->SetUV(uv_top_left_, uv_bottom_right_); |
| 165 layer_impl->SetVertexOpacity(vertex_opacity_); | 167 layer_impl->SetVertexOpacity(vertex_opacity_); |
| 166 } | 168 } |
| 167 } | 169 } |
| 168 | 170 |
| 169 } // namespace cc | 171 } // namespace cc |
| OLD | NEW |