| 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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 list->AppendInteger(m_imageAperture.origin().x()); | 190 list->AppendInteger(m_imageAperture.origin().x()); |
| 174 list->AppendInteger(m_imageAperture.origin().y()); | 191 list->AppendInteger(m_imageAperture.origin().y()); |
| 175 list->AppendInteger(m_imageAperture.size().width()); | 192 list->AppendInteger(m_imageAperture.size().width()); |
| 176 list->AppendInteger(m_imageAperture.size().height()); | 193 list->AppendInteger(m_imageAperture.size().height()); |
| 177 result->Set("ImageAperture", list); | 194 result->Set("ImageAperture", list); |
| 178 | 195 |
| 179 return result; | 196 return result; |
| 180 } | 197 } |
| 181 | 198 |
| 182 } | 199 } |
| OLD | NEW |