Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "services/ui/ws/frame_generator.h" | 5 #include "services/ui/ws/frame_generator.h" |
| 6 | 6 |
| 7 #include "base/containers/adapters.h" | 7 #include "base/containers/adapters.h" |
| 8 #include "cc/output/compositor_frame.h" | 8 #include "cc/output/compositor_frame.h" |
| 9 #include "cc/quads/render_pass.h" | 9 #include "cc/quads/render_pass.h" |
| 10 #include "cc/quads/render_pass_draw_quad.h" | |
| 10 #include "cc/quads/shared_quad_state.h" | 11 #include "cc/quads/shared_quad_state.h" |
| 11 #include "cc/quads/surface_draw_quad.h" | 12 #include "cc/quads/surface_draw_quad.h" |
| 12 #include "services/ui/surfaces/display_compositor.h" | 13 #include "services/ui/surfaces/display_compositor.h" |
| 13 #include "services/ui/ws/frame_generator_delegate.h" | 14 #include "services/ui/ws/frame_generator_delegate.h" |
| 14 #include "services/ui/ws/server_window.h" | 15 #include "services/ui/ws/server_window.h" |
| 15 #include "services/ui/ws/server_window_surface.h" | 16 #include "services/ui/ws/server_window_surface.h" |
| 16 #include "services/ui/ws/server_window_surface_manager.h" | 17 #include "services/ui/ws/server_window_surface_manager.h" |
| 17 | 18 |
| 18 namespace ui { | 19 namespace ui { |
| 19 | 20 |
| 20 namespace ws { | 21 namespace ws { |
| 21 | 22 |
| 22 FrameGenerator::FrameGenerator(FrameGeneratorDelegate* delegate, | 23 FrameGenerator::FrameGenerator(FrameGeneratorDelegate* delegate, |
| 23 scoped_refptr<GpuState> gpu_state, | 24 scoped_refptr<GpuState> gpu_state, |
| 24 scoped_refptr<SurfacesState> surfaces_state) | 25 scoped_refptr<SurfacesState> surfaces_state) |
| 25 : delegate_(delegate), | 26 : delegate_(delegate), |
| 26 gpu_state_(gpu_state), | 27 gpu_state_(gpu_state), |
| 27 surfaces_state_(surfaces_state), | 28 surfaces_state_(surfaces_state), |
| 28 draw_timer_(false, false), | 29 draw_timer_(false, false), |
| 29 weak_factory_(this) {} | 30 weak_factory_(this) { |
| 31 DCHECK(delegate_); | |
| 32 } | |
| 30 | 33 |
| 31 FrameGenerator::~FrameGenerator() { | 34 FrameGenerator::~FrameGenerator() { |
| 32 // Invalidate WeakPtrs now to avoid callbacks back into the | 35 // Invalidate WeakPtrs now to avoid callbacks back into the |
| 33 // FrameGenerator during destruction of |display_compositor_|. | 36 // FrameGenerator during destruction of |display_compositor_|. |
| 34 weak_factory_.InvalidateWeakPtrs(); | 37 weak_factory_.InvalidateWeakPtrs(); |
| 35 display_compositor_.reset(); | 38 display_compositor_.reset(); |
| 36 } | 39 } |
| 37 | 40 |
| 38 void FrameGenerator::RequestRedraw(const gfx::Rect& redraw_region) { | 41 void FrameGenerator::RequestRedraw(const gfx::Rect& redraw_region) { |
| 39 dirty_rect_.Union(redraw_region); | 42 dirty_rect_.Union(redraw_region); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 83 void FrameGenerator::DidDraw(cc::SurfaceDrawStatus status) { | 86 void FrameGenerator::DidDraw(cc::SurfaceDrawStatus status) { |
| 84 frame_pending_ = false; | 87 frame_pending_ = false; |
| 85 delegate_->OnCompositorFrameDrawn(); | 88 delegate_->OnCompositorFrameDrawn(); |
| 86 if (!dirty_rect_.IsEmpty()) | 89 if (!dirty_rect_.IsEmpty()) |
| 87 WantToDraw(); | 90 WantToDraw(); |
| 88 } | 91 } |
| 89 | 92 |
| 90 cc::CompositorFrame FrameGenerator::GenerateCompositorFrame() { | 93 cc::CompositorFrame FrameGenerator::GenerateCompositorFrame() { |
| 91 const ViewportMetrics& metrics = delegate_->GetViewportMetrics(); | 94 const ViewportMetrics& metrics = delegate_->GetViewportMetrics(); |
| 92 std::unique_ptr<cc::RenderPass> render_pass = cc::RenderPass::Create(); | 95 std::unique_ptr<cc::RenderPass> render_pass = cc::RenderPass::Create(); |
| 93 render_pass->damage_rect = dirty_rect_; | 96 gfx::Rect output_rect(metrics.size_in_pixels); |
| 94 render_pass->output_rect = gfx::Rect(metrics.size_in_pixels); | 97 dirty_rect_.Intersect(output_rect); |
| 98 render_pass->SetNew(cc::RenderPassId(1, 1), output_rect, dirty_rect_, | |
| 99 gfx::Transform()); | |
| 95 | 100 |
| 96 DrawWindowTree(render_pass.get(), delegate_->GetRootWindow(), gfx::Vector2d(), | 101 DrawWindowTree(render_pass.get(), delegate_->GetRootWindow(), gfx::Vector2d(), |
| 97 1.0f); | 102 1.0f); |
| 98 | 103 |
| 99 std::unique_ptr<cc::DelegatedFrameData> frame_data( | 104 std::unique_ptr<cc::DelegatedFrameData> frame_data( |
| 100 new cc::DelegatedFrameData); | 105 new cc::DelegatedFrameData); |
| 101 frame_data->render_pass_list.push_back(std::move(render_pass)); | 106 frame_data->render_pass_list.push_back(std::move(render_pass)); |
| 107 if (delegate_->IsInHighContrastMode()) { | |
| 108 std::unique_ptr<cc::RenderPass> invert_pass = cc::RenderPass::Create(); | |
|
danakj
2016/07/08 19:59:23
pls call SetNew on the pass, rather than setting a
sadrul
2016/07/08 20:10:27
Done.
| |
| 109 invert_pass->damage_rect = dirty_rect_; | |
| 110 invert_pass->output_rect = gfx::Rect(metrics.size_in_pixels); | |
| 111 ServerWindow* root = delegate_->GetRootWindow(); | |
| 112 cc::SharedQuadState* shared_state = | |
| 113 invert_pass->CreateAndAppendSharedQuadState(); | |
| 114 shared_state->SetAll(gfx::Transform(), root->bounds().size(), | |
|
danakj
2016/07/08 19:59:23
Why are you using these root bounds. Are they not
sadrul
2016/07/08 20:10:27
Done.
| |
| 115 root->bounds(), root->bounds(), false, 1.f, | |
| 116 SkXfermode::kSrcOver_Mode, 0); | |
| 117 auto* quad = invert_pass->CreateAndAppendDrawQuad<cc::RenderPassDrawQuad>(); | |
| 118 cc::FilterOperations filters; | |
| 119 filters.Append(cc::FilterOperation::CreateInvertFilter(1.0)); | |
| 120 quad->SetNew(shared_state, root->bounds(), root->bounds(), | |
| 121 cc::RenderPassId(1, 1), | |
| 122 0, // mask_resource_id | |
|
danakj
2016/07/08 19:59:23
if you use /* */ then it can pack parameters bette
sadrul
2016/07/08 20:10:27
Done.
| |
| 123 gfx::Vector2dF(), gfx::Size(), filters, gfx::Vector2dF(), | |
| 124 cc::FilterOperations()); | |
| 125 frame_data->render_pass_list.push_back(std::move(invert_pass)); | |
| 126 } | |
| 102 | 127 |
| 103 cc::CompositorFrame frame; | 128 cc::CompositorFrame frame; |
| 104 frame.delegated_frame_data = std::move(frame_data); | 129 frame.delegated_frame_data = std::move(frame_data); |
| 105 return frame; | 130 return frame; |
| 106 } | 131 } |
| 107 | 132 |
| 108 void FrameGenerator::DrawWindowTree( | 133 void FrameGenerator::DrawWindowTree( |
| 109 cc::RenderPass* pass, | 134 cc::RenderPass* pass, |
| 110 ServerWindow* window, | 135 ServerWindow* window, |
| 111 const gfx::Vector2d& parent_to_root_origin_offset, | 136 const gfx::Vector2d& parent_to_root_origin_offset, |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 176 quad->SetAll(sqs, bounds_at_origin /* rect */, | 201 quad->SetAll(sqs, bounds_at_origin /* rect */, |
| 177 gfx::Rect() /* opaque_rect */, | 202 gfx::Rect() /* opaque_rect */, |
| 178 bounds_at_origin /* visible_rect */, true /* needs_blending*/, | 203 bounds_at_origin /* visible_rect */, true /* needs_blending*/, |
| 179 underlay_surface->id()); | 204 underlay_surface->id()); |
| 180 } | 205 } |
| 181 } | 206 } |
| 182 | 207 |
| 183 } // namespace ws | 208 } // namespace ws |
| 184 | 209 |
| 185 } // namespace ui | 210 } // namespace ui |
| OLD | NEW |