| OLD | NEW |
| (Empty) |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "cc/layers/nine_patch_layer.h" | |
| 6 | |
| 7 #include "cc/layers/nine_patch_layer_impl.h" | |
| 8 #include "cc/resources/prioritized_resource.h" | |
| 9 #include "cc/resources/resource_update.h" | |
| 10 #include "cc/resources/resource_update_queue.h" | |
| 11 #include "cc/resources/scoped_ui_resource.h" | |
| 12 #include "cc/resources/ui_resource_bitmap.h" | |
| 13 #include "cc/trees/layer_tree_host.h" | |
| 14 | |
| 15 namespace cc { | |
| 16 | |
| 17 scoped_refptr<NinePatchLayer> NinePatchLayer::Create() { | |
| 18 return make_scoped_refptr(new NinePatchLayer()); | |
| 19 } | |
| 20 | |
| 21 NinePatchLayer::NinePatchLayer() : fill_center_(false) {} | |
| 22 | |
| 23 NinePatchLayer::~NinePatchLayer() {} | |
| 24 | |
| 25 scoped_ptr<LayerImpl> NinePatchLayer::CreateLayerImpl( | |
| 26 LayerTreeImpl* tree_impl) { | |
| 27 return NinePatchLayerImpl::Create(tree_impl, id()); | |
| 28 } | |
| 29 | |
| 30 void NinePatchLayer::SetBorder(const gfx::Rect& border) { | |
| 31 if (border == border_) | |
| 32 return; | |
| 33 border_ = border; | |
| 34 SetNeedsCommit(); | |
| 35 } | |
| 36 | |
| 37 void NinePatchLayer::SetAperture(const gfx::Rect& aperture) { | |
| 38 if (image_aperture_ == aperture) | |
| 39 return; | |
| 40 | |
| 41 image_aperture_ = aperture; | |
| 42 SetNeedsCommit(); | |
| 43 } | |
| 44 | |
| 45 void NinePatchLayer::SetFillCenter(bool fill_center) { | |
| 46 if (fill_center_ == fill_center) | |
| 47 return; | |
| 48 | |
| 49 fill_center_ = fill_center; | |
| 50 SetNeedsCommit(); | |
| 51 } | |
| 52 | |
| 53 void NinePatchLayer::PushPropertiesTo(LayerImpl* layer) { | |
| 54 UIResourceLayer::PushPropertiesTo(layer); | |
| 55 NinePatchLayerImpl* layer_impl = static_cast<NinePatchLayerImpl*>(layer); | |
| 56 | |
| 57 if (!ui_resource_holder_) { | |
| 58 layer_impl->SetUIResourceId(0); | |
| 59 } else { | |
| 60 DCHECK(layer_tree_host()); | |
| 61 | |
| 62 layer_impl->SetLayout(image_aperture_, border_, fill_center_); | |
| 63 } | |
| 64 } | |
| 65 | |
| 66 } // namespace cc | |
| OLD | NEW |