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/layer_impl.h" | 5 #include "cc/layers/layer_impl.h" |
6 | 6 |
7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
10 #include "base/trace_event/trace_event_argument.h" | 10 #include "base/trace_event/trace_event_argument.h" |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 DCHECK(!scroll_offset_delegate_); | 168 DCHECK(!scroll_offset_delegate_); |
169 | 169 |
170 if (parent) | 170 if (parent) |
171 DCHECK_EQ(layer_tree_impl()->LayerById(parent->id()), parent); | 171 DCHECK_EQ(layer_tree_impl()->LayerById(parent->id()), parent); |
172 | 172 |
173 scroll_parent_ = parent; | 173 scroll_parent_ = parent; |
174 SetNeedsPushProperties(); | 174 SetNeedsPushProperties(); |
175 } | 175 } |
176 | 176 |
177 void LayerImpl::SetDebugInfo( | 177 void LayerImpl::SetDebugInfo( |
178 scoped_refptr<base::debug::ConvertableToTraceFormat> other) { | 178 scoped_refptr<base::trace_event::ConvertableToTraceFormat> other) { |
179 debug_info_ = other; | 179 debug_info_ = other; |
180 SetNeedsPushProperties(); | 180 SetNeedsPushProperties(); |
181 } | 181 } |
182 | 182 |
183 void LayerImpl::SetScrollChildren(std::set<LayerImpl*>* children) { | 183 void LayerImpl::SetScrollChildren(std::set<LayerImpl*>* children) { |
184 if (scroll_children_.get() == children) | 184 if (scroll_children_.get() == children) |
185 return; | 185 return; |
186 scroll_children_.reset(children); | 186 scroll_children_.reset(children); |
187 SetNeedsPushProperties(); | 187 SetNeedsPushProperties(); |
188 } | 188 } |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 } | 254 } |
255 | 255 |
256 void LayerImpl::PopulateSharedQuadState(SharedQuadState* state) const { | 256 void LayerImpl::PopulateSharedQuadState(SharedQuadState* state) const { |
257 state->SetAll( | 257 state->SetAll( |
258 draw_properties_.target_space_transform, draw_properties_.content_bounds, | 258 draw_properties_.target_space_transform, draw_properties_.content_bounds, |
259 draw_properties_.visible_content_rect, draw_properties_.clip_rect, | 259 draw_properties_.visible_content_rect, draw_properties_.clip_rect, |
260 draw_properties_.is_clipped, draw_properties_.opacity, | 260 draw_properties_.is_clipped, draw_properties_.opacity, |
261 draw_properties_.blend_mode, sorting_context_id_); | 261 draw_properties_.blend_mode, sorting_context_id_); |
262 } | 262 } |
263 | 263 |
| 264 void LayerImpl::PopulateScaledSharedQuadState(SharedQuadState* state, |
| 265 float scale) const { |
| 266 gfx::Transform scaled_draw_transform = |
| 267 draw_properties_.target_space_transform; |
| 268 scaled_draw_transform.Scale(SK_MScalar1 / scale, SK_MScalar1 / scale); |
| 269 gfx::Size scaled_content_bounds = |
| 270 gfx::ToCeiledSize(gfx::ScaleSize(bounds(), scale)); |
| 271 gfx::Rect scaled_visible_content_rect = |
| 272 gfx::ScaleToEnclosingRect(visible_content_rect(), scale); |
| 273 scaled_visible_content_rect.Intersect(gfx::Rect(scaled_content_bounds)); |
| 274 |
| 275 state->SetAll(scaled_draw_transform, scaled_content_bounds, |
| 276 scaled_visible_content_rect, draw_properties().clip_rect, |
| 277 draw_properties().is_clipped, draw_properties().opacity, |
| 278 draw_properties().blend_mode, sorting_context_id_); |
| 279 } |
| 280 |
264 bool LayerImpl::WillDraw(DrawMode draw_mode, | 281 bool LayerImpl::WillDraw(DrawMode draw_mode, |
265 ResourceProvider* resource_provider) { | 282 ResourceProvider* resource_provider) { |
266 // WillDraw/DidDraw must be matched. | 283 // WillDraw/DidDraw must be matched. |
267 DCHECK_NE(DRAW_MODE_NONE, draw_mode); | 284 DCHECK_NE(DRAW_MODE_NONE, draw_mode); |
268 DCHECK_EQ(DRAW_MODE_NONE, current_draw_mode_); | 285 DCHECK_EQ(DRAW_MODE_NONE, current_draw_mode_); |
269 current_draw_mode_ = draw_mode; | 286 current_draw_mode_ = draw_mode; |
270 return true; | 287 return true; |
271 } | 288 } |
272 | 289 |
273 void LayerImpl::DidDraw(ResourceProvider* resource_provider) { | 290 void LayerImpl::DidDraw(ResourceProvider* resource_provider) { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 float width) const { | 337 float width) const { |
321 if (!ShowDebugBorders()) | 338 if (!ShowDebugBorders()) |
322 return; | 339 return; |
323 | 340 |
324 gfx::Rect quad_rect(content_bounds); | 341 gfx::Rect quad_rect(content_bounds); |
325 gfx::Rect visible_quad_rect(quad_rect); | 342 gfx::Rect visible_quad_rect(quad_rect); |
326 DebugBorderDrawQuad* debug_border_quad = | 343 DebugBorderDrawQuad* debug_border_quad = |
327 render_pass->CreateAndAppendDrawQuad<DebugBorderDrawQuad>(); | 344 render_pass->CreateAndAppendDrawQuad<DebugBorderDrawQuad>(); |
328 debug_border_quad->SetNew( | 345 debug_border_quad->SetNew( |
329 shared_quad_state, quad_rect, visible_quad_rect, color, width); | 346 shared_quad_state, quad_rect, visible_quad_rect, color, width); |
| 347 if (contents_opaque()) { |
| 348 // When opaque, draw a second inner border that is thicker than the outer |
| 349 // border, but more transparent. |
| 350 static const float kFillOpacity = 0.3f; |
| 351 SkColor fill_color = SkColorSetA( |
| 352 color, static_cast<uint8_t>(SkColorGetA(color) * kFillOpacity)); |
| 353 float fill_width = width * 3; |
| 354 gfx::Rect fill_rect = quad_rect; |
| 355 fill_rect.Inset(fill_width / 2.f, fill_width / 2.f); |
| 356 gfx::Rect visible_fill_rect = |
| 357 gfx::IntersectRects(visible_quad_rect, fill_rect); |
| 358 DebugBorderDrawQuad* fill_quad = |
| 359 render_pass->CreateAndAppendDrawQuad<DebugBorderDrawQuad>(); |
| 360 fill_quad->SetNew(shared_quad_state, fill_rect, visible_fill_rect, |
| 361 fill_color, fill_width); |
| 362 } |
330 } | 363 } |
331 | 364 |
332 bool LayerImpl::HasDelegatedContent() const { | 365 bool LayerImpl::HasDelegatedContent() const { |
333 return false; | 366 return false; |
334 } | 367 } |
335 | 368 |
336 bool LayerImpl::HasContributingDelegatedRenderPasses() const { | 369 bool LayerImpl::HasContributingDelegatedRenderPasses() const { |
337 return false; | 370 return false; |
338 } | 371 } |
339 | 372 |
340 RenderPassId LayerImpl::FirstContributingRenderPassId() const { | 373 RenderPassId LayerImpl::FirstContributingRenderPassId() const { |
341 return RenderPassId(0, 0); | 374 return RenderPassId(0, 0); |
342 } | 375 } |
343 | 376 |
344 RenderPassId LayerImpl::NextContributingRenderPassId(RenderPassId id) const { | 377 RenderPassId LayerImpl::NextContributingRenderPassId(RenderPassId id) const { |
345 return RenderPassId(0, 0); | 378 return RenderPassId(0, 0); |
346 } | 379 } |
347 | 380 |
348 bool LayerImpl::UpdateTiles(const Occlusion& occlusion_in_layer_space, | |
349 bool resourceless_software_draw) { | |
350 return false; | |
351 } | |
352 | |
353 void LayerImpl::GetContentsResourceId(ResourceProvider::ResourceId* resource_id, | 381 void LayerImpl::GetContentsResourceId(ResourceProvider::ResourceId* resource_id, |
354 gfx::Size* resource_size) const { | 382 gfx::Size* resource_size) const { |
355 NOTREACHED(); | 383 NOTREACHED(); |
356 *resource_id = 0; | 384 *resource_id = 0; |
357 } | 385 } |
358 | 386 |
359 gfx::Vector2dF LayerImpl::ScrollBy(const gfx::Vector2dF& scroll) { | 387 gfx::Vector2dF LayerImpl::ScrollBy(const gfx::Vector2dF& scroll) { |
360 RefreshFromScrollDelegate(); | 388 RefreshFromScrollDelegate(); |
361 | 389 |
362 gfx::ScrollOffset adjusted_scroll(scroll); | 390 gfx::ScrollOffset adjusted_scroll(scroll); |
(...skipping 1031 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1394 num_dependents_need_push_properties_--; | 1422 num_dependents_need_push_properties_--; |
1395 DCHECK_GE(num_dependents_need_push_properties_, 0); | 1423 DCHECK_GE(num_dependents_need_push_properties_, 0); |
1396 | 1424 |
1397 if (!parent_should_know_need_push_properties() && parent_) | 1425 if (!parent_should_know_need_push_properties() && parent_) |
1398 parent_->RemoveDependentNeedsPushProperties(); | 1426 parent_->RemoveDependentNeedsPushProperties(); |
1399 } | 1427 } |
1400 | 1428 |
1401 void LayerImpl::GetAllTilesForTracing(std::set<const Tile*>* tiles) const { | 1429 void LayerImpl::GetAllTilesForTracing(std::set<const Tile*>* tiles) const { |
1402 } | 1430 } |
1403 | 1431 |
1404 void LayerImpl::AsValueInto(base::debug::TracedValue* state) const { | 1432 void LayerImpl::AsValueInto(base::trace_event::TracedValue* state) const { |
1405 TracedValue::MakeDictIntoImplicitSnapshotWithCategory( | 1433 TracedValue::MakeDictIntoImplicitSnapshotWithCategory( |
1406 TRACE_DISABLED_BY_DEFAULT("cc.debug"), | 1434 TRACE_DISABLED_BY_DEFAULT("cc.debug"), |
1407 state, | 1435 state, |
1408 "cc::LayerImpl", | 1436 "cc::LayerImpl", |
1409 LayerTypeAsString(), | 1437 LayerTypeAsString(), |
1410 this); | 1438 this); |
1411 state->SetInteger("layer_id", id()); | 1439 state->SetInteger("layer_id", id()); |
1412 MathUtil::AddToTracedValue("bounds", bounds_, state); | 1440 MathUtil::AddToTracedValue("bounds", bounds_, state); |
1413 | 1441 |
1414 state->SetDouble("opacity", opacity()); | 1442 state->SetDouble("opacity", opacity()); |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1556 SetNeedsPushProperties(); | 1584 SetNeedsPushProperties(); |
1557 layer_tree_impl()->set_needs_update_draw_properties(); | 1585 layer_tree_impl()->set_needs_update_draw_properties(); |
1558 if (should_have_render_surface) { | 1586 if (should_have_render_surface) { |
1559 render_surface_ = make_scoped_ptr(new RenderSurfaceImpl(this)); | 1587 render_surface_ = make_scoped_ptr(new RenderSurfaceImpl(this)); |
1560 return; | 1588 return; |
1561 } | 1589 } |
1562 render_surface_.reset(); | 1590 render_surface_.reset(); |
1563 } | 1591 } |
1564 | 1592 |
1565 } // namespace cc | 1593 } // namespace cc |
OLD | NEW |