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 if (!visible_rect.IsEmpty()) { | 238 if (!visible_rect.IsEmpty()) { |
237 TextureDrawQuad* quad = | 239 TextureDrawQuad* quad = |
238 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); | 240 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); |
239 quad->SetNew(shared_quad_state, | 241 quad->SetNew(shared_quad_state, |
240 layer_top_right, | 242 layer_top_right, |
241 opaque_rect, | 243 opaque_rect, |
242 visible_rect, | 244 visible_rect, |
243 resource, | 245 resource, |
244 premultiplied_alpha, | 246 premultiplied_alpha, |
245 uv_top_right.origin(), | 247 uv_top_right.origin(), |
246 uv_top_right.bottom_right(), | 248 uv_top_right.bottom_right(), |
247 SK_ColorTRANSPARENT, | 249 SK_ColorTRANSPARENT, |
248 vertex_opacity, | 250 vertex_opacity, |
249 flipped); | 251 flipped, |
| 252 nearest_neighbor); |
250 } | 253 } |
251 | 254 |
252 visible_rect = | 255 visible_rect = |
253 occlusion_in_content_space.GetUnoccludedContentRect(layer_bottom_left); | 256 occlusion_in_content_space.GetUnoccludedContentRect(layer_bottom_left); |
254 if (!visible_rect.IsEmpty()) { | 257 if (!visible_rect.IsEmpty()) { |
255 TextureDrawQuad* quad = | 258 TextureDrawQuad* quad = |
256 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); | 259 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); |
257 quad->SetNew(shared_quad_state, | 260 quad->SetNew(shared_quad_state, |
258 layer_bottom_left, | 261 layer_bottom_left, |
259 opaque_rect, | 262 opaque_rect, |
260 visible_rect, | 263 visible_rect, |
261 resource, | 264 resource, |
262 premultiplied_alpha, | 265 premultiplied_alpha, |
263 uv_bottom_left.origin(), | 266 uv_bottom_left.origin(), |
264 uv_bottom_left.bottom_right(), | 267 uv_bottom_left.bottom_right(), |
265 SK_ColorTRANSPARENT, | 268 SK_ColorTRANSPARENT, |
266 vertex_opacity, | 269 vertex_opacity, |
267 flipped); | 270 flipped, |
| 271 nearest_neighbor); |
268 } | 272 } |
269 | 273 |
270 visible_rect = | 274 visible_rect = |
271 occlusion_in_content_space.GetUnoccludedContentRect(layer_bottom_right); | 275 occlusion_in_content_space.GetUnoccludedContentRect(layer_bottom_right); |
272 if (!visible_rect.IsEmpty()) { | 276 if (!visible_rect.IsEmpty()) { |
273 TextureDrawQuad* quad = | 277 TextureDrawQuad* quad = |
274 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); | 278 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); |
275 quad->SetNew(shared_quad_state, | 279 quad->SetNew(shared_quad_state, |
276 layer_bottom_right, | 280 layer_bottom_right, |
277 opaque_rect, | 281 opaque_rect, |
278 visible_rect, | 282 visible_rect, |
279 resource, | 283 resource, |
280 premultiplied_alpha, | 284 premultiplied_alpha, |
281 uv_bottom_right.origin(), | 285 uv_bottom_right.origin(), |
282 uv_bottom_right.bottom_right(), | 286 uv_bottom_right.bottom_right(), |
283 SK_ColorTRANSPARENT, | 287 SK_ColorTRANSPARENT, |
284 vertex_opacity, | 288 vertex_opacity, |
285 flipped); | 289 flipped, |
| 290 nearest_neighbor); |
286 } | 291 } |
287 | 292 |
288 visible_rect = occlusion_in_content_space.GetUnoccludedContentRect(layer_top); | 293 visible_rect = occlusion_in_content_space.GetUnoccludedContentRect(layer_top); |
289 if (!visible_rect.IsEmpty()) { | 294 if (!visible_rect.IsEmpty()) { |
290 TextureDrawQuad* quad = | 295 TextureDrawQuad* quad = |
291 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); | 296 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); |
292 quad->SetNew(shared_quad_state, | 297 quad->SetNew(shared_quad_state, |
293 layer_top, | 298 layer_top, |
294 opaque_rect, | 299 opaque_rect, |
295 visible_rect, | 300 visible_rect, |
296 resource, | 301 resource, |
297 premultiplied_alpha, | 302 premultiplied_alpha, |
298 uv_top.origin(), | 303 uv_top.origin(), |
299 uv_top.bottom_right(), | 304 uv_top.bottom_right(), |
300 SK_ColorTRANSPARENT, | 305 SK_ColorTRANSPARENT, |
301 vertex_opacity, | 306 vertex_opacity, |
302 flipped); | 307 flipped, |
| 308 nearest_neighbor); |
303 } | 309 } |
304 | 310 |
305 visible_rect = | 311 visible_rect = |
306 occlusion_in_content_space.GetUnoccludedContentRect(layer_left); | 312 occlusion_in_content_space.GetUnoccludedContentRect(layer_left); |
307 if (!visible_rect.IsEmpty()) { | 313 if (!visible_rect.IsEmpty()) { |
308 TextureDrawQuad* quad = | 314 TextureDrawQuad* quad = |
309 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); | 315 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); |
310 quad->SetNew(shared_quad_state, | 316 quad->SetNew(shared_quad_state, |
311 layer_left, | 317 layer_left, |
312 opaque_rect, | 318 opaque_rect, |
313 visible_rect, | 319 visible_rect, |
314 resource, | 320 resource, |
315 premultiplied_alpha, | 321 premultiplied_alpha, |
316 uv_left.origin(), | 322 uv_left.origin(), |
317 uv_left.bottom_right(), | 323 uv_left.bottom_right(), |
318 SK_ColorTRANSPARENT, | 324 SK_ColorTRANSPARENT, |
319 vertex_opacity, | 325 vertex_opacity, |
320 flipped); | 326 flipped, |
| 327 nearest_neighbor); |
321 } | 328 } |
322 | 329 |
323 visible_rect = | 330 visible_rect = |
324 occlusion_in_content_space.GetUnoccludedContentRect(layer_right); | 331 occlusion_in_content_space.GetUnoccludedContentRect(layer_right); |
325 if (!visible_rect.IsEmpty()) { | 332 if (!visible_rect.IsEmpty()) { |
326 TextureDrawQuad* quad = | 333 TextureDrawQuad* quad = |
327 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); | 334 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); |
328 quad->SetNew(shared_quad_state, | 335 quad->SetNew(shared_quad_state, |
329 layer_right, | 336 layer_right, |
330 opaque_rect, | 337 opaque_rect, |
331 layer_right, | 338 layer_right, |
332 resource, | 339 resource, |
333 premultiplied_alpha, | 340 premultiplied_alpha, |
334 uv_right.origin(), | 341 uv_right.origin(), |
335 uv_right.bottom_right(), | 342 uv_right.bottom_right(), |
336 SK_ColorTRANSPARENT, | 343 SK_ColorTRANSPARENT, |
337 vertex_opacity, | 344 vertex_opacity, |
338 flipped); | 345 flipped, |
| 346 nearest_neighbor); |
339 } | 347 } |
340 | 348 |
341 visible_rect = | 349 visible_rect = |
342 occlusion_in_content_space.GetUnoccludedContentRect(layer_bottom); | 350 occlusion_in_content_space.GetUnoccludedContentRect(layer_bottom); |
343 if (!visible_rect.IsEmpty()) { | 351 if (!visible_rect.IsEmpty()) { |
344 TextureDrawQuad* quad = | 352 TextureDrawQuad* quad = |
345 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); | 353 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); |
346 quad->SetNew(shared_quad_state, | 354 quad->SetNew(shared_quad_state, |
347 layer_bottom, | 355 layer_bottom, |
348 opaque_rect, | 356 opaque_rect, |
349 visible_rect, | 357 visible_rect, |
350 resource, | 358 resource, |
351 premultiplied_alpha, | 359 premultiplied_alpha, |
352 uv_bottom.origin(), | 360 uv_bottom.origin(), |
353 uv_bottom.bottom_right(), | 361 uv_bottom.bottom_right(), |
354 SK_ColorTRANSPARENT, | 362 SK_ColorTRANSPARENT, |
355 vertex_opacity, | 363 vertex_opacity, |
356 flipped); | 364 flipped, |
| 365 nearest_neighbor); |
357 } | 366 } |
358 | 367 |
359 if (fill_center_) { | 368 if (fill_center_) { |
360 visible_rect = | 369 visible_rect = |
361 occlusion_in_content_space.GetUnoccludedContentRect(layer_center); | 370 occlusion_in_content_space.GetUnoccludedContentRect(layer_center); |
362 if (!visible_rect.IsEmpty()) { | 371 if (!visible_rect.IsEmpty()) { |
363 TextureDrawQuad* quad = | 372 TextureDrawQuad* quad = |
364 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); | 373 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); |
365 quad->SetNew(shared_quad_state, | 374 quad->SetNew(shared_quad_state, |
366 layer_center, | 375 layer_center, |
367 opaque_rect, | 376 opaque_rect, |
368 visible_rect, | 377 visible_rect, |
369 resource, | 378 resource, |
370 premultiplied_alpha, | 379 premultiplied_alpha, |
371 uv_center.origin(), | 380 uv_center.origin(), |
372 uv_center.bottom_right(), | 381 uv_center.bottom_right(), |
373 SK_ColorTRANSPARENT, | 382 SK_ColorTRANSPARENT, |
374 vertex_opacity, | 383 vertex_opacity, |
375 flipped); | 384 flipped, |
| 385 nearest_neighbor); |
376 } | 386 } |
377 } | 387 } |
378 } | 388 } |
379 | 389 |
380 const char* NinePatchLayerImpl::LayerTypeAsString() const { | 390 const char* NinePatchLayerImpl::LayerTypeAsString() const { |
381 return "cc::NinePatchLayerImpl"; | 391 return "cc::NinePatchLayerImpl"; |
382 } | 392 } |
383 | 393 |
384 base::DictionaryValue* NinePatchLayerImpl::LayerTreeAsJson() const { | 394 base::DictionaryValue* NinePatchLayerImpl::LayerTreeAsJson() const { |
385 base::DictionaryValue* result = LayerImpl::LayerTreeAsJson(); | 395 base::DictionaryValue* result = LayerImpl::LayerTreeAsJson(); |
(...skipping 11 matching lines...) Expand all Loading... |
397 result->Set("ImageBounds", list); | 407 result->Set("ImageBounds", list); |
398 | 408 |
399 result->Set("Border", MathUtil::AsValue(border_).release()); | 409 result->Set("Border", MathUtil::AsValue(border_).release()); |
400 | 410 |
401 result->SetBoolean("FillCenter", fill_center_); | 411 result->SetBoolean("FillCenter", fill_center_); |
402 | 412 |
403 return result; | 413 return result; |
404 } | 414 } |
405 | 415 |
406 } // namespace cc | 416 } // namespace cc |
OLD | NEW |