| 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/base/math_util.h" |
| 10 #include "cc/quads/texture_draw_quad.h" | 10 #include "cc/quads/texture_draw_quad.h" |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 if (!ui_resource_id_) | 95 if (!ui_resource_id_) |
| 96 return; | 96 return; |
| 97 | 97 |
| 98 ResourceProvider::ResourceId resource = | 98 ResourceProvider::ResourceId resource = |
| 99 layer_tree_impl()->ResourceIdForUIResource(ui_resource_id_); | 99 layer_tree_impl()->ResourceIdForUIResource(ui_resource_id_); |
| 100 | 100 |
| 101 if (!resource) | 101 if (!resource) |
| 102 return; | 102 return; |
| 103 | 103 |
| 104 static const bool flipped = false; | 104 static const bool flipped = false; |
| 105 static const bool nearest_neighbor = false; |
| 105 static const bool premultiplied_alpha = true; | 106 static const bool premultiplied_alpha = true; |
| 106 | 107 |
| 107 DCHECK(!bounds().IsEmpty()); | 108 DCHECK(!bounds().IsEmpty()); |
| 108 | 109 |
| 109 // NinePatch border widths in layer space. | 110 // NinePatch border widths in layer space. |
| 110 int layer_left_width = border_.x(); | 111 int layer_left_width = border_.x(); |
| 111 int layer_top_height = border_.y(); | 112 int layer_top_height = border_.y(); |
| 112 int layer_right_width = border_.width() - layer_left_width; | 113 int layer_right_width = border_.width() - layer_left_width; |
| 113 int layer_bottom_height = border_.height() - layer_top_height; | 114 int layer_bottom_height = border_.height() - layer_top_height; |
| 114 | 115 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 quad->SetNew(shared_quad_state, | 222 quad->SetNew(shared_quad_state, |
| 222 layer_top_left, | 223 layer_top_left, |
| 223 opaque_rect, | 224 opaque_rect, |
| 224 visible_rect, | 225 visible_rect, |
| 225 resource, | 226 resource, |
| 226 premultiplied_alpha, | 227 premultiplied_alpha, |
| 227 uv_top_left.origin(), | 228 uv_top_left.origin(), |
| 228 uv_top_left.bottom_right(), | 229 uv_top_left.bottom_right(), |
| 229 SK_ColorTRANSPARENT, | 230 SK_ColorTRANSPARENT, |
| 230 vertex_opacity, | 231 vertex_opacity, |
| 231 flipped); | 232 flipped, |
| 233 nearest_neighbor); |
| 232 } | 234 } |
| 233 | 235 |
| 234 visible_rect = | 236 visible_rect = |
| 235 occlusion_in_content_space.GetUnoccludedContentRect(layer_top_right); | 237 occlusion_in_content_space.GetUnoccludedContentRect(layer_top_right); |
| 236 opaque_rect = opaque ? visible_rect : gfx::Rect(); | 238 opaque_rect = opaque ? visible_rect : gfx::Rect(); |
| 237 if (!visible_rect.IsEmpty()) { | 239 if (!visible_rect.IsEmpty()) { |
| 238 TextureDrawQuad* quad = | 240 TextureDrawQuad* quad = |
| 239 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); | 241 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); |
| 240 quad->SetNew(shared_quad_state, | 242 quad->SetNew(shared_quad_state, |
| 241 layer_top_right, | 243 layer_top_right, |
| 242 opaque_rect, | 244 opaque_rect, |
| 243 visible_rect, | 245 visible_rect, |
| 244 resource, | 246 resource, |
| 245 premultiplied_alpha, | 247 premultiplied_alpha, |
| 246 uv_top_right.origin(), | 248 uv_top_right.origin(), |
| 247 uv_top_right.bottom_right(), | 249 uv_top_right.bottom_right(), |
| 248 SK_ColorTRANSPARENT, | 250 SK_ColorTRANSPARENT, |
| 249 vertex_opacity, | 251 vertex_opacity, |
| 250 flipped); | 252 flipped, |
| 253 nearest_neighbor); |
| 251 } | 254 } |
| 252 | 255 |
| 253 visible_rect = | 256 visible_rect = |
| 254 occlusion_in_content_space.GetUnoccludedContentRect(layer_bottom_left); | 257 occlusion_in_content_space.GetUnoccludedContentRect(layer_bottom_left); |
| 255 opaque_rect = opaque ? visible_rect : gfx::Rect(); | 258 opaque_rect = opaque ? visible_rect : gfx::Rect(); |
| 256 if (!visible_rect.IsEmpty()) { | 259 if (!visible_rect.IsEmpty()) { |
| 257 TextureDrawQuad* quad = | 260 TextureDrawQuad* quad = |
| 258 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); | 261 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); |
| 259 quad->SetNew(shared_quad_state, | 262 quad->SetNew(shared_quad_state, |
| 260 layer_bottom_left, | 263 layer_bottom_left, |
| 261 opaque_rect, | 264 opaque_rect, |
| 262 visible_rect, | 265 visible_rect, |
| 263 resource, | 266 resource, |
| 264 premultiplied_alpha, | 267 premultiplied_alpha, |
| 265 uv_bottom_left.origin(), | 268 uv_bottom_left.origin(), |
| 266 uv_bottom_left.bottom_right(), | 269 uv_bottom_left.bottom_right(), |
| 267 SK_ColorTRANSPARENT, | 270 SK_ColorTRANSPARENT, |
| 268 vertex_opacity, | 271 vertex_opacity, |
| 269 flipped); | 272 flipped, |
| 273 nearest_neighbor); |
| 270 } | 274 } |
| 271 | 275 |
| 272 visible_rect = | 276 visible_rect = |
| 273 occlusion_in_content_space.GetUnoccludedContentRect(layer_bottom_right); | 277 occlusion_in_content_space.GetUnoccludedContentRect(layer_bottom_right); |
| 274 opaque_rect = opaque ? visible_rect : gfx::Rect(); | 278 opaque_rect = opaque ? visible_rect : gfx::Rect(); |
| 275 if (!visible_rect.IsEmpty()) { | 279 if (!visible_rect.IsEmpty()) { |
| 276 TextureDrawQuad* quad = | 280 TextureDrawQuad* quad = |
| 277 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); | 281 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); |
| 278 quad->SetNew(shared_quad_state, | 282 quad->SetNew(shared_quad_state, |
| 279 layer_bottom_right, | 283 layer_bottom_right, |
| 280 opaque_rect, | 284 opaque_rect, |
| 281 visible_rect, | 285 visible_rect, |
| 282 resource, | 286 resource, |
| 283 premultiplied_alpha, | 287 premultiplied_alpha, |
| 284 uv_bottom_right.origin(), | 288 uv_bottom_right.origin(), |
| 285 uv_bottom_right.bottom_right(), | 289 uv_bottom_right.bottom_right(), |
| 286 SK_ColorTRANSPARENT, | 290 SK_ColorTRANSPARENT, |
| 287 vertex_opacity, | 291 vertex_opacity, |
| 288 flipped); | 292 flipped, |
| 293 nearest_neighbor); |
| 289 } | 294 } |
| 290 | 295 |
| 291 visible_rect = occlusion_in_content_space.GetUnoccludedContentRect(layer_top); | 296 visible_rect = occlusion_in_content_space.GetUnoccludedContentRect(layer_top); |
| 292 opaque_rect = opaque ? visible_rect : gfx::Rect(); | 297 opaque_rect = opaque ? visible_rect : gfx::Rect(); |
| 293 if (!visible_rect.IsEmpty()) { | 298 if (!visible_rect.IsEmpty()) { |
| 294 TextureDrawQuad* quad = | 299 TextureDrawQuad* quad = |
| 295 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); | 300 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); |
| 296 quad->SetNew(shared_quad_state, | 301 quad->SetNew(shared_quad_state, |
| 297 layer_top, | 302 layer_top, |
| 298 opaque_rect, | 303 opaque_rect, |
| 299 visible_rect, | 304 visible_rect, |
| 300 resource, | 305 resource, |
| 301 premultiplied_alpha, | 306 premultiplied_alpha, |
| 302 uv_top.origin(), | 307 uv_top.origin(), |
| 303 uv_top.bottom_right(), | 308 uv_top.bottom_right(), |
| 304 SK_ColorTRANSPARENT, | 309 SK_ColorTRANSPARENT, |
| 305 vertex_opacity, | 310 vertex_opacity, |
| 306 flipped); | 311 flipped, |
| 312 nearest_neighbor); |
| 307 } | 313 } |
| 308 | 314 |
| 309 visible_rect = | 315 visible_rect = |
| 310 occlusion_in_content_space.GetUnoccludedContentRect(layer_left); | 316 occlusion_in_content_space.GetUnoccludedContentRect(layer_left); |
| 311 opaque_rect = opaque ? visible_rect : gfx::Rect(); | 317 opaque_rect = opaque ? visible_rect : gfx::Rect(); |
| 312 if (!visible_rect.IsEmpty()) { | 318 if (!visible_rect.IsEmpty()) { |
| 313 TextureDrawQuad* quad = | 319 TextureDrawQuad* quad = |
| 314 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); | 320 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); |
| 315 quad->SetNew(shared_quad_state, | 321 quad->SetNew(shared_quad_state, |
| 316 layer_left, | 322 layer_left, |
| 317 opaque_rect, | 323 opaque_rect, |
| 318 visible_rect, | 324 visible_rect, |
| 319 resource, | 325 resource, |
| 320 premultiplied_alpha, | 326 premultiplied_alpha, |
| 321 uv_left.origin(), | 327 uv_left.origin(), |
| 322 uv_left.bottom_right(), | 328 uv_left.bottom_right(), |
| 323 SK_ColorTRANSPARENT, | 329 SK_ColorTRANSPARENT, |
| 324 vertex_opacity, | 330 vertex_opacity, |
| 325 flipped); | 331 flipped, |
| 332 nearest_neighbor); |
| 326 } | 333 } |
| 327 | 334 |
| 328 visible_rect = | 335 visible_rect = |
| 329 occlusion_in_content_space.GetUnoccludedContentRect(layer_right); | 336 occlusion_in_content_space.GetUnoccludedContentRect(layer_right); |
| 330 opaque_rect = opaque ? visible_rect : gfx::Rect(); | 337 opaque_rect = opaque ? visible_rect : gfx::Rect(); |
| 331 if (!visible_rect.IsEmpty()) { | 338 if (!visible_rect.IsEmpty()) { |
| 332 TextureDrawQuad* quad = | 339 TextureDrawQuad* quad = |
| 333 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); | 340 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); |
| 334 quad->SetNew(shared_quad_state, | 341 quad->SetNew(shared_quad_state, |
| 335 layer_right, | 342 layer_right, |
| 336 opaque_rect, | 343 opaque_rect, |
| 337 layer_right, | 344 layer_right, |
| 338 resource, | 345 resource, |
| 339 premultiplied_alpha, | 346 premultiplied_alpha, |
| 340 uv_right.origin(), | 347 uv_right.origin(), |
| 341 uv_right.bottom_right(), | 348 uv_right.bottom_right(), |
| 342 SK_ColorTRANSPARENT, | 349 SK_ColorTRANSPARENT, |
| 343 vertex_opacity, | 350 vertex_opacity, |
| 344 flipped); | 351 flipped, |
| 352 nearest_neighbor); |
| 345 } | 353 } |
| 346 | 354 |
| 347 visible_rect = | 355 visible_rect = |
| 348 occlusion_in_content_space.GetUnoccludedContentRect(layer_bottom); | 356 occlusion_in_content_space.GetUnoccludedContentRect(layer_bottom); |
| 349 opaque_rect = opaque ? visible_rect : gfx::Rect(); | 357 opaque_rect = opaque ? visible_rect : gfx::Rect(); |
| 350 if (!visible_rect.IsEmpty()) { | 358 if (!visible_rect.IsEmpty()) { |
| 351 TextureDrawQuad* quad = | 359 TextureDrawQuad* quad = |
| 352 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); | 360 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); |
| 353 quad->SetNew(shared_quad_state, | 361 quad->SetNew(shared_quad_state, |
| 354 layer_bottom, | 362 layer_bottom, |
| 355 opaque_rect, | 363 opaque_rect, |
| 356 visible_rect, | 364 visible_rect, |
| 357 resource, | 365 resource, |
| 358 premultiplied_alpha, | 366 premultiplied_alpha, |
| 359 uv_bottom.origin(), | 367 uv_bottom.origin(), |
| 360 uv_bottom.bottom_right(), | 368 uv_bottom.bottom_right(), |
| 361 SK_ColorTRANSPARENT, | 369 SK_ColorTRANSPARENT, |
| 362 vertex_opacity, | 370 vertex_opacity, |
| 363 flipped); | 371 flipped, |
| 372 nearest_neighbor); |
| 364 } | 373 } |
| 365 | 374 |
| 366 if (fill_center_) { | 375 if (fill_center_) { |
| 367 visible_rect = | 376 visible_rect = |
| 368 occlusion_in_content_space.GetUnoccludedContentRect(layer_center); | 377 occlusion_in_content_space.GetUnoccludedContentRect(layer_center); |
| 369 opaque_rect = opaque ? visible_rect : gfx::Rect(); | 378 opaque_rect = opaque ? visible_rect : gfx::Rect(); |
| 370 if (!visible_rect.IsEmpty()) { | 379 if (!visible_rect.IsEmpty()) { |
| 371 TextureDrawQuad* quad = | 380 TextureDrawQuad* quad = |
| 372 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); | 381 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); |
| 373 quad->SetNew(shared_quad_state, | 382 quad->SetNew(shared_quad_state, |
| 374 layer_center, | 383 layer_center, |
| 375 opaque_rect, | 384 opaque_rect, |
| 376 visible_rect, | 385 visible_rect, |
| 377 resource, | 386 resource, |
| 378 premultiplied_alpha, | 387 premultiplied_alpha, |
| 379 uv_center.origin(), | 388 uv_center.origin(), |
| 380 uv_center.bottom_right(), | 389 uv_center.bottom_right(), |
| 381 SK_ColorTRANSPARENT, | 390 SK_ColorTRANSPARENT, |
| 382 vertex_opacity, | 391 vertex_opacity, |
| 383 flipped); | 392 flipped, |
| 393 nearest_neighbor); |
| 384 } | 394 } |
| 385 } | 395 } |
| 386 } | 396 } |
| 387 | 397 |
| 388 const char* NinePatchLayerImpl::LayerTypeAsString() const { | 398 const char* NinePatchLayerImpl::LayerTypeAsString() const { |
| 389 return "cc::NinePatchLayerImpl"; | 399 return "cc::NinePatchLayerImpl"; |
| 390 } | 400 } |
| 391 | 401 |
| 392 base::DictionaryValue* NinePatchLayerImpl::LayerTreeAsJson() const { | 402 base::DictionaryValue* NinePatchLayerImpl::LayerTreeAsJson() const { |
| 393 base::DictionaryValue* result = LayerImpl::LayerTreeAsJson(); | 403 base::DictionaryValue* result = LayerImpl::LayerTreeAsJson(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 405 result->Set("ImageBounds", list); | 415 result->Set("ImageBounds", list); |
| 406 | 416 |
| 407 result->Set("Border", MathUtil::AsValue(border_).release()); | 417 result->Set("Border", MathUtil::AsValue(border_).release()); |
| 408 | 418 |
| 409 result->SetBoolean("FillCenter", fill_center_); | 419 result->SetBoolean("FillCenter", fill_center_); |
| 410 | 420 |
| 411 return result; | 421 return result; |
| 412 } | 422 } |
| 413 | 423 |
| 414 } // namespace cc | 424 } // namespace cc |
| OLD | NEW |