| 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/layers/quad_sink.h" | 10 #include "cc/layers/quad_sink.h" |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 uv_left.height()); | 204 uv_left.height()); |
| 205 | 205 |
| 206 // Nothing is opaque here. | 206 // Nothing is opaque here. |
| 207 // TODO(danakj): Should we look at the SkBitmaps to determine opaqueness? | 207 // TODO(danakj): Should we look at the SkBitmaps to determine opaqueness? |
| 208 gfx::Rect opaque_rect; | 208 gfx::Rect opaque_rect; |
| 209 gfx::Rect visible_rect; | 209 gfx::Rect visible_rect; |
| 210 const float vertex_opacity[] = {1.0f, 1.0f, 1.0f, 1.0f}; | 210 const float vertex_opacity[] = {1.0f, 1.0f, 1.0f, 1.0f}; |
| 211 scoped_ptr<TextureDrawQuad> quad; | 211 scoped_ptr<TextureDrawQuad> quad; |
| 212 | 212 |
| 213 visible_rect = | 213 visible_rect = |
| 214 quad_sink->UnoccludedContentRect(layer_top_left, draw_transform()); | 214 quad_sink->UnoccludedContentRect(this, layer_top_left, draw_transform()); |
| 215 if (!visible_rect.IsEmpty()) { | 215 if (!visible_rect.IsEmpty()) { |
| 216 quad = TextureDrawQuad::Create(); | 216 quad = TextureDrawQuad::Create(); |
| 217 quad->SetNew(shared_quad_state, | 217 quad->SetNew(shared_quad_state, |
| 218 layer_top_left, | 218 layer_top_left, |
| 219 opaque_rect, | 219 opaque_rect, |
| 220 visible_rect, | 220 visible_rect, |
| 221 resource, | 221 resource, |
| 222 premultiplied_alpha, | 222 premultiplied_alpha, |
| 223 uv_top_left.origin(), | 223 uv_top_left.origin(), |
| 224 uv_top_left.bottom_right(), | 224 uv_top_left.bottom_right(), |
| 225 SK_ColorTRANSPARENT, | 225 SK_ColorTRANSPARENT, |
| 226 vertex_opacity, | 226 vertex_opacity, |
| 227 flipped); | 227 flipped); |
| 228 quad_sink->Append(quad.PassAs<DrawQuad>()); | 228 quad_sink->Append(quad.PassAs<DrawQuad>()); |
| 229 } | 229 } |
| 230 | 230 |
| 231 visible_rect = | 231 visible_rect = |
| 232 quad_sink->UnoccludedContentRect(layer_top_right, draw_transform()); | 232 quad_sink->UnoccludedContentRect(this, layer_top_right, draw_transform()); |
| 233 if (!visible_rect.IsEmpty()) { | 233 if (!visible_rect.IsEmpty()) { |
| 234 quad = TextureDrawQuad::Create(); | 234 quad = TextureDrawQuad::Create(); |
| 235 quad->SetNew(shared_quad_state, | 235 quad->SetNew(shared_quad_state, |
| 236 layer_top_right, | 236 layer_top_right, |
| 237 opaque_rect, | 237 opaque_rect, |
| 238 visible_rect, | 238 visible_rect, |
| 239 resource, | 239 resource, |
| 240 premultiplied_alpha, | 240 premultiplied_alpha, |
| 241 uv_top_right.origin(), | 241 uv_top_right.origin(), |
| 242 uv_top_right.bottom_right(), | 242 uv_top_right.bottom_right(), |
| 243 SK_ColorTRANSPARENT, | 243 SK_ColorTRANSPARENT, |
| 244 vertex_opacity, | 244 vertex_opacity, |
| 245 flipped); | 245 flipped); |
| 246 quad_sink->Append(quad.PassAs<DrawQuad>()); | 246 quad_sink->Append(quad.PassAs<DrawQuad>()); |
| 247 } | 247 } |
| 248 | 248 |
| 249 visible_rect = | 249 visible_rect = quad_sink->UnoccludedContentRect( |
| 250 quad_sink->UnoccludedContentRect(layer_bottom_left, draw_transform()); | 250 this, layer_bottom_left, draw_transform()); |
| 251 if (!visible_rect.IsEmpty()) { | 251 if (!visible_rect.IsEmpty()) { |
| 252 quad = TextureDrawQuad::Create(); | 252 quad = TextureDrawQuad::Create(); |
| 253 quad->SetNew(shared_quad_state, | 253 quad->SetNew(shared_quad_state, |
| 254 layer_bottom_left, | 254 layer_bottom_left, |
| 255 opaque_rect, | 255 opaque_rect, |
| 256 visible_rect, | 256 visible_rect, |
| 257 resource, | 257 resource, |
| 258 premultiplied_alpha, | 258 premultiplied_alpha, |
| 259 uv_bottom_left.origin(), | 259 uv_bottom_left.origin(), |
| 260 uv_bottom_left.bottom_right(), | 260 uv_bottom_left.bottom_right(), |
| 261 SK_ColorTRANSPARENT, | 261 SK_ColorTRANSPARENT, |
| 262 vertex_opacity, | 262 vertex_opacity, |
| 263 flipped); | 263 flipped); |
| 264 quad_sink->Append(quad.PassAs<DrawQuad>()); | 264 quad_sink->Append(quad.PassAs<DrawQuad>()); |
| 265 } | 265 } |
| 266 | 266 |
| 267 visible_rect = | 267 visible_rect = quad_sink->UnoccludedContentRect( |
| 268 quad_sink->UnoccludedContentRect(layer_bottom_right, draw_transform()); | 268 this, layer_bottom_right, draw_transform()); |
| 269 if (!visible_rect.IsEmpty()) { | 269 if (!visible_rect.IsEmpty()) { |
| 270 quad = TextureDrawQuad::Create(); | 270 quad = TextureDrawQuad::Create(); |
| 271 quad->SetNew(shared_quad_state, | 271 quad->SetNew(shared_quad_state, |
| 272 layer_bottom_right, | 272 layer_bottom_right, |
| 273 opaque_rect, | 273 opaque_rect, |
| 274 visible_rect, | 274 visible_rect, |
| 275 resource, | 275 resource, |
| 276 premultiplied_alpha, | 276 premultiplied_alpha, |
| 277 uv_bottom_right.origin(), | 277 uv_bottom_right.origin(), |
| 278 uv_bottom_right.bottom_right(), | 278 uv_bottom_right.bottom_right(), |
| 279 SK_ColorTRANSPARENT, | 279 SK_ColorTRANSPARENT, |
| 280 vertex_opacity, | 280 vertex_opacity, |
| 281 flipped); | 281 flipped); |
| 282 quad_sink->Append(quad.PassAs<DrawQuad>()); | 282 quad_sink->Append(quad.PassAs<DrawQuad>()); |
| 283 } | 283 } |
| 284 | 284 |
| 285 visible_rect = quad_sink->UnoccludedContentRect(layer_top, draw_transform()); | 285 visible_rect = |
| 286 quad_sink->UnoccludedContentRect(this, layer_top, draw_transform()); |
| 286 if (!visible_rect.IsEmpty()) { | 287 if (!visible_rect.IsEmpty()) { |
| 287 quad = TextureDrawQuad::Create(); | 288 quad = TextureDrawQuad::Create(); |
| 288 quad->SetNew(shared_quad_state, | 289 quad->SetNew(shared_quad_state, |
| 289 layer_top, | 290 layer_top, |
| 290 opaque_rect, | 291 opaque_rect, |
| 291 visible_rect, | 292 visible_rect, |
| 292 resource, | 293 resource, |
| 293 premultiplied_alpha, | 294 premultiplied_alpha, |
| 294 uv_top.origin(), | 295 uv_top.origin(), |
| 295 uv_top.bottom_right(), | 296 uv_top.bottom_right(), |
| 296 SK_ColorTRANSPARENT, | 297 SK_ColorTRANSPARENT, |
| 297 vertex_opacity, | 298 vertex_opacity, |
| 298 flipped); | 299 flipped); |
| 299 quad_sink->Append(quad.PassAs<DrawQuad>()); | 300 quad_sink->Append(quad.PassAs<DrawQuad>()); |
| 300 } | 301 } |
| 301 | 302 |
| 302 visible_rect = quad_sink->UnoccludedContentRect(layer_left, draw_transform()); | 303 visible_rect = |
| 304 quad_sink->UnoccludedContentRect(this, layer_left, draw_transform()); |
| 303 if (!visible_rect.IsEmpty()) { | 305 if (!visible_rect.IsEmpty()) { |
| 304 quad = TextureDrawQuad::Create(); | 306 quad = TextureDrawQuad::Create(); |
| 305 quad->SetNew(shared_quad_state, | 307 quad->SetNew(shared_quad_state, |
| 306 layer_left, | 308 layer_left, |
| 307 opaque_rect, | 309 opaque_rect, |
| 308 visible_rect, | 310 visible_rect, |
| 309 resource, | 311 resource, |
| 310 premultiplied_alpha, | 312 premultiplied_alpha, |
| 311 uv_left.origin(), | 313 uv_left.origin(), |
| 312 uv_left.bottom_right(), | 314 uv_left.bottom_right(), |
| 313 SK_ColorTRANSPARENT, | 315 SK_ColorTRANSPARENT, |
| 314 vertex_opacity, | 316 vertex_opacity, |
| 315 flipped); | 317 flipped); |
| 316 quad_sink->Append(quad.PassAs<DrawQuad>()); | 318 quad_sink->Append(quad.PassAs<DrawQuad>()); |
| 317 } | 319 } |
| 318 | 320 |
| 319 visible_rect = | 321 visible_rect = |
| 320 quad_sink->UnoccludedContentRect(layer_right, draw_transform()); | 322 quad_sink->UnoccludedContentRect(this, layer_right, draw_transform()); |
| 321 if (!visible_rect.IsEmpty()) { | 323 if (!visible_rect.IsEmpty()) { |
| 322 quad = TextureDrawQuad::Create(); | 324 quad = TextureDrawQuad::Create(); |
| 323 quad->SetNew(shared_quad_state, | 325 quad->SetNew(shared_quad_state, |
| 324 layer_right, | 326 layer_right, |
| 325 opaque_rect, | 327 opaque_rect, |
| 326 layer_right, | 328 layer_right, |
| 327 resource, | 329 resource, |
| 328 premultiplied_alpha, | 330 premultiplied_alpha, |
| 329 uv_right.origin(), | 331 uv_right.origin(), |
| 330 uv_right.bottom_right(), | 332 uv_right.bottom_right(), |
| 331 SK_ColorTRANSPARENT, | 333 SK_ColorTRANSPARENT, |
| 332 vertex_opacity, | 334 vertex_opacity, |
| 333 flipped); | 335 flipped); |
| 334 quad_sink->Append(quad.PassAs<DrawQuad>()); | 336 quad_sink->Append(quad.PassAs<DrawQuad>()); |
| 335 } | 337 } |
| 336 | 338 |
| 337 visible_rect = | 339 visible_rect = |
| 338 quad_sink->UnoccludedContentRect(layer_bottom, draw_transform()); | 340 quad_sink->UnoccludedContentRect(this, layer_bottom, draw_transform()); |
| 339 if (!visible_rect.IsEmpty()) { | 341 if (!visible_rect.IsEmpty()) { |
| 340 quad = TextureDrawQuad::Create(); | 342 quad = TextureDrawQuad::Create(); |
| 341 quad->SetNew(shared_quad_state, | 343 quad->SetNew(shared_quad_state, |
| 342 layer_bottom, | 344 layer_bottom, |
| 343 opaque_rect, | 345 opaque_rect, |
| 344 visible_rect, | 346 visible_rect, |
| 345 resource, | 347 resource, |
| 346 premultiplied_alpha, | 348 premultiplied_alpha, |
| 347 uv_bottom.origin(), | 349 uv_bottom.origin(), |
| 348 uv_bottom.bottom_right(), | 350 uv_bottom.bottom_right(), |
| 349 SK_ColorTRANSPARENT, | 351 SK_ColorTRANSPARENT, |
| 350 vertex_opacity, | 352 vertex_opacity, |
| 351 flipped); | 353 flipped); |
| 352 quad_sink->Append(quad.PassAs<DrawQuad>()); | 354 quad_sink->Append(quad.PassAs<DrawQuad>()); |
| 353 } | 355 } |
| 354 | 356 |
| 355 if (fill_center_) { | 357 if (fill_center_) { |
| 356 visible_rect = | 358 visible_rect = |
| 357 quad_sink->UnoccludedContentRect(layer_center, draw_transform()); | 359 quad_sink->UnoccludedContentRect(this, layer_center, draw_transform()); |
| 358 if (!visible_rect.IsEmpty()) { | 360 if (!visible_rect.IsEmpty()) { |
| 359 quad = TextureDrawQuad::Create(); | 361 quad = TextureDrawQuad::Create(); |
| 360 quad->SetNew(shared_quad_state, | 362 quad->SetNew(shared_quad_state, |
| 361 layer_center, | 363 layer_center, |
| 362 opaque_rect, | 364 opaque_rect, |
| 363 visible_rect, | 365 visible_rect, |
| 364 resource, | 366 resource, |
| 365 premultiplied_alpha, | 367 premultiplied_alpha, |
| 366 uv_center.origin(), | 368 uv_center.origin(), |
| 367 uv_center.bottom_right(), | 369 uv_center.bottom_right(), |
| (...skipping 27 matching lines...) Expand all Loading... |
| 395 result->Set("Border", MathUtil::AsValue(border_).release()); | 397 result->Set("Border", MathUtil::AsValue(border_).release()); |
| 396 | 398 |
| 397 base::FundamentalValue* fill_center = | 399 base::FundamentalValue* fill_center = |
| 398 base::Value::CreateBooleanValue(fill_center_); | 400 base::Value::CreateBooleanValue(fill_center_); |
| 399 result->Set("FillCenter", fill_center); | 401 result->Set("FillCenter", fill_center); |
| 400 | 402 |
| 401 return result; | 403 return result; |
| 402 } | 404 } |
| 403 | 405 |
| 404 } // namespace cc | 406 } // namespace cc |
| OLD | NEW |