1 // Copyright 2014 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "cc/layers/quad_sink.h" 6 7 #include "cc/debug/debug_colors.h" 8 #include "cc/layers/append_quads_data.h" 9 #include "cc/layers/layer_impl.h" 10 #include "cc/quads/debug_border_draw_quad.h" 11 #include "cc/quads/render_pass.h" 12 #include "cc/quads/render_pass_draw_quad.h" 13 #include "cc/trees/occlusion_tracker.h" 14 #include "third_party/skia/include/core/SkColor.h" 15 #include "ui/gfx/transform.h" 16 17 namespace cc { 18 19 QuadSink::QuadSink(RenderPass* render_pass, 20 const OcclusionTracker<LayerImpl>* occlusion_tracker) 21 : render_pass_(render_pass), 22 current_shared_quad_state_(NULL), 23 occlusion_tracker_(occlusion_tracker) { 24 } 25 26 SharedQuadState* QuadSink::CreateSharedQuadState() { 27 current_shared_quad_state_ = render_pass_->CreateAndAppendSharedQuadState(); 28 return current_shared_quad_state_; 29 } 30 31 gfx::Rect QuadSink::UnoccludedContentRect( 32 const gfx::Rect& content_rect, 33 const gfx::Transform& draw_transform) { 34 return occlusion_tracker_->UnoccludedContentRect(content_rect, 35 draw_transform); 36 } 37 38 gfx::Rect QuadSink::UnoccludedContributingSurfaceContentRect( 39 const gfx::Rect& content_rect, 40 const gfx::Transform& draw_transform) { 41 return occlusion_tracker_->UnoccludedContributingSurfaceContentRect( 42 content_rect, draw_transform); 43 } 44 45 void QuadSink::Append(scoped_ptr<DrawQuad> draw_quad) { 46 DCHECK(draw_quad->shared_quad_state == current_shared_quad_state_); 47 DCHECK(!render_pass_->shared_quad_state_list.empty()); 48 DCHECK(render_pass_->shared_quad_state_list.back() == 49 current_shared_quad_state_); 50 DCHECK(!draw_quad->rect.IsEmpty()); 51 DCHECK(!draw_quad->visible_rect.IsEmpty()); 52 render_pass_->quad_list.push_back(draw_quad.Pass()); 53 } 54 55 } // namespace cc 56