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

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: rebase 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 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 paint); 582 paint);
581 } 583 }
582 584
583 DrawGraphLines(canvas, &paint, graph_bounds, paint_time_graph_); 585 DrawGraphLines(canvas, &paint, graph_bounds, paint_time_graph_);
584 586
585 return area; 587 return area;
586 } 588 }
587 589
588 void HeadsUpDisplayLayerImpl::DrawDebugRect( 590 void HeadsUpDisplayLayerImpl::DrawDebugRect(
589 SkCanvas* canvas, 591 SkCanvas* canvas,
590 SkPaint& paint, 592 SkPaint* paint,
591 const DebugRect& rect, 593 const DebugRect& rect,
592 SkColor stroke_color, 594 SkColor stroke_color,
593 SkColor fill_color, 595 SkColor fill_color,
594 float stroke_width, 596 float stroke_width,
595 const std::string& label_text) const { 597 const std::string& label_text) const {
596 gfx::Rect debug_layer_rect = gfx::ScaleToEnclosingRect( 598 gfx::Rect debug_layer_rect = gfx::ScaleToEnclosingRect(
597 rect.rect, 1.0 / contents_scale_x(), 1.0 / contents_scale_y()); 599 rect.rect, 1.0 / contents_scale_x(), 1.0 / contents_scale_y());
598 SkIRect sk_rect = RectToSkIRect(debug_layer_rect); 600 SkIRect sk_rect = RectToSkIRect(debug_layer_rect);
599 paint.setColor(fill_color); 601 paint->setColor(fill_color);
600 paint.setStyle(SkPaint::kFill_Style); 602 paint->setStyle(SkPaint::kFill_Style);
601 canvas->drawIRect(sk_rect, paint); 603 canvas->drawIRect(sk_rect, *paint);
602 604
603 paint.setColor(stroke_color); 605 paint->setColor(stroke_color);
604 paint.setStyle(SkPaint::kStroke_Style); 606 paint->setStyle(SkPaint::kStroke_Style);
605 paint.setStrokeWidth(SkFloatToScalar(stroke_width)); 607 paint->setStrokeWidth(SkFloatToScalar(stroke_width));
606 canvas->drawIRect(sk_rect, paint); 608 canvas->drawIRect(sk_rect, *paint);
607 609
608 if (label_text.length()) { 610 if (label_text.length()) {
609 const int kFontHeight = 12; 611 const int kFontHeight = 12;
610 const int kPadding = 3; 612 const int kPadding = 3;
611 613
612 // The debug_layer_rect may be huge, and converting to a floating point may 614 // The debug_layer_rect may be huge, and converting to a floating point may
613 // be lossy, so intersect with the HUD layer bounds first to prevent that. 615 // be lossy, so intersect with the HUD layer bounds first to prevent that.
614 gfx::Rect clip_rect = debug_layer_rect; 616 gfx::Rect clip_rect = debug_layer_rect;
615 clip_rect.Intersect(gfx::Rect(content_bounds())); 617 clip_rect.Intersect(gfx::Rect(content_bounds()));
616 SkRect sk_clip_rect = RectToSkRect(clip_rect); 618 SkRect sk_clip_rect = RectToSkRect(clip_rect);
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 break; 718 break;
717 case ANIMATION_BOUNDS_RECT_TYPE: 719 case ANIMATION_BOUNDS_RECT_TYPE:
718 stroke_color = DebugColors::LayerAnimationBoundsBorderColor(); 720 stroke_color = DebugColors::LayerAnimationBoundsBorderColor();
719 fill_color = DebugColors::LayerAnimationBoundsFillColor(); 721 fill_color = DebugColors::LayerAnimationBoundsFillColor();
720 stroke_width = DebugColors::LayerAnimationBoundsBorderWidth(); 722 stroke_width = DebugColors::LayerAnimationBoundsBorderWidth();
721 label_text = "animation bounds"; 723 label_text = "animation bounds";
722 break; 724 break;
723 } 725 }
724 726
725 DrawDebugRect(canvas, 727 DrawDebugRect(canvas,
726 paint, 728 &paint,
727 debug_rects[i], 729 debug_rects[i],
728 stroke_color, 730 stroke_color,
729 fill_color, 731 fill_color,
730 stroke_width, 732 stroke_width,
731 label_text); 733 label_text);
732 } 734 }
733 735
734 if (new_paint_rects.size()) { 736 if (new_paint_rects.size()) {
735 paint_rects_.swap(new_paint_rects); 737 paint_rects_.swap(new_paint_rects);
736 fade_step_ = DebugColors::kFadeSteps; 738 fade_step_ = DebugColors::kFadeSteps;
737 } 739 }
738 if (fade_step_ > 0) { 740 if (fade_step_ > 0) {
739 fade_step_--; 741 fade_step_--;
740 for (size_t i = 0; i < paint_rects_.size(); ++i) { 742 for (size_t i = 0; i < paint_rects_.size(); ++i) {
741 DrawDebugRect(canvas, 743 DrawDebugRect(canvas,
742 paint, 744 &paint,
743 paint_rects_[i], 745 paint_rects_[i],
744 DebugColors::PaintRectBorderColor(fade_step_), 746 DebugColors::PaintRectBorderColor(fade_step_),
745 DebugColors::PaintRectFillColor(fade_step_), 747 DebugColors::PaintRectFillColor(fade_step_),
746 DebugColors::PaintRectBorderWidth(), 748 DebugColors::PaintRectBorderWidth(),
747 ""); 749 "");
748 } 750 }
749 } 751 }
750 } 752 }
751 753
752 const char* HeadsUpDisplayLayerImpl::LayerTypeAsString() const { 754 const char* HeadsUpDisplayLayerImpl::LayerTypeAsString() const {
753 return "cc::HeadsUpDisplayLayerImpl"; 755 return "cc::HeadsUpDisplayLayerImpl";
754 } 756 }
755 757
756 void HeadsUpDisplayLayerImpl::AsValueInto(base::DictionaryValue* dict) const { 758 void HeadsUpDisplayLayerImpl::AsValueInto(base::DictionaryValue* dict) const {
757 LayerImpl::AsValueInto(dict); 759 LayerImpl::AsValueInto(dict);
758 dict->SetString("layer_name", "Heads Up Display Layer"); 760 dict->SetString("layer_name", "Heads Up Display Layer");
759 } 761 }
760 762
761 } // namespace cc 763 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/heads_up_display_layer_impl.h ('k') | cc/layers/heads_up_display_layer_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698