Chromium Code Reviews| 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 "cc/layers/nine_patch_layer_impl.h" | 5 #include "cc/layers/nine_patch_layer_impl.h" |
| 6 | 6 |
| 7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "cc/base/math_util.h" | |
| 9 #include "cc/layers/quad_sink.h" | 10 #include "cc/layers/quad_sink.h" |
| 10 #include "cc/quads/texture_draw_quad.h" | 11 #include "cc/quads/texture_draw_quad.h" |
| 12 #include "cc/trees/layer_tree_impl.h" | |
| 11 #include "ui/gfx/rect_f.h" | 13 #include "ui/gfx/rect_f.h" |
| 12 | 14 |
| 13 namespace cc { | 15 namespace cc { |
| 14 | 16 |
| 15 NinePatchLayerImpl::NinePatchLayerImpl(LayerTreeImpl* tree_impl, int id) | 17 NinePatchLayerImpl::NinePatchLayerImpl(LayerTreeImpl* tree_impl, int id) |
| 16 : LayerImpl(tree_impl, id), | 18 : LayerImpl(tree_impl, id), |
| 17 resource_id_(0) {} | 19 fill_center_(false), |
| 20 ui_resource_id_(0) {} | |
| 18 | 21 |
| 19 NinePatchLayerImpl::~NinePatchLayerImpl() {} | 22 NinePatchLayerImpl::~NinePatchLayerImpl() {} |
| 20 | 23 |
| 21 ResourceProvider::ResourceId NinePatchLayerImpl::ContentsResourceId() const { | 24 ResourceProvider::ResourceId NinePatchLayerImpl::ContentsResourceId() const { |
| 22 return 0; | 25 return 0; |
| 23 } | 26 } |
| 24 | 27 |
| 25 scoped_ptr<LayerImpl> NinePatchLayerImpl::CreateLayerImpl( | 28 scoped_ptr<LayerImpl> NinePatchLayerImpl::CreateLayerImpl( |
| 26 LayerTreeImpl* tree_impl) { | 29 LayerTreeImpl* tree_impl) { |
| 27 return NinePatchLayerImpl::Create(tree_impl, id()).PassAs<LayerImpl>(); | 30 return NinePatchLayerImpl::Create(tree_impl, id()).PassAs<LayerImpl>(); |
| 28 } | 31 } |
| 29 | 32 |
| 30 void NinePatchLayerImpl::PushPropertiesTo(LayerImpl* layer) { | 33 void NinePatchLayerImpl::PushPropertiesTo(LayerImpl* layer) { |
| 31 LayerImpl::PushPropertiesTo(layer); | 34 LayerImpl::PushPropertiesTo(layer); |
| 32 NinePatchLayerImpl* layer_impl = static_cast<NinePatchLayerImpl*>(layer); | 35 NinePatchLayerImpl* layer_impl = static_cast<NinePatchLayerImpl*>(layer); |
| 33 | 36 |
| 34 if (!resource_id_) | 37 layer_impl->SetUIResourceId(ui_resource_id_); |
| 35 return; | 38 layer_impl->SetLayout(image_bounds_, image_aperture_, border_, fill_center_); |
| 36 | |
| 37 layer_impl->SetResourceId(resource_id_); | |
| 38 layer_impl->SetLayout(image_bounds_, image_aperture_); | |
| 39 } | 39 } |
| 40 | 40 |
| 41 static gfx::RectF NormalizedRect(float x, | 41 static gfx::RectF NormalizedRect(float x, |
| 42 float y, | 42 float y, |
| 43 float width, | 43 float width, |
| 44 float height, | 44 float height, |
| 45 float total_width, | 45 float total_width, |
| 46 float total_height) { | 46 float total_height) { |
| 47 return gfx::RectF(x / total_width, | 47 return gfx::RectF(x / total_width, |
| 48 y / total_height, | 48 y / total_height, |
| 49 width / total_width, | 49 width / total_width, |
| 50 height / total_height); | 50 height / total_height); |
| 51 } | 51 } |
| 52 | 52 |
| 53 void NinePatchLayerImpl::SetLayout(gfx::Size image_bounds, gfx::Rect aperture) { | 53 void NinePatchLayerImpl::SetUIResourceId(UIResourceId uid) { |
| 54 image_bounds_ = image_bounds; | 54 if (uid == ui_resource_id_) |
| 55 image_aperture_ = aperture; | 55 return; |
| 56 ui_resource_id_ = uid; | |
| 57 NoteLayerPropertyChanged(); | |
| 58 } | |
| 59 | |
| 60 void NinePatchLayerImpl::SetLayout(gfx::Size image_bounds, | |
| 61 gfx::Rect aperture, | |
| 62 gfx::Rect border, | |
| 63 bool fill_center) { | |
| 64 // This check imposes an ordering on the call sequence. An UIResource must | |
| 65 // exist before SetLayout can be called. | |
| 66 if (!ui_resource_id_) | |
| 67 return; | |
| 68 | |
| 69 // |border| is in layer space. It cannot exceed the bounds of the layer. | |
| 70 DCHECK(!border.size().IsEmpty()); | |
| 71 DCHECK_GT(bounds().width(), border.width()); | |
| 72 DCHECK_GT(bounds().height(), border.height()); | |
| 73 | |
| 74 // Sanity Check on |border| | |
| 75 DCHECK_LT(border.x(), border.width()); | |
| 76 DCHECK_LT(border.y(), border.height()); | |
| 77 DCHECK_GT(border.x(), 0); | |
| 78 DCHECK_GT(border.y(), 0); | |
| 79 | |
| 80 // |aperture| is in image space. It cannot exceed the bounds of the bitmap. | |
| 81 DCHECK(!aperture.size().IsEmpty()); | |
| 82 DCHECK(gfx::Rect(image_bounds.width(), image_bounds.height()) | |
| 83 .Contains(aperture)); | |
| 84 | |
| 85 // Avoid the degenerate cases where the aperture touches the edge of the | |
| 86 // image. | |
| 87 DCHECK_LT(aperture.width(), image_bounds.width() - 1); | |
| 88 DCHECK_LT(aperture.height(), image_bounds.height()-1); | |
| 89 DCHECK_GT(aperture.x(), 0); | |
| 90 DCHECK_GT(aperture.y(), 0); | |
| 91 | |
| 92 bool damaged = false; | |
|
aelias_OOO_until_Jul13
2013/08/28 22:28:29
Please reformulate this as:
if (image_bounds_ ==
powei
2013/08/30 05:17:15
Done.
| |
| 93 | |
| 94 if (image_bounds_ != image_bounds) { | |
| 95 image_bounds_ = image_bounds; | |
| 96 damaged = true; | |
| 97 } | |
| 98 | |
| 99 if (image_aperture_ != aperture) { | |
| 100 image_aperture_ = aperture; | |
| 101 damaged = true; | |
| 102 } | |
| 103 | |
| 104 if (border_ != border) { | |
| 105 border_ = border; | |
| 106 damaged = true; | |
| 107 } | |
| 108 | |
| 109 if (fill_center_ != fill_center) { | |
| 110 fill_center_ = fill_center; | |
| 111 damaged = true; | |
| 112 } | |
| 113 | |
| 114 if (damaged) | |
| 115 NoteLayerPropertyChanged(); | |
| 56 } | 116 } |
| 57 | 117 |
| 58 bool NinePatchLayerImpl::WillDraw(DrawMode draw_mode, | 118 bool NinePatchLayerImpl::WillDraw(DrawMode draw_mode, |
| 59 ResourceProvider* resource_provider) { | 119 ResourceProvider* resource_provider) { |
| 60 if (!resource_id_ || draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE) | 120 if (!ui_resource_id_ || draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE) |
| 61 return false; | 121 return false; |
| 62 return LayerImpl::WillDraw(draw_mode, resource_provider); | 122 return LayerImpl::WillDraw(draw_mode, resource_provider); |
| 63 } | 123 } |
| 64 | 124 |
| 65 void NinePatchLayerImpl::AppendQuads(QuadSink* quad_sink, | 125 void NinePatchLayerImpl::AppendQuads(QuadSink* quad_sink, |
| 66 AppendQuadsData* append_quads_data) { | 126 AppendQuadsData* append_quads_data) { |
| 127 if (!ui_resource_id_) | |
| 128 return; | |
| 129 | |
| 130 ResourceProvider::ResourceId resource = | |
| 131 layer_tree_impl()->ResourceIdForUIResource(ui_resource_id_); | |
| 132 | |
| 133 if (!resource) | |
| 134 return; | |
| 135 | |
| 67 SharedQuadState* shared_quad_state = | 136 SharedQuadState* shared_quad_state = |
| 68 quad_sink->UseSharedQuadState(CreateSharedQuadState()); | 137 quad_sink->UseSharedQuadState(CreateSharedQuadState()); |
| 69 AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data); | 138 AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data); |
| 70 | 139 |
| 71 if (!resource_id_) | |
| 72 return; | |
| 73 | |
| 74 static const bool flipped = false; | 140 static const bool flipped = false; |
| 75 static const bool premultiplied_alpha = true; | 141 static const bool premultiplied_alpha = true; |
| 76 | 142 |
| 77 DCHECK(!bounds().IsEmpty()); | 143 DCHECK(!bounds().IsEmpty()); |
| 78 | 144 |
| 79 // NinePatch border widths in bitmap pixel space | 145 // NinePatch border widths in layer space. |
| 80 int left_width = image_aperture_.x(); | 146 int layer_left_width = border_.x(); |
| 81 int top_height = image_aperture_.y(); | 147 int layer_top_height = border_.y(); |
| 82 int right_width = image_bounds_.width() - image_aperture_.right(); | 148 int layer_right_width = border_.width() - layer_left_width; |
| 83 int bottom_height = image_bounds_.height() - image_aperture_.bottom(); | 149 int layer_bottom_height = border_.height() - layer_top_height; |
| 84 | 150 |
| 85 // If layer can't fit the corners, clip to show the outer edges of the | 151 int layer_middle_width = bounds().width() - border_.width(); |
| 86 // image. | 152 int layer_middle_height = bounds().height() - border_.height(); |
| 87 int corner_total_width = left_width + right_width; | |
| 88 int middle_width = bounds().width() - corner_total_width; | |
| 89 if (middle_width < 0) { | |
| 90 float left_width_proportion = | |
| 91 static_cast<float>(left_width) / corner_total_width; | |
| 92 int left_width_crop = middle_width * left_width_proportion; | |
| 93 left_width += left_width_crop; | |
| 94 right_width = bounds().width() - left_width; | |
| 95 middle_width = 0; | |
| 96 } | |
| 97 int corner_total_height = top_height + bottom_height; | |
| 98 int middle_height = bounds().height() - corner_total_height; | |
| 99 if (middle_height < 0) { | |
| 100 float top_height_proportion = | |
| 101 static_cast<float>(top_height) / corner_total_height; | |
| 102 int top_height_crop = middle_height * top_height_proportion; | |
| 103 top_height += top_height_crop; | |
| 104 bottom_height = bounds().height() - top_height; | |
| 105 middle_height = 0; | |
| 106 } | |
| 107 | 153 |
| 108 // Patch positions in layer space | 154 // Patch positions in layer space |
| 109 gfx::Rect top_left(0, 0, left_width, top_height); | 155 gfx::Rect layer_top_left(0, 0, layer_left_width, layer_top_height); |
| 110 gfx::Rect top_right( | 156 gfx::Rect layer_top_right(bounds().width() - layer_right_width, |
| 111 bounds().width() - right_width, 0, right_width, top_height); | 157 0, |
| 112 gfx::Rect bottom_left( | 158 layer_right_width, |
| 113 0, bounds().height() - bottom_height, left_width, bottom_height); | 159 layer_top_height); |
| 114 gfx::Rect bottom_right( | 160 gfx::Rect layer_bottom_left(0, |
| 115 top_right.x(), bottom_left.y(), right_width, bottom_height); | 161 bounds().height() - layer_bottom_height, |
| 116 gfx::Rect top(top_left.right(), 0, middle_width, top_height); | 162 layer_left_width, |
| 117 gfx::Rect left(0, top_left.bottom(), left_width, middle_height); | 163 layer_bottom_height); |
| 118 gfx::Rect right(top_right.x(), | 164 gfx::Rect layer_bottom_right(layer_top_right.x(), |
| 119 top_right.bottom(), | 165 layer_bottom_left.y(), |
| 120 right_width, | 166 layer_right_width, |
| 121 left.height()); | 167 layer_bottom_height); |
| 122 gfx::Rect bottom(top.x(), bottom_left.y(), top.width(), bottom_height); | 168 gfx::Rect layer_top( |
| 169 layer_top_left.right(), 0, layer_middle_width, layer_top_height); | |
| 170 gfx::Rect layer_left( | |
| 171 0, layer_top_left.bottom(), layer_left_width, layer_middle_height); | |
| 172 gfx::Rect layer_right(layer_top_right.x(), | |
| 173 layer_top_right.bottom(), | |
| 174 layer_right_width, | |
| 175 layer_left.height()); | |
| 176 gfx::Rect layer_bottom(layer_top.x(), | |
| 177 layer_bottom_left.y(), | |
| 178 layer_top.width(), | |
| 179 layer_bottom_height); | |
| 180 gfx::Rect layer_center(layer_left_width, | |
| 181 layer_top_height, | |
| 182 layer_middle_width, | |
| 183 layer_middle_height); | |
| 123 | 184 |
| 124 float img_width = image_bounds_.width(); | 185 // Note the following values are in image (bitmap) space. |
| 125 float img_height = image_bounds_.height(); | 186 float image_width = image_bounds_.width(); |
| 187 float image_height = image_bounds_.height(); | |
| 126 | 188 |
| 189 int image_aperture_left_width = image_aperture_.x(); | |
| 190 int image_aperture_top_height = image_aperture_.y(); | |
| 191 int image_aperture_right_width = image_width - image_aperture_.right(); | |
| 192 int image_aperture_bottom_height = image_height - image_aperture_.bottom(); | |
| 127 // Patch positions in bitmap UV space (from zero to one) | 193 // Patch positions in bitmap UV space (from zero to one) |
| 128 gfx::RectF uv_top_left = NormalizedRect(0, | 194 gfx::RectF uv_top_left = NormalizedRect(0, |
| 129 0, | 195 0, |
| 130 left_width, | 196 image_aperture_left_width, |
| 131 top_height, | 197 image_aperture_top_height, |
| 132 img_width, | 198 image_width, |
| 133 img_height); | 199 image_height); |
| 134 gfx::RectF uv_top_right = NormalizedRect(img_width - right_width, | 200 gfx::RectF uv_top_right = |
| 135 0, | 201 NormalizedRect(image_width - image_aperture_right_width, |
| 136 right_width, | 202 0, |
| 137 top_height, | 203 image_aperture_right_width, |
| 138 img_width, | 204 image_aperture_top_height, |
| 139 img_height); | 205 image_width, |
| 140 gfx::RectF uv_bottom_left = NormalizedRect(0, | 206 image_height); |
| 141 img_height - bottom_height, | 207 gfx::RectF uv_bottom_left = |
| 142 left_width, | 208 NormalizedRect(0, |
| 143 bottom_height, | 209 image_height - image_aperture_bottom_height, |
| 144 img_width, | 210 image_aperture_left_width, |
| 145 img_height); | 211 image_aperture_bottom_height, |
| 146 gfx::RectF uv_bottom_right = NormalizedRect(img_width - right_width, | 212 image_width, |
| 147 img_height - bottom_height, | 213 image_height); |
| 148 right_width, | 214 gfx::RectF uv_bottom_right = |
| 149 bottom_height, | 215 NormalizedRect(image_width - image_aperture_right_width, |
| 150 img_width, | 216 image_height - image_aperture_bottom_height, |
| 151 img_height); | 217 image_aperture_right_width, |
| 152 gfx::RectF uv_top(uv_top_left.right(), | 218 image_aperture_bottom_height, |
| 153 0, | 219 image_width, |
| 154 (img_width - left_width - right_width) / img_width, | 220 image_height); |
| 155 (top_height) / img_height); | 221 gfx::RectF uv_top( |
| 222 uv_top_left.right(), | |
| 223 0, | |
| 224 (image_width - image_aperture_left_width - image_aperture_right_width) / | |
| 225 image_width, | |
| 226 (image_aperture_top_height) / image_height); | |
| 156 gfx::RectF uv_left(0, | 227 gfx::RectF uv_left(0, |
| 157 uv_top_left.bottom(), | 228 uv_top_left.bottom(), |
| 158 left_width / img_width, | 229 image_aperture_left_width / image_width, |
| 159 (img_height - top_height - bottom_height) / img_height); | 230 (image_height - image_aperture_top_height - |
| 231 image_aperture_bottom_height) / | |
| 232 image_height); | |
| 160 gfx::RectF uv_right(uv_top_right.x(), | 233 gfx::RectF uv_right(uv_top_right.x(), |
| 161 uv_top_right.bottom(), | 234 uv_top_right.bottom(), |
| 162 right_width / img_width, | 235 image_aperture_right_width / image_width, |
| 163 uv_left.height()); | 236 uv_left.height()); |
| 164 gfx::RectF uv_bottom(uv_top.x(), | 237 gfx::RectF uv_bottom(uv_top.x(), |
| 165 uv_bottom_left.y(), | 238 uv_bottom_left.y(), |
| 166 uv_top.width(), | 239 uv_top.width(), |
| 167 bottom_height / img_height); | 240 image_aperture_bottom_height / image_height); |
| 241 gfx::RectF uv_center(uv_top_left.right(), | |
| 242 uv_top_left.bottom(), | |
| 243 uv_top.width(), | |
| 244 uv_left.height()); | |
| 168 | 245 |
| 169 // Nothing is opaque here. | 246 // Nothing is opaque here. |
| 170 // TODO(danakj): Should we look at the SkBitmaps to determine opaqueness? | 247 // TODO(danakj): Should we look at the SkBitmaps to determine opaqueness? |
| 171 gfx::Rect opaque_rect; | 248 gfx::Rect opaque_rect; |
| 172 const float vertex_opacity[] = {1.0f, 1.0f, 1.0f, 1.0f}; | 249 const float vertex_opacity[] = {1.0f, 1.0f, 1.0f, 1.0f}; |
| 173 scoped_ptr<TextureDrawQuad> quad; | 250 scoped_ptr<TextureDrawQuad> quad; |
| 174 | 251 |
| 175 quad = TextureDrawQuad::Create(); | 252 quad = TextureDrawQuad::Create(); |
| 176 quad->SetNew(shared_quad_state, | 253 quad->SetNew(shared_quad_state, |
| 177 top_left, | 254 layer_top_left, |
| 178 opaque_rect, | 255 opaque_rect, |
| 179 resource_id_, | 256 resource, |
| 180 premultiplied_alpha, | 257 premultiplied_alpha, |
| 181 uv_top_left.origin(), | 258 uv_top_left.origin(), |
| 182 uv_top_left.bottom_right(), | 259 uv_top_left.bottom_right(), |
| 183 SK_ColorTRANSPARENT, | 260 SK_ColorTRANSPARENT, |
| 184 vertex_opacity, | 261 vertex_opacity, |
| 185 flipped); | 262 flipped); |
| 186 quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data); | 263 quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data); |
| 187 | 264 |
| 188 quad = TextureDrawQuad::Create(); | 265 quad = TextureDrawQuad::Create(); |
| 189 quad->SetNew(shared_quad_state, | 266 quad->SetNew(shared_quad_state, |
| 190 top_right, | 267 layer_top_right, |
| 191 opaque_rect, | 268 opaque_rect, |
| 192 resource_id_, | 269 resource, |
| 193 premultiplied_alpha, | 270 premultiplied_alpha, |
| 194 uv_top_right.origin(), | 271 uv_top_right.origin(), |
| 195 uv_top_right.bottom_right(), | 272 uv_top_right.bottom_right(), |
| 196 SK_ColorTRANSPARENT, | 273 SK_ColorTRANSPARENT, |
| 197 vertex_opacity, | 274 vertex_opacity, |
| 198 flipped); | 275 flipped); |
| 199 quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data); | 276 quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data); |
| 200 | 277 |
| 201 quad = TextureDrawQuad::Create(); | 278 quad = TextureDrawQuad::Create(); |
| 202 quad->SetNew(shared_quad_state, | 279 quad->SetNew(shared_quad_state, |
| 203 bottom_left, | 280 layer_bottom_left, |
| 204 opaque_rect, | 281 opaque_rect, |
| 205 resource_id_, | 282 resource, |
| 206 premultiplied_alpha, | 283 premultiplied_alpha, |
| 207 uv_bottom_left.origin(), | 284 uv_bottom_left.origin(), |
| 208 uv_bottom_left.bottom_right(), | 285 uv_bottom_left.bottom_right(), |
| 209 SK_ColorTRANSPARENT, | 286 SK_ColorTRANSPARENT, |
| 210 vertex_opacity, | 287 vertex_opacity, |
| 211 flipped); | 288 flipped); |
| 212 quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data); | 289 quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data); |
| 213 | 290 |
| 214 quad = TextureDrawQuad::Create(); | 291 quad = TextureDrawQuad::Create(); |
| 215 quad->SetNew(shared_quad_state, | 292 quad->SetNew(shared_quad_state, |
| 216 bottom_right, | 293 layer_bottom_right, |
| 217 opaque_rect, | 294 opaque_rect, |
| 218 resource_id_, | 295 resource, |
| 219 premultiplied_alpha, | 296 premultiplied_alpha, |
| 220 uv_bottom_right.origin(), | 297 uv_bottom_right.origin(), |
| 221 uv_bottom_right.bottom_right(), | 298 uv_bottom_right.bottom_right(), |
| 222 SK_ColorTRANSPARENT, | 299 SK_ColorTRANSPARENT, |
| 223 vertex_opacity, | 300 vertex_opacity, |
| 224 flipped); | 301 flipped); |
| 225 quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data); | 302 quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data); |
| 226 | 303 |
| 227 quad = TextureDrawQuad::Create(); | 304 quad = TextureDrawQuad::Create(); |
| 228 quad->SetNew(shared_quad_state, | 305 quad->SetNew(shared_quad_state, |
| 229 top, | 306 layer_top, |
| 230 opaque_rect, | 307 opaque_rect, |
| 231 resource_id_, | 308 resource, |
| 232 premultiplied_alpha, | 309 premultiplied_alpha, |
| 233 uv_top.origin(), | 310 uv_top.origin(), |
| 234 uv_top.bottom_right(), | 311 uv_top.bottom_right(), |
| 235 SK_ColorTRANSPARENT, | 312 SK_ColorTRANSPARENT, |
| 236 vertex_opacity, | 313 vertex_opacity, |
| 237 flipped); | 314 flipped); |
| 238 quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data); | 315 quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data); |
| 239 | 316 |
| 240 quad = TextureDrawQuad::Create(); | 317 quad = TextureDrawQuad::Create(); |
| 241 quad->SetNew(shared_quad_state, | 318 quad->SetNew(shared_quad_state, |
| 242 left, | 319 layer_left, |
| 243 opaque_rect, | 320 opaque_rect, |
| 244 resource_id_, | 321 resource, |
| 245 premultiplied_alpha, | 322 premultiplied_alpha, |
| 246 uv_left.origin(), | 323 uv_left.origin(), |
| 247 uv_left.bottom_right(), | 324 uv_left.bottom_right(), |
| 248 SK_ColorTRANSPARENT, | 325 SK_ColorTRANSPARENT, |
| 249 vertex_opacity, | 326 vertex_opacity, |
| 250 flipped); | 327 flipped); |
| 251 quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data); | 328 quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data); |
| 252 | 329 |
| 253 quad = TextureDrawQuad::Create(); | 330 quad = TextureDrawQuad::Create(); |
| 254 quad->SetNew(shared_quad_state, | 331 quad->SetNew(shared_quad_state, |
| 255 right, | 332 layer_right, |
| 256 opaque_rect, | 333 opaque_rect, |
| 257 resource_id_, | 334 resource, |
| 258 premultiplied_alpha, | 335 premultiplied_alpha, |
| 259 uv_right.origin(), | 336 uv_right.origin(), |
| 260 uv_right.bottom_right(), | 337 uv_right.bottom_right(), |
| 261 SK_ColorTRANSPARENT, | 338 SK_ColorTRANSPARENT, |
| 262 vertex_opacity, | 339 vertex_opacity, |
| 263 flipped); | 340 flipped); |
| 264 quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data); | 341 quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data); |
| 265 | 342 |
| 266 quad = TextureDrawQuad::Create(); | 343 quad = TextureDrawQuad::Create(); |
| 267 quad->SetNew(shared_quad_state, | 344 quad->SetNew(shared_quad_state, |
| 268 bottom, | 345 layer_bottom, |
| 269 opaque_rect, | 346 opaque_rect, |
| 270 resource_id_, | 347 resource, |
| 271 premultiplied_alpha, | 348 premultiplied_alpha, |
| 272 uv_bottom.origin(), | 349 uv_bottom.origin(), |
| 273 uv_bottom.bottom_right(), | 350 uv_bottom.bottom_right(), |
| 274 SK_ColorTRANSPARENT, | 351 SK_ColorTRANSPARENT, |
| 275 vertex_opacity, | 352 vertex_opacity, |
| 276 flipped); | 353 flipped); |
| 277 quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data); | 354 quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data); |
| 278 } | |
| 279 | 355 |
| 280 void NinePatchLayerImpl::DidLoseOutputSurface() { | 356 if (fill_center_) { |
| 281 resource_id_ = 0; | 357 quad = TextureDrawQuad::Create(); |
| 358 quad->SetNew(shared_quad_state, | |
| 359 layer_center, | |
| 360 opaque_rect, | |
| 361 resource, | |
| 362 premultiplied_alpha, | |
| 363 uv_center.origin(), | |
| 364 uv_center.bottom_right(), | |
| 365 SK_ColorTRANSPARENT, | |
| 366 vertex_opacity, | |
| 367 flipped); | |
| 368 quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data); | |
| 369 } | |
| 282 } | 370 } |
| 283 | 371 |
| 284 const char* NinePatchLayerImpl::LayerTypeAsString() const { | 372 const char* NinePatchLayerImpl::LayerTypeAsString() const { |
| 285 return "cc::NinePatchLayerImpl"; | 373 return "cc::NinePatchLayerImpl"; |
| 286 } | 374 } |
| 287 | 375 |
| 288 base::DictionaryValue* NinePatchLayerImpl::LayerTreeAsJson() const { | 376 base::DictionaryValue* NinePatchLayerImpl::LayerTreeAsJson() const { |
| 289 base::DictionaryValue* result = LayerImpl::LayerTreeAsJson(); | 377 base::DictionaryValue* result = LayerImpl::LayerTreeAsJson(); |
| 290 | 378 |
| 291 base::ListValue* list = new base::ListValue; | 379 base::ListValue* list = new base::ListValue; |
| 292 list->AppendInteger(image_aperture_.origin().x()); | 380 list->AppendInteger(image_aperture_.origin().x()); |
| 293 list->AppendInteger(image_aperture_.origin().y()); | 381 list->AppendInteger(image_aperture_.origin().y()); |
| 294 list->AppendInteger(image_aperture_.size().width()); | 382 list->AppendInteger(image_aperture_.size().width()); |
| 295 list->AppendInteger(image_aperture_.size().height()); | 383 list->AppendInteger(image_aperture_.size().height()); |
| 296 result->Set("ImageAperture", list); | 384 result->Set("ImageAperture", list); |
| 297 | 385 |
| 298 list = new base::ListValue; | 386 result->Set("ImageBounds", MathUtil::AsValue(image_bounds_).release()); |
| 299 list->AppendInteger(image_bounds_.width()); | 387 result->Set("Border", MathUtil::AsValue(border_).release()); |
| 300 list->AppendInteger(image_bounds_.height()); | 388 |
| 301 result->Set("ImageBounds", list); | 389 base::FundamentalValue* fill_center = |
| 390 base::Value::CreateBooleanValue(fill_center_); | |
| 391 result->Set("FillCenter", fill_center); | |
| 302 | 392 |
| 303 return result; | 393 return result; |
| 304 } | 394 } |
| 305 | 395 |
| 306 } // namespace cc | 396 } // namespace cc |
| OLD | NEW |