OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 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 | 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 "nine_patch_layer_impl.h" | 5 #include "nine_patch_layer_impl.h" |
6 | 6 |
7 #include "base/stringprintf.h" | 7 #include "base/stringprintf.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "cc/quad_sink.h" | 9 #include "cc/quad_sink.h" |
10 #include "cc/texture_draw_quad.h" | 10 #include "cc/texture_draw_quad.h" |
11 #include "ui/gfx/rect_f.h" | 11 #include "ui/gfx/rect_f.h" |
12 | 12 |
13 namespace cc { | 13 namespace cc { |
14 | 14 |
15 NinePatchLayerImpl::NinePatchLayerImpl(LayerTreeImpl* treeImpl, int id) | 15 NinePatchLayerImpl::NinePatchLayerImpl(LayerTreeImpl* treeImpl, int id) |
16 : LayerImpl(treeImpl, id) | 16 : LayerImpl(treeImpl, id) |
17 , m_resourceId(0) | 17 , m_resourceId(0) |
18 { | 18 { |
19 } | 19 } |
20 | 20 |
21 NinePatchLayerImpl::~NinePatchLayerImpl() | 21 NinePatchLayerImpl::~NinePatchLayerImpl() |
22 { | 22 { |
23 } | 23 } |
24 | 24 |
25 ResourceProvider::ResourceId NinePatchLayerImpl::contentsResourceId() const | 25 ResourceProvider::ResourceId NinePatchLayerImpl::contentsResourceId() const |
26 { | 26 { |
27 return 0; | 27 return 0; |
28 } | 28 } |
29 | 29 |
| 30 scoped_ptr<LayerImpl> NinePatchLayerImpl::createLayerImpl(LayerTreeImpl* treeImp
l) |
| 31 { |
| 32 return NinePatchLayerImpl::create(treeImpl, id()).PassAs<LayerImpl>(); |
| 33 } |
| 34 |
| 35 void NinePatchLayerImpl::pushPropertiesTo(LayerImpl* layer) |
| 36 { |
| 37 LayerImpl::pushPropertiesTo(layer); |
| 38 NinePatchLayerImpl* layerImpl = static_cast<NinePatchLayerImpl*>(layer); |
| 39 |
| 40 if (!m_resourceId) |
| 41 return; |
| 42 |
| 43 layerImpl->setResourceId(m_resourceId); |
| 44 layerImpl->setLayout(m_imageBounds, m_imageAperture); |
| 45 } |
| 46 |
30 void NinePatchLayerImpl::willDraw(ResourceProvider* resourceProvider) | 47 void NinePatchLayerImpl::willDraw(ResourceProvider* resourceProvider) |
31 { | 48 { |
32 } | 49 } |
33 | 50 |
34 static gfx::RectF normalizedRect(float x, float y, float width, float height, fl
oat totalWidth, float totalHeight) | 51 static gfx::RectF normalizedRect(float x, float y, float width, float height, fl
oat totalWidth, float totalHeight) |
35 { | 52 { |
36 return gfx::RectF(x / totalWidth, y / totalHeight, width / totalWidth, heigh
t / totalHeight); | 53 return gfx::RectF(x / totalWidth, y / totalHeight, width / totalWidth, heigh
t / totalHeight); |
37 } | 54 } |
38 | 55 |
39 void NinePatchLayerImpl::setLayout(const gfx::Size& imageBounds, const gfx::Rect
& aperture) | 56 void NinePatchLayerImpl::setLayout(const gfx::Size& imageBounds, const gfx::Rect
& aperture) |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 | 196 |
180 list = new base::ListValue; | 197 list = new base::ListValue; |
181 list->AppendInteger(m_imageBounds.width()); | 198 list->AppendInteger(m_imageBounds.width()); |
182 list->AppendInteger(m_imageBounds.height()); | 199 list->AppendInteger(m_imageBounds.height()); |
183 result->Set("ImageBounds", list); | 200 result->Set("ImageBounds", list); |
184 | 201 |
185 return result; | 202 return result; |
186 } | 203 } |
187 | 204 |
188 } | 205 } |
OLD | NEW |