Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(549)

Side by Side Diff: cc/layers/heads_up_display_layer_impl.cc

Issue 308193003: Removed QuadSink and MockQuadCuller (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@plumLayerImpl
Patch Set: rm unused line Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/heads_up_display_layer_impl.h" 5 #include "cc/layers/heads_up_display_layer_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
11 #include "cc/debug/debug_colors.h" 11 #include "cc/debug/debug_colors.h"
12 #include "cc/debug/frame_rate_counter.h" 12 #include "cc/debug/frame_rate_counter.h"
13 #include "cc/debug/paint_time_counter.h" 13 #include "cc/debug/paint_time_counter.h"
14 #include "cc/debug/traced_value.h" 14 #include "cc/debug/traced_value.h"
15 #include "cc/layers/quad_sink.h"
16 #include "cc/output/renderer.h" 15 #include "cc/output/renderer.h"
17 #include "cc/quads/texture_draw_quad.h" 16 #include "cc/quads/texture_draw_quad.h"
18 #include "cc/resources/memory_history.h" 17 #include "cc/resources/memory_history.h"
19 #include "cc/trees/layer_tree_impl.h" 18 #include "cc/trees/layer_tree_impl.h"
20 #include "skia/ext/platform_canvas.h" 19 #include "skia/ext/platform_canvas.h"
21 #include "third_party/khronos/GLES2/gl2.h" 20 #include "third_party/khronos/GLES2/gl2.h"
22 #include "third_party/khronos/GLES2/gl2ext.h" 21 #include "third_party/khronos/GLES2/gl2ext.h"
23 #include "third_party/skia/include/core/SkBitmap.h" 22 #include "third_party/skia/include/core/SkBitmap.h"
24 #include "third_party/skia/include/core/SkPaint.h" 23 #include "third_party/skia/include/core/SkPaint.h"
25 #include "third_party/skia/include/core/SkTypeface.h" 24 #include "third_party/skia/include/core/SkTypeface.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 97
99 if (!hud_resource_->id()) { 98 if (!hud_resource_->id()) {
100 hud_resource_->Allocate(content_bounds(), 99 hud_resource_->Allocate(content_bounds(),
101 ResourceProvider::TextureUsageAny, 100 ResourceProvider::TextureUsageAny,
102 RGBA_8888); 101 RGBA_8888);
103 } 102 }
104 103
105 return LayerImpl::WillDraw(draw_mode, resource_provider); 104 return LayerImpl::WillDraw(draw_mode, resource_provider);
106 } 105 }
107 106
108 void HeadsUpDisplayLayerImpl::AppendQuads(QuadSink* quad_sink, 107 void HeadsUpDisplayLayerImpl::AppendQuads(
109 AppendQuadsData* append_quads_data) { 108 RenderPass* render_pass,
109 const OcclusionTracker<LayerImpl>& occlusion_tracker,
110 AppendQuadsData* append_quads_data) {
110 if (!hud_resource_->id()) 111 if (!hud_resource_->id())
111 return; 112 return;
112 113
113 SharedQuadState* shared_quad_state = quad_sink->CreateSharedQuadState(); 114 SharedQuadState* shared_quad_state =
115 render_pass->CreateAndAppendSharedQuadState();
114 PopulateSharedQuadState(shared_quad_state); 116 PopulateSharedQuadState(shared_quad_state);
115 117
116 gfx::Rect quad_rect(content_bounds()); 118 gfx::Rect quad_rect(content_bounds());
117 gfx::Rect opaque_rect(contents_opaque() ? quad_rect : gfx::Rect()); 119 gfx::Rect opaque_rect(contents_opaque() ? quad_rect : gfx::Rect());
118 gfx::Rect visible_quad_rect(quad_rect); 120 gfx::Rect visible_quad_rect(quad_rect);
119 bool premultiplied_alpha = true; 121 bool premultiplied_alpha = true;
120 gfx::PointF uv_top_left(0.f, 0.f); 122 gfx::PointF uv_top_left(0.f, 0.f);
121 gfx::PointF uv_bottom_right(1.f, 1.f); 123 gfx::PointF uv_bottom_right(1.f, 1.f);
122 const float vertex_opacity[] = { 1.f, 1.f, 1.f, 1.f }; 124 const float vertex_opacity[] = { 1.f, 1.f, 1.f, 1.f };
123 bool flipped = false; 125 bool flipped = false;
124 scoped_ptr<TextureDrawQuad> quad = TextureDrawQuad::Create(); 126 scoped_ptr<TextureDrawQuad> quad = TextureDrawQuad::Create();
125 quad->SetNew(shared_quad_state, 127 quad->SetNew(shared_quad_state,
126 quad_rect, 128 quad_rect,
127 opaque_rect, 129 opaque_rect,
128 visible_quad_rect, 130 visible_quad_rect,
129 hud_resource_->id(), 131 hud_resource_->id(),
130 premultiplied_alpha, 132 premultiplied_alpha,
131 uv_top_left, 133 uv_top_left,
132 uv_bottom_right, 134 uv_bottom_right,
133 SK_ColorTRANSPARENT, 135 SK_ColorTRANSPARENT,
134 vertex_opacity, 136 vertex_opacity,
135 flipped); 137 flipped);
136 quad_sink->Append(quad.PassAs<DrawQuad>()); 138 render_pass->AppendDrawQuad(quad.PassAs<DrawQuad>());
137 } 139 }
138 140
139 void HeadsUpDisplayLayerImpl::UpdateHudTexture( 141 void HeadsUpDisplayLayerImpl::UpdateHudTexture(
140 DrawMode draw_mode, 142 DrawMode draw_mode,
141 ResourceProvider* resource_provider) { 143 ResourceProvider* resource_provider) {
142 if (draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE || !hud_resource_->id()) 144 if (draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE || !hud_resource_->id())
143 return; 145 return;
144 146
145 SkISize canvas_size; 147 SkISize canvas_size;
146 if (hud_canvas_) 148 if (hud_canvas_)
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 paint); 588 paint);
587 } 589 }
588 590
589 DrawGraphLines(canvas, &paint, graph_bounds, paint_time_graph_); 591 DrawGraphLines(canvas, &paint, graph_bounds, paint_time_graph_);
590 592
591 return area; 593 return area;
592 } 594 }
593 595
594 void HeadsUpDisplayLayerImpl::DrawDebugRect( 596 void HeadsUpDisplayLayerImpl::DrawDebugRect(
595 SkCanvas* canvas, 597 SkCanvas* canvas,
596 SkPaint& paint, 598 SkPaint* paint,
enne (OOO) 2014/05/30 21:37:43 Oops. Thanks for this.
597 const DebugRect& rect, 599 const DebugRect& rect,
598 SkColor stroke_color, 600 SkColor stroke_color,
599 SkColor fill_color, 601 SkColor fill_color,
600 float stroke_width, 602 float stroke_width,
601 const std::string& label_text) const { 603 const std::string& label_text) const {
602 gfx::Rect debug_layer_rect = gfx::ScaleToEnclosingRect( 604 gfx::Rect debug_layer_rect = gfx::ScaleToEnclosingRect(
603 rect.rect, 1.0 / contents_scale_x(), 1.0 / contents_scale_y()); 605 rect.rect, 1.0 / contents_scale_x(), 1.0 / contents_scale_y());
604 SkIRect sk_rect = RectToSkIRect(debug_layer_rect); 606 SkIRect sk_rect = RectToSkIRect(debug_layer_rect);
605 paint.setColor(fill_color); 607 paint->setColor(fill_color);
606 paint.setStyle(SkPaint::kFill_Style); 608 paint->setStyle(SkPaint::kFill_Style);
607 canvas->drawIRect(sk_rect, paint); 609 canvas->drawIRect(sk_rect, *paint);
608 610
609 paint.setColor(stroke_color); 611 paint->setColor(stroke_color);
610 paint.setStyle(SkPaint::kStroke_Style); 612 paint->setStyle(SkPaint::kStroke_Style);
611 paint.setStrokeWidth(SkFloatToScalar(stroke_width)); 613 paint->setStrokeWidth(SkFloatToScalar(stroke_width));
612 canvas->drawIRect(sk_rect, paint); 614 canvas->drawIRect(sk_rect, *paint);
613 615
614 if (label_text.length()) { 616 if (label_text.length()) {
615 const int kFontHeight = 12; 617 const int kFontHeight = 12;
616 const int kPadding = 3; 618 const int kPadding = 3;
617 619
618 // The debug_layer_rect may be huge, and converting to a floating point may 620 // The debug_layer_rect may be huge, and converting to a floating point may
619 // be lossy, so intersect with the HUD layer bounds first to prevent that. 621 // be lossy, so intersect with the HUD layer bounds first to prevent that.
620 gfx::Rect clip_rect = debug_layer_rect; 622 gfx::Rect clip_rect = debug_layer_rect;
621 clip_rect.Intersect(gfx::Rect(content_bounds())); 623 clip_rect.Intersect(gfx::Rect(content_bounds()));
622 SkRect sk_clip_rect = RectToSkRect(clip_rect); 624 SkRect sk_clip_rect = RectToSkRect(clip_rect);
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 break; 724 break;
723 case ANIMATION_BOUNDS_RECT_TYPE: 725 case ANIMATION_BOUNDS_RECT_TYPE:
724 stroke_color = DebugColors::LayerAnimationBoundsBorderColor(); 726 stroke_color = DebugColors::LayerAnimationBoundsBorderColor();
725 fill_color = DebugColors::LayerAnimationBoundsFillColor(); 727 fill_color = DebugColors::LayerAnimationBoundsFillColor();
726 stroke_width = DebugColors::LayerAnimationBoundsBorderWidth(); 728 stroke_width = DebugColors::LayerAnimationBoundsBorderWidth();
727 label_text = "animation bounds"; 729 label_text = "animation bounds";
728 break; 730 break;
729 } 731 }
730 732
731 DrawDebugRect(canvas, 733 DrawDebugRect(canvas,
732 paint, 734 &paint,
733 debug_rects[i], 735 debug_rects[i],
734 stroke_color, 736 stroke_color,
735 fill_color, 737 fill_color,
736 stroke_width, 738 stroke_width,
737 label_text); 739 label_text);
738 } 740 }
739 741
740 if (new_paint_rects.size()) { 742 if (new_paint_rects.size()) {
741 paint_rects_.swap(new_paint_rects); 743 paint_rects_.swap(new_paint_rects);
742 fade_step_ = DebugColors::kFadeSteps; 744 fade_step_ = DebugColors::kFadeSteps;
743 } 745 }
744 if (fade_step_ > 0) { 746 if (fade_step_ > 0) {
745 fade_step_--; 747 fade_step_--;
746 for (size_t i = 0; i < paint_rects_.size(); ++i) { 748 for (size_t i = 0; i < paint_rects_.size(); ++i) {
747 DrawDebugRect(canvas, 749 DrawDebugRect(canvas,
748 paint, 750 &paint,
749 paint_rects_[i], 751 paint_rects_[i],
750 DebugColors::PaintRectBorderColor(fade_step_), 752 DebugColors::PaintRectBorderColor(fade_step_),
751 DebugColors::PaintRectFillColor(fade_step_), 753 DebugColors::PaintRectFillColor(fade_step_),
752 DebugColors::PaintRectBorderWidth(), 754 DebugColors::PaintRectBorderWidth(),
753 ""); 755 "");
754 } 756 }
755 } 757 }
756 } 758 }
757 759
758 const char* HeadsUpDisplayLayerImpl::LayerTypeAsString() const { 760 const char* HeadsUpDisplayLayerImpl::LayerTypeAsString() const {
759 return "cc::HeadsUpDisplayLayerImpl"; 761 return "cc::HeadsUpDisplayLayerImpl";
760 } 762 }
761 763
762 void HeadsUpDisplayLayerImpl::AsValueInto(base::DictionaryValue* dict) const { 764 void HeadsUpDisplayLayerImpl::AsValueInto(base::DictionaryValue* dict) const {
763 LayerImpl::AsValueInto(dict); 765 LayerImpl::AsValueInto(dict);
764 dict->SetString("layer_name", "Heads Up Display Layer"); 766 dict->SetString("layer_name", "Heads Up Display Layer");
765 } 767 }
766 768
767 } // namespace cc 769 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698