| 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 | 75 |
| 76 // |aperture| is in image space. It cannot exceed the bounds of the bitmap. | 76 // |aperture| is in image space. It cannot exceed the bounds of the bitmap. |
| 77 DCHECK(!image_aperture_.size().IsEmpty()); | 77 DCHECK(!image_aperture_.size().IsEmpty()); |
| 78 DCHECK(gfx::Rect(image_bounds_).Contains(image_aperture_)) | 78 DCHECK(gfx::Rect(image_bounds_).Contains(image_aperture_)) |
| 79 << "image_bounds_ " << gfx::Rect(image_bounds_).ToString() | 79 << "image_bounds_ " << gfx::Rect(image_bounds_).ToString() |
| 80 << " image_aperture_ " << image_aperture_.ToString(); | 80 << " image_aperture_ " << image_aperture_.ToString(); |
| 81 } | 81 } |
| 82 | 82 |
| 83 void NinePatchLayerImpl::AppendQuads( | 83 void NinePatchLayerImpl::AppendQuads( |
| 84 RenderPass* render_pass, | 84 RenderPass* render_pass, |
| 85 const Occlusion& occlusion_in_content_space, | |
| 86 AppendQuadsData* append_quads_data) { | 85 AppendQuadsData* append_quads_data) { |
| 87 CheckGeometryLimitations(); | 86 CheckGeometryLimitations(); |
| 88 SharedQuadState* shared_quad_state = | 87 SharedQuadState* shared_quad_state = |
| 89 render_pass->CreateAndAppendSharedQuadState(); | 88 render_pass->CreateAndAppendSharedQuadState(); |
| 90 PopulateSharedQuadState(shared_quad_state); | 89 PopulateSharedQuadState(shared_quad_state); |
| 91 | 90 |
| 92 AppendDebugBorderQuad( | 91 AppendDebugBorderQuad( |
| 93 render_pass, content_bounds(), shared_quad_state, append_quads_data); | 92 render_pass, content_bounds(), shared_quad_state, append_quads_data); |
| 94 | 93 |
| 95 if (!ui_resource_id_) | 94 if (!ui_resource_id_) |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 uv_top_left.bottom(), | 206 uv_top_left.bottom(), |
| 208 uv_top.width(), | 207 uv_top.width(), |
| 209 uv_left.height()); | 208 uv_left.height()); |
| 210 | 209 |
| 211 gfx::Rect opaque_rect; | 210 gfx::Rect opaque_rect; |
| 212 gfx::Rect visible_rect; | 211 gfx::Rect visible_rect; |
| 213 const float vertex_opacity[] = {1.0f, 1.0f, 1.0f, 1.0f}; | 212 const float vertex_opacity[] = {1.0f, 1.0f, 1.0f, 1.0f}; |
| 214 const bool opaque = layer_tree_impl()->IsUIResourceOpaque(ui_resource_id_); | 213 const bool opaque = layer_tree_impl()->IsUIResourceOpaque(ui_resource_id_); |
| 215 | 214 |
| 216 visible_rect = | 215 visible_rect = |
| 217 occlusion_in_content_space.GetUnoccludedContentRect(layer_top_left); | 216 draw_properties().occlusion_in_content_space.GetUnoccludedContentRect( |
| 217 layer_top_left); |
| 218 opaque_rect = opaque ? visible_rect : gfx::Rect(); | 218 opaque_rect = opaque ? visible_rect : gfx::Rect(); |
| 219 if (!visible_rect.IsEmpty()) { | 219 if (!visible_rect.IsEmpty()) { |
| 220 TextureDrawQuad* quad = | 220 TextureDrawQuad* quad = |
| 221 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); | 221 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); |
| 222 quad->SetNew(shared_quad_state, | 222 quad->SetNew(shared_quad_state, |
| 223 layer_top_left, | 223 layer_top_left, |
| 224 opaque_rect, | 224 opaque_rect, |
| 225 visible_rect, | 225 visible_rect, |
| 226 resource, | 226 resource, |
| 227 premultiplied_alpha, | 227 premultiplied_alpha, |
| 228 uv_top_left.origin(), | 228 uv_top_left.origin(), |
| 229 uv_top_left.bottom_right(), | 229 uv_top_left.bottom_right(), |
| 230 SK_ColorTRANSPARENT, | 230 SK_ColorTRANSPARENT, |
| 231 vertex_opacity, | 231 vertex_opacity, |
| 232 flipped, | 232 flipped, |
| 233 nearest_neighbor); | 233 nearest_neighbor); |
| 234 } | 234 } |
| 235 | 235 |
| 236 visible_rect = | 236 visible_rect = |
| 237 occlusion_in_content_space.GetUnoccludedContentRect(layer_top_right); | 237 draw_properties().occlusion_in_content_space.GetUnoccludedContentRect( |
| 238 layer_top_right); |
| 238 opaque_rect = opaque ? visible_rect : gfx::Rect(); | 239 opaque_rect = opaque ? visible_rect : gfx::Rect(); |
| 239 if (!visible_rect.IsEmpty()) { | 240 if (!visible_rect.IsEmpty()) { |
| 240 TextureDrawQuad* quad = | 241 TextureDrawQuad* quad = |
| 241 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); | 242 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); |
| 242 quad->SetNew(shared_quad_state, | 243 quad->SetNew(shared_quad_state, |
| 243 layer_top_right, | 244 layer_top_right, |
| 244 opaque_rect, | 245 opaque_rect, |
| 245 visible_rect, | 246 visible_rect, |
| 246 resource, | 247 resource, |
| 247 premultiplied_alpha, | 248 premultiplied_alpha, |
| 248 uv_top_right.origin(), | 249 uv_top_right.origin(), |
| 249 uv_top_right.bottom_right(), | 250 uv_top_right.bottom_right(), |
| 250 SK_ColorTRANSPARENT, | 251 SK_ColorTRANSPARENT, |
| 251 vertex_opacity, | 252 vertex_opacity, |
| 252 flipped, | 253 flipped, |
| 253 nearest_neighbor); | 254 nearest_neighbor); |
| 254 } | 255 } |
| 255 | 256 |
| 256 visible_rect = | 257 visible_rect = |
| 257 occlusion_in_content_space.GetUnoccludedContentRect(layer_bottom_left); | 258 draw_properties().occlusion_in_content_space.GetUnoccludedContentRect( |
| 259 layer_bottom_left); |
| 258 opaque_rect = opaque ? visible_rect : gfx::Rect(); | 260 opaque_rect = opaque ? visible_rect : gfx::Rect(); |
| 259 if (!visible_rect.IsEmpty()) { | 261 if (!visible_rect.IsEmpty()) { |
| 260 TextureDrawQuad* quad = | 262 TextureDrawQuad* quad = |
| 261 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); | 263 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); |
| 262 quad->SetNew(shared_quad_state, | 264 quad->SetNew(shared_quad_state, |
| 263 layer_bottom_left, | 265 layer_bottom_left, |
| 264 opaque_rect, | 266 opaque_rect, |
| 265 visible_rect, | 267 visible_rect, |
| 266 resource, | 268 resource, |
| 267 premultiplied_alpha, | 269 premultiplied_alpha, |
| 268 uv_bottom_left.origin(), | 270 uv_bottom_left.origin(), |
| 269 uv_bottom_left.bottom_right(), | 271 uv_bottom_left.bottom_right(), |
| 270 SK_ColorTRANSPARENT, | 272 SK_ColorTRANSPARENT, |
| 271 vertex_opacity, | 273 vertex_opacity, |
| 272 flipped, | 274 flipped, |
| 273 nearest_neighbor); | 275 nearest_neighbor); |
| 274 } | 276 } |
| 275 | 277 |
| 276 visible_rect = | 278 visible_rect = |
| 277 occlusion_in_content_space.GetUnoccludedContentRect(layer_bottom_right); | 279 draw_properties().occlusion_in_content_space.GetUnoccludedContentRect( |
| 280 layer_bottom_right); |
| 278 opaque_rect = opaque ? visible_rect : gfx::Rect(); | 281 opaque_rect = opaque ? visible_rect : gfx::Rect(); |
| 279 if (!visible_rect.IsEmpty()) { | 282 if (!visible_rect.IsEmpty()) { |
| 280 TextureDrawQuad* quad = | 283 TextureDrawQuad* quad = |
| 281 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); | 284 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); |
| 282 quad->SetNew(shared_quad_state, | 285 quad->SetNew(shared_quad_state, |
| 283 layer_bottom_right, | 286 layer_bottom_right, |
| 284 opaque_rect, | 287 opaque_rect, |
| 285 visible_rect, | 288 visible_rect, |
| 286 resource, | 289 resource, |
| 287 premultiplied_alpha, | 290 premultiplied_alpha, |
| 288 uv_bottom_right.origin(), | 291 uv_bottom_right.origin(), |
| 289 uv_bottom_right.bottom_right(), | 292 uv_bottom_right.bottom_right(), |
| 290 SK_ColorTRANSPARENT, | 293 SK_ColorTRANSPARENT, |
| 291 vertex_opacity, | 294 vertex_opacity, |
| 292 flipped, | 295 flipped, |
| 293 nearest_neighbor); | 296 nearest_neighbor); |
| 294 } | 297 } |
| 295 | 298 |
| 296 visible_rect = occlusion_in_content_space.GetUnoccludedContentRect(layer_top); | 299 visible_rect = |
| 300 draw_properties().occlusion_in_content_space.GetUnoccludedContentRect( |
| 301 layer_top); |
| 297 opaque_rect = opaque ? visible_rect : gfx::Rect(); | 302 opaque_rect = opaque ? visible_rect : gfx::Rect(); |
| 298 if (!visible_rect.IsEmpty()) { | 303 if (!visible_rect.IsEmpty()) { |
| 299 TextureDrawQuad* quad = | 304 TextureDrawQuad* quad = |
| 300 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); | 305 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); |
| 301 quad->SetNew(shared_quad_state, | 306 quad->SetNew(shared_quad_state, |
| 302 layer_top, | 307 layer_top, |
| 303 opaque_rect, | 308 opaque_rect, |
| 304 visible_rect, | 309 visible_rect, |
| 305 resource, | 310 resource, |
| 306 premultiplied_alpha, | 311 premultiplied_alpha, |
| 307 uv_top.origin(), | 312 uv_top.origin(), |
| 308 uv_top.bottom_right(), | 313 uv_top.bottom_right(), |
| 309 SK_ColorTRANSPARENT, | 314 SK_ColorTRANSPARENT, |
| 310 vertex_opacity, | 315 vertex_opacity, |
| 311 flipped, | 316 flipped, |
| 312 nearest_neighbor); | 317 nearest_neighbor); |
| 313 } | 318 } |
| 314 | 319 |
| 315 visible_rect = | 320 visible_rect = |
| 316 occlusion_in_content_space.GetUnoccludedContentRect(layer_left); | 321 draw_properties().occlusion_in_content_space.GetUnoccludedContentRect( |
| 322 layer_left); |
| 317 opaque_rect = opaque ? visible_rect : gfx::Rect(); | 323 opaque_rect = opaque ? visible_rect : gfx::Rect(); |
| 318 if (!visible_rect.IsEmpty()) { | 324 if (!visible_rect.IsEmpty()) { |
| 319 TextureDrawQuad* quad = | 325 TextureDrawQuad* quad = |
| 320 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); | 326 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); |
| 321 quad->SetNew(shared_quad_state, | 327 quad->SetNew(shared_quad_state, |
| 322 layer_left, | 328 layer_left, |
| 323 opaque_rect, | 329 opaque_rect, |
| 324 visible_rect, | 330 visible_rect, |
| 325 resource, | 331 resource, |
| 326 premultiplied_alpha, | 332 premultiplied_alpha, |
| 327 uv_left.origin(), | 333 uv_left.origin(), |
| 328 uv_left.bottom_right(), | 334 uv_left.bottom_right(), |
| 329 SK_ColorTRANSPARENT, | 335 SK_ColorTRANSPARENT, |
| 330 vertex_opacity, | 336 vertex_opacity, |
| 331 flipped, | 337 flipped, |
| 332 nearest_neighbor); | 338 nearest_neighbor); |
| 333 } | 339 } |
| 334 | 340 |
| 335 visible_rect = | 341 visible_rect = |
| 336 occlusion_in_content_space.GetUnoccludedContentRect(layer_right); | 342 draw_properties().occlusion_in_content_space.GetUnoccludedContentRect( |
| 343 layer_right); |
| 337 opaque_rect = opaque ? visible_rect : gfx::Rect(); | 344 opaque_rect = opaque ? visible_rect : gfx::Rect(); |
| 338 if (!visible_rect.IsEmpty()) { | 345 if (!visible_rect.IsEmpty()) { |
| 339 TextureDrawQuad* quad = | 346 TextureDrawQuad* quad = |
| 340 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); | 347 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); |
| 341 quad->SetNew(shared_quad_state, | 348 quad->SetNew(shared_quad_state, |
| 342 layer_right, | 349 layer_right, |
| 343 opaque_rect, | 350 opaque_rect, |
| 344 layer_right, | 351 layer_right, |
| 345 resource, | 352 resource, |
| 346 premultiplied_alpha, | 353 premultiplied_alpha, |
| 347 uv_right.origin(), | 354 uv_right.origin(), |
| 348 uv_right.bottom_right(), | 355 uv_right.bottom_right(), |
| 349 SK_ColorTRANSPARENT, | 356 SK_ColorTRANSPARENT, |
| 350 vertex_opacity, | 357 vertex_opacity, |
| 351 flipped, | 358 flipped, |
| 352 nearest_neighbor); | 359 nearest_neighbor); |
| 353 } | 360 } |
| 354 | 361 |
| 355 visible_rect = | 362 visible_rect = |
| 356 occlusion_in_content_space.GetUnoccludedContentRect(layer_bottom); | 363 draw_properties().occlusion_in_content_space.GetUnoccludedContentRect( |
| 364 layer_bottom); |
| 357 opaque_rect = opaque ? visible_rect : gfx::Rect(); | 365 opaque_rect = opaque ? visible_rect : gfx::Rect(); |
| 358 if (!visible_rect.IsEmpty()) { | 366 if (!visible_rect.IsEmpty()) { |
| 359 TextureDrawQuad* quad = | 367 TextureDrawQuad* quad = |
| 360 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); | 368 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); |
| 361 quad->SetNew(shared_quad_state, | 369 quad->SetNew(shared_quad_state, |
| 362 layer_bottom, | 370 layer_bottom, |
| 363 opaque_rect, | 371 opaque_rect, |
| 364 visible_rect, | 372 visible_rect, |
| 365 resource, | 373 resource, |
| 366 premultiplied_alpha, | 374 premultiplied_alpha, |
| 367 uv_bottom.origin(), | 375 uv_bottom.origin(), |
| 368 uv_bottom.bottom_right(), | 376 uv_bottom.bottom_right(), |
| 369 SK_ColorTRANSPARENT, | 377 SK_ColorTRANSPARENT, |
| 370 vertex_opacity, | 378 vertex_opacity, |
| 371 flipped, | 379 flipped, |
| 372 nearest_neighbor); | 380 nearest_neighbor); |
| 373 } | 381 } |
| 374 | 382 |
| 375 if (fill_center_) { | 383 if (fill_center_) { |
| 376 visible_rect = | 384 visible_rect = |
| 377 occlusion_in_content_space.GetUnoccludedContentRect(layer_center); | 385 draw_properties().occlusion_in_content_space.GetUnoccludedContentRect( |
| 386 layer_center); |
| 378 opaque_rect = opaque ? visible_rect : gfx::Rect(); | 387 opaque_rect = opaque ? visible_rect : gfx::Rect(); |
| 379 if (!visible_rect.IsEmpty()) { | 388 if (!visible_rect.IsEmpty()) { |
| 380 TextureDrawQuad* quad = | 389 TextureDrawQuad* quad = |
| 381 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); | 390 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); |
| 382 quad->SetNew(shared_quad_state, | 391 quad->SetNew(shared_quad_state, |
| 383 layer_center, | 392 layer_center, |
| 384 opaque_rect, | 393 opaque_rect, |
| 385 visible_rect, | 394 visible_rect, |
| 386 resource, | 395 resource, |
| 387 premultiplied_alpha, | 396 premultiplied_alpha, |
| (...skipping 27 matching lines...) Expand all Loading... |
| 415 result->Set("ImageBounds", list); | 424 result->Set("ImageBounds", list); |
| 416 | 425 |
| 417 result->Set("Border", MathUtil::AsValue(border_).release()); | 426 result->Set("Border", MathUtil::AsValue(border_).release()); |
| 418 | 427 |
| 419 result->SetBoolean("FillCenter", fill_center_); | 428 result->SetBoolean("FillCenter", fill_center_); |
| 420 | 429 |
| 421 return result; | 430 return result; |
| 422 } | 431 } |
| 423 | 432 |
| 424 } // namespace cc | 433 } // namespace cc |
| OLD | NEW |