| 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" |
| 11 #include "cc/trees/layer_tree_impl.h" | 11 #include "cc/trees/layer_tree_impl.h" |
| 12 #include "cc/trees/occlusion_tracker.h" | 12 #include "cc/trees/occlusion.h" |
| 13 #include "ui/gfx/rect_f.h" | 13 #include "ui/gfx/rect_f.h" |
| 14 | 14 |
| 15 namespace cc { | 15 namespace cc { |
| 16 | 16 |
| 17 NinePatchLayerImpl::NinePatchLayerImpl(LayerTreeImpl* tree_impl, int id) | 17 NinePatchLayerImpl::NinePatchLayerImpl(LayerTreeImpl* tree_impl, int id) |
| 18 : UIResourceLayerImpl(tree_impl, id), | 18 : UIResourceLayerImpl(tree_impl, id), |
| 19 fill_center_(false) {} | 19 fill_center_(false) {} |
| 20 | 20 |
| 21 NinePatchLayerImpl::~NinePatchLayerImpl() {} | 21 NinePatchLayerImpl::~NinePatchLayerImpl() {} |
| 22 | 22 |
| (...skipping 52 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 OcclusionTracker<LayerImpl>& occlusion_tracker, | 85 const Occlusion& occlusion_in_content_space, |
| 86 AppendQuadsData* append_quads_data) { | 86 AppendQuadsData* append_quads_data) { |
| 87 CheckGeometryLimitations(); | 87 CheckGeometryLimitations(); |
| 88 SharedQuadState* shared_quad_state = | 88 SharedQuadState* shared_quad_state = |
| 89 render_pass->CreateAndAppendSharedQuadState(); | 89 render_pass->CreateAndAppendSharedQuadState(); |
| 90 PopulateSharedQuadState(shared_quad_state); | 90 PopulateSharedQuadState(shared_quad_state); |
| 91 | 91 |
| 92 AppendDebugBorderQuad( | 92 AppendDebugBorderQuad( |
| 93 render_pass, content_bounds(), shared_quad_state, append_quads_data); | 93 render_pass, content_bounds(), shared_quad_state, append_quads_data); |
| 94 | 94 |
| 95 if (!ui_resource_id_) | 95 if (!ui_resource_id_) |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 uv_top_left.bottom(), | 206 uv_top_left.bottom(), |
| 207 uv_top.width(), | 207 uv_top.width(), |
| 208 uv_left.height()); | 208 uv_left.height()); |
| 209 | 209 |
| 210 // Nothing is opaque here. | 210 // Nothing is opaque here. |
| 211 // TODO(danakj): Should we look at the SkBitmaps to determine opaqueness? | 211 // TODO(danakj): Should we look at the SkBitmaps to determine opaqueness? |
| 212 gfx::Rect opaque_rect; | 212 gfx::Rect opaque_rect; |
| 213 gfx::Rect visible_rect; | 213 gfx::Rect visible_rect; |
| 214 const float vertex_opacity[] = {1.0f, 1.0f, 1.0f, 1.0f}; | 214 const float vertex_opacity[] = {1.0f, 1.0f, 1.0f, 1.0f}; |
| 215 | 215 |
| 216 Occlusion occlusion = | 216 visible_rect = |
| 217 occlusion_tracker.GetCurrentOcclusionForLayer(draw_transform()); | 217 occlusion_in_content_space.GetUnoccludedContentRect(layer_top_left); |
| 218 | |
| 219 visible_rect = occlusion.GetUnoccludedContentRect(layer_top_left); | |
| 220 if (!visible_rect.IsEmpty()) { | 218 if (!visible_rect.IsEmpty()) { |
| 221 TextureDrawQuad* quad = | 219 TextureDrawQuad* quad = |
| 222 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); | 220 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); |
| 223 quad->SetNew(shared_quad_state, | 221 quad->SetNew(shared_quad_state, |
| 224 layer_top_left, | 222 layer_top_left, |
| 225 opaque_rect, | 223 opaque_rect, |
| 226 visible_rect, | 224 visible_rect, |
| 227 resource, | 225 resource, |
| 228 premultiplied_alpha, | 226 premultiplied_alpha, |
| 229 uv_top_left.origin(), | 227 uv_top_left.origin(), |
| 230 uv_top_left.bottom_right(), | 228 uv_top_left.bottom_right(), |
| 231 SK_ColorTRANSPARENT, | 229 SK_ColorTRANSPARENT, |
| 232 vertex_opacity, | 230 vertex_opacity, |
| 233 flipped); | 231 flipped); |
| 234 } | 232 } |
| 235 | 233 |
| 236 visible_rect = occlusion.GetUnoccludedContentRect(layer_top_right); | 234 visible_rect = |
| 235 occlusion_in_content_space.GetUnoccludedContentRect(layer_top_right); |
| 237 if (!visible_rect.IsEmpty()) { | 236 if (!visible_rect.IsEmpty()) { |
| 238 TextureDrawQuad* quad = | 237 TextureDrawQuad* quad = |
| 239 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); | 238 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); |
| 240 quad->SetNew(shared_quad_state, | 239 quad->SetNew(shared_quad_state, |
| 241 layer_top_right, | 240 layer_top_right, |
| 242 opaque_rect, | 241 opaque_rect, |
| 243 visible_rect, | 242 visible_rect, |
| 244 resource, | 243 resource, |
| 245 premultiplied_alpha, | 244 premultiplied_alpha, |
| 246 uv_top_right.origin(), | 245 uv_top_right.origin(), |
| 247 uv_top_right.bottom_right(), | 246 uv_top_right.bottom_right(), |
| 248 SK_ColorTRANSPARENT, | 247 SK_ColorTRANSPARENT, |
| 249 vertex_opacity, | 248 vertex_opacity, |
| 250 flipped); | 249 flipped); |
| 251 } | 250 } |
| 252 | 251 |
| 253 visible_rect = occlusion.GetUnoccludedContentRect(layer_bottom_left); | 252 visible_rect = |
| 253 occlusion_in_content_space.GetUnoccludedContentRect(layer_bottom_left); |
| 254 if (!visible_rect.IsEmpty()) { | 254 if (!visible_rect.IsEmpty()) { |
| 255 TextureDrawQuad* quad = | 255 TextureDrawQuad* quad = |
| 256 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); | 256 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); |
| 257 quad->SetNew(shared_quad_state, | 257 quad->SetNew(shared_quad_state, |
| 258 layer_bottom_left, | 258 layer_bottom_left, |
| 259 opaque_rect, | 259 opaque_rect, |
| 260 visible_rect, | 260 visible_rect, |
| 261 resource, | 261 resource, |
| 262 premultiplied_alpha, | 262 premultiplied_alpha, |
| 263 uv_bottom_left.origin(), | 263 uv_bottom_left.origin(), |
| 264 uv_bottom_left.bottom_right(), | 264 uv_bottom_left.bottom_right(), |
| 265 SK_ColorTRANSPARENT, | 265 SK_ColorTRANSPARENT, |
| 266 vertex_opacity, | 266 vertex_opacity, |
| 267 flipped); | 267 flipped); |
| 268 } | 268 } |
| 269 | 269 |
| 270 visible_rect = occlusion.GetUnoccludedContentRect(layer_bottom_right); | 270 visible_rect = |
| 271 occlusion_in_content_space.GetUnoccludedContentRect(layer_bottom_right); |
| 271 if (!visible_rect.IsEmpty()) { | 272 if (!visible_rect.IsEmpty()) { |
| 272 TextureDrawQuad* quad = | 273 TextureDrawQuad* quad = |
| 273 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); | 274 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); |
| 274 quad->SetNew(shared_quad_state, | 275 quad->SetNew(shared_quad_state, |
| 275 layer_bottom_right, | 276 layer_bottom_right, |
| 276 opaque_rect, | 277 opaque_rect, |
| 277 visible_rect, | 278 visible_rect, |
| 278 resource, | 279 resource, |
| 279 premultiplied_alpha, | 280 premultiplied_alpha, |
| 280 uv_bottom_right.origin(), | 281 uv_bottom_right.origin(), |
| 281 uv_bottom_right.bottom_right(), | 282 uv_bottom_right.bottom_right(), |
| 282 SK_ColorTRANSPARENT, | 283 SK_ColorTRANSPARENT, |
| 283 vertex_opacity, | 284 vertex_opacity, |
| 284 flipped); | 285 flipped); |
| 285 } | 286 } |
| 286 | 287 |
| 287 visible_rect = occlusion.GetUnoccludedContentRect(layer_top); | 288 visible_rect = occlusion_in_content_space.GetUnoccludedContentRect(layer_top); |
| 288 if (!visible_rect.IsEmpty()) { | 289 if (!visible_rect.IsEmpty()) { |
| 289 TextureDrawQuad* quad = | 290 TextureDrawQuad* quad = |
| 290 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); | 291 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); |
| 291 quad->SetNew(shared_quad_state, | 292 quad->SetNew(shared_quad_state, |
| 292 layer_top, | 293 layer_top, |
| 293 opaque_rect, | 294 opaque_rect, |
| 294 visible_rect, | 295 visible_rect, |
| 295 resource, | 296 resource, |
| 296 premultiplied_alpha, | 297 premultiplied_alpha, |
| 297 uv_top.origin(), | 298 uv_top.origin(), |
| 298 uv_top.bottom_right(), | 299 uv_top.bottom_right(), |
| 299 SK_ColorTRANSPARENT, | 300 SK_ColorTRANSPARENT, |
| 300 vertex_opacity, | 301 vertex_opacity, |
| 301 flipped); | 302 flipped); |
| 302 } | 303 } |
| 303 | 304 |
| 304 visible_rect = occlusion.GetUnoccludedContentRect(layer_left); | 305 visible_rect = |
| 306 occlusion_in_content_space.GetUnoccludedContentRect(layer_left); |
| 305 if (!visible_rect.IsEmpty()) { | 307 if (!visible_rect.IsEmpty()) { |
| 306 TextureDrawQuad* quad = | 308 TextureDrawQuad* quad = |
| 307 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); | 309 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); |
| 308 quad->SetNew(shared_quad_state, | 310 quad->SetNew(shared_quad_state, |
| 309 layer_left, | 311 layer_left, |
| 310 opaque_rect, | 312 opaque_rect, |
| 311 visible_rect, | 313 visible_rect, |
| 312 resource, | 314 resource, |
| 313 premultiplied_alpha, | 315 premultiplied_alpha, |
| 314 uv_left.origin(), | 316 uv_left.origin(), |
| 315 uv_left.bottom_right(), | 317 uv_left.bottom_right(), |
| 316 SK_ColorTRANSPARENT, | 318 SK_ColorTRANSPARENT, |
| 317 vertex_opacity, | 319 vertex_opacity, |
| 318 flipped); | 320 flipped); |
| 319 } | 321 } |
| 320 | 322 |
| 321 visible_rect = occlusion.GetUnoccludedContentRect(layer_right); | 323 visible_rect = |
| 324 occlusion_in_content_space.GetUnoccludedContentRect(layer_right); |
| 322 if (!visible_rect.IsEmpty()) { | 325 if (!visible_rect.IsEmpty()) { |
| 323 TextureDrawQuad* quad = | 326 TextureDrawQuad* quad = |
| 324 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); | 327 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); |
| 325 quad->SetNew(shared_quad_state, | 328 quad->SetNew(shared_quad_state, |
| 326 layer_right, | 329 layer_right, |
| 327 opaque_rect, | 330 opaque_rect, |
| 328 layer_right, | 331 layer_right, |
| 329 resource, | 332 resource, |
| 330 premultiplied_alpha, | 333 premultiplied_alpha, |
| 331 uv_right.origin(), | 334 uv_right.origin(), |
| 332 uv_right.bottom_right(), | 335 uv_right.bottom_right(), |
| 333 SK_ColorTRANSPARENT, | 336 SK_ColorTRANSPARENT, |
| 334 vertex_opacity, | 337 vertex_opacity, |
| 335 flipped); | 338 flipped); |
| 336 } | 339 } |
| 337 | 340 |
| 338 visible_rect = occlusion.GetUnoccludedContentRect(layer_bottom); | 341 visible_rect = |
| 342 occlusion_in_content_space.GetUnoccludedContentRect(layer_bottom); |
| 339 if (!visible_rect.IsEmpty()) { | 343 if (!visible_rect.IsEmpty()) { |
| 340 TextureDrawQuad* quad = | 344 TextureDrawQuad* quad = |
| 341 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); | 345 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); |
| 342 quad->SetNew(shared_quad_state, | 346 quad->SetNew(shared_quad_state, |
| 343 layer_bottom, | 347 layer_bottom, |
| 344 opaque_rect, | 348 opaque_rect, |
| 345 visible_rect, | 349 visible_rect, |
| 346 resource, | 350 resource, |
| 347 premultiplied_alpha, | 351 premultiplied_alpha, |
| 348 uv_bottom.origin(), | 352 uv_bottom.origin(), |
| 349 uv_bottom.bottom_right(), | 353 uv_bottom.bottom_right(), |
| 350 SK_ColorTRANSPARENT, | 354 SK_ColorTRANSPARENT, |
| 351 vertex_opacity, | 355 vertex_opacity, |
| 352 flipped); | 356 flipped); |
| 353 } | 357 } |
| 354 | 358 |
| 355 if (fill_center_) { | 359 if (fill_center_) { |
| 356 visible_rect = occlusion.GetUnoccludedContentRect(layer_center); | 360 visible_rect = |
| 361 occlusion_in_content_space.GetUnoccludedContentRect(layer_center); |
| 357 if (!visible_rect.IsEmpty()) { | 362 if (!visible_rect.IsEmpty()) { |
| 358 TextureDrawQuad* quad = | 363 TextureDrawQuad* quad = |
| 359 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); | 364 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); |
| 360 quad->SetNew(shared_quad_state, | 365 quad->SetNew(shared_quad_state, |
| 361 layer_center, | 366 layer_center, |
| 362 opaque_rect, | 367 opaque_rect, |
| 363 visible_rect, | 368 visible_rect, |
| 364 resource, | 369 resource, |
| 365 premultiplied_alpha, | 370 premultiplied_alpha, |
| 366 uv_center.origin(), | 371 uv_center.origin(), |
| (...skipping 25 matching lines...) Expand all Loading... |
| 392 result->Set("ImageBounds", list); | 397 result->Set("ImageBounds", list); |
| 393 | 398 |
| 394 result->Set("Border", MathUtil::AsValue(border_).release()); | 399 result->Set("Border", MathUtil::AsValue(border_).release()); |
| 395 | 400 |
| 396 result->SetBoolean("FillCenter", fill_center_); | 401 result->SetBoolean("FillCenter", fill_center_); |
| 397 | 402 |
| 398 return result; | 403 return result; |
| 399 } | 404 } |
| 400 | 405 |
| 401 } // namespace cc | 406 } // namespace cc |
| OLD | NEW |