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

Side by Side Diff: cc/output/delegating_renderer.cc

Issue 2194013002: cc: Delete the Renderer base class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@dcheck-delegating
Patch Set: delete-renderer-base-class: rebase Created 4 years, 4 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/output/delegating_renderer.h" 5 #include "cc/output/delegating_renderer.h"
6 6
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "base/trace_event/trace_event.h" 12 #include "base/trace_event/trace_event.h"
13 #include "cc/output/context_provider.h" 13 #include "cc/output/context_provider.h"
14 #include "cc/quads/draw_quad.h" 14 #include "cc/quads/draw_quad.h"
15 #include "cc/quads/render_pass.h" 15 #include "cc/quads/render_pass.h"
16 #include "cc/resources/resource_provider.h" 16 #include "cc/resources/resource_provider.h"
17 #include "gpu/command_buffer/client/context_support.h" 17 #include "gpu/command_buffer/client/context_support.h"
18 #include "gpu/command_buffer/client/gles2_interface.h" 18 #include "gpu/command_buffer/client/gles2_interface.h"
19 19
20 20
21 namespace cc { 21 namespace cc {
22 22
23 std::unique_ptr<DelegatingRenderer> DelegatingRenderer::Create( 23 DelegatingRenderer::DelegatingRenderer(OutputSurface* output_surface,
24 RendererClient* client,
25 const RendererSettings* settings,
26 OutputSurface* output_surface,
27 ResourceProvider* resource_provider) {
28 return base::WrapUnique(new DelegatingRenderer(
29 client, settings, output_surface, resource_provider));
30 }
31
32 DelegatingRenderer::DelegatingRenderer(RendererClient* client,
33 const RendererSettings* settings,
34 OutputSurface* output_surface,
35 ResourceProvider* resource_provider) 24 ResourceProvider* resource_provider)
36 : Renderer(client, settings), 25 : output_surface_(output_surface), resource_provider_(resource_provider) {
37 output_surface_(output_surface),
38 resource_provider_(resource_provider) {
39 DCHECK(resource_provider_); 26 DCHECK(resource_provider_);
40 27
41 capabilities_.using_partial_swap = false; 28 capabilities_.using_partial_swap = false;
42 capabilities_.max_texture_size = resource_provider_->max_texture_size(); 29 capabilities_.max_texture_size = resource_provider_->max_texture_size();
43 capabilities_.best_texture_format = resource_provider_->best_texture_format(); 30 capabilities_.best_texture_format = resource_provider_->best_texture_format();
44 capabilities_.allow_partial_texture_updates = 31 capabilities_.allow_partial_texture_updates =
45 output_surface->capabilities().can_force_reclaim_resources; 32 output_surface->capabilities().can_force_reclaim_resources;
46 33
47 if (!output_surface_->context_provider()) { 34 if (!output_surface_->context_provider()) {
48 capabilities_.using_shared_memory_resources = true; 35 capabilities_.using_shared_memory_resources = true;
(...skipping 10 matching lines...) Expand all
59 46
60 // If MSAA is slow, we want this renderer to behave as though MSAA is not 47 // If MSAA is slow, we want this renderer to behave as though MSAA is not
61 // available. Set samples to 0 to achieve this. 48 // available. Set samples to 0 to achieve this.
62 if (caps.msaa_is_slow) 49 if (caps.msaa_is_slow)
63 capabilities_.max_msaa_samples = 0; 50 capabilities_.max_msaa_samples = 0;
64 else 51 else
65 capabilities_.max_msaa_samples = caps.max_samples; 52 capabilities_.max_msaa_samples = caps.max_samples;
66 } 53 }
67 } 54 }
68 55
69 DelegatingRenderer::~DelegatingRenderer() {} 56 DelegatingRenderer::~DelegatingRenderer() = default;
70
71 const RendererCapabilitiesImpl& DelegatingRenderer::Capabilities() const {
72 return capabilities_;
73 }
74 57
75 void DelegatingRenderer::DrawFrame(RenderPassList* render_passes_in_draw_order, 58 void DelegatingRenderer::DrawFrame(RenderPassList* render_passes_in_draw_order,
76 float device_scale_factor, 59 float device_scale_factor,
77 const gfx::ColorSpace& device_color_space, 60 const gfx::ColorSpace& device_color_space,
78 const gfx::Rect& device_viewport_rect, 61 const gfx::Rect& device_viewport_rect,
79 const gfx::Rect& device_clip_rect) { 62 const gfx::Rect& device_clip_rect) {
80 TRACE_EVENT0("cc", "DelegatingRenderer::DrawFrame"); 63 TRACE_EVENT0("cc", "DelegatingRenderer::DrawFrame");
81 64
82 DCHECK(!delegated_frame_data_); 65 DCHECK(!delegated_frame_data_);
83 66
(...skipping 19 matching lines...) Expand all
103 compositor_frame.metadata = std::move(metadata); 86 compositor_frame.metadata = std::move(metadata);
104 compositor_frame.delegated_frame_data = std::move(delegated_frame_data_); 87 compositor_frame.delegated_frame_data = std::move(delegated_frame_data_);
105 output_surface_->SwapBuffers(std::move(compositor_frame)); 88 output_surface_->SwapBuffers(std::move(compositor_frame));
106 } 89 }
107 90
108 void DelegatingRenderer::ReclaimResources( 91 void DelegatingRenderer::ReclaimResources(
109 const ReturnedResourceArray& resources) { 92 const ReturnedResourceArray& resources) {
110 resource_provider_->ReceiveReturnsFromParent(resources); 93 resource_provider_->ReceiveReturnsFromParent(resources);
111 } 94 }
112 95
113 void DelegatingRenderer::DidChangeVisibility() { 96 void DelegatingRenderer::SetVisible(bool visible) {
97 if (visible == visible_)
98 return;
99 visible_ = visible;
114 ContextProvider* context_provider = output_surface_->context_provider(); 100 ContextProvider* context_provider = output_surface_->context_provider();
115 if (!visible()) { 101 if (!visible_) {
116 TRACE_EVENT0("cc", "DelegatingRenderer::SetVisible dropping resources"); 102 TRACE_EVENT0("cc", "DelegatingRenderer::SetVisible dropping resources");
117 if (context_provider) { 103 if (context_provider) {
118 context_provider->DeleteCachedResources(); 104 context_provider->DeleteCachedResources();
119 context_provider->ContextGL()->Flush(); 105 context_provider->ContextGL()->Flush();
120 } 106 }
121 } 107 }
122 if (context_provider) { 108 if (context_provider) {
123 // If we are not visible, we ask the context to aggressively free resources. 109 // If we are not visible, we ask the context to aggressively free resources.
124 context_provider->ContextSupport()->SetAggressivelyFreeResources( 110 context_provider->ContextSupport()->SetAggressivelyFreeResources(!visible_);
125 !visible());
126 } 111 }
127 } 112 }
128 113
129 } // namespace cc 114 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698