Reland "Non-SFI mode: Switch to newlib. (patchset #4 id:60001 of https://codereview...
[chromium-blink-merge.git] / cc / layers / nine_patch_layer.cc
blob39043c4f8a3d67fe881b18539d1e8ea689d2dd54
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.
5 #include "cc/layers/nine_patch_layer.h"
7 #include "cc/layers/nine_patch_layer_impl.h"
8 #include "cc/resources/prioritized_resource.h"
9 #include "cc/resources/scoped_ui_resource.h"
10 #include "cc/resources/ui_resource_bitmap.h"
11 #include "cc/trees/layer_tree_host.h"
13 namespace cc {
15 scoped_refptr<NinePatchLayer> NinePatchLayer::Create(
16 const LayerSettings& settings) {
17 return make_scoped_refptr(new NinePatchLayer(settings));
20 NinePatchLayer::NinePatchLayer(const LayerSettings& settings)
21 : UIResourceLayer(settings), fill_center_(false) {
24 NinePatchLayer::~NinePatchLayer() {}
26 scoped_ptr<LayerImpl> NinePatchLayer::CreateLayerImpl(
27 LayerTreeImpl* tree_impl) {
28 return NinePatchLayerImpl::Create(tree_impl, id());
31 void NinePatchLayer::SetBorder(const gfx::Rect& border) {
32 if (border == border_)
33 return;
34 border_ = border;
35 SetNeedsCommit();
38 void NinePatchLayer::SetAperture(const gfx::Rect& aperture) {
39 if (image_aperture_ == aperture)
40 return;
42 image_aperture_ = aperture;
43 SetNeedsCommit();
46 void NinePatchLayer::SetFillCenter(bool fill_center) {
47 if (fill_center_ == fill_center)
48 return;
50 fill_center_ = fill_center;
51 SetNeedsCommit();
54 void NinePatchLayer::PushPropertiesTo(LayerImpl* layer) {
55 UIResourceLayer::PushPropertiesTo(layer);
56 NinePatchLayerImpl* layer_impl = static_cast<NinePatchLayerImpl*>(layer);
58 if (!ui_resource_holder_) {
59 layer_impl->SetUIResourceId(0);
60 } else {
61 DCHECK(layer_tree_host());
63 layer_impl->SetLayout(image_aperture_, border_, fill_center_);
67 } // namespace cc