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