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

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

Issue 1535833002: Delete CC. (Closed) Base URL: git@github.com:domokit/mojo.git@moz-5
Patch Set: rebase Created 4 years, 11 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
« no previous file with comments | « cc/output/delegating_renderer.h ('k') | cc/output/delegating_renderer_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "cc/output/delegating_renderer.h"
6
7 #include <set>
8 #include <string>
9 #include <vector>
10
11 #include "base/trace_event/trace_event.h"
12 #include "cc/output/compositor_frame_ack.h"
13 #include "cc/output/context_provider.h"
14 #include "cc/quads/draw_quad.h"
15 #include "cc/quads/render_pass.h"
16 #include "cc/resources/resource_provider.h"
17 #include "gpu/command_buffer/client/context_support.h"
18 #include "gpu/command_buffer/client/gles2_interface.h"
19
20
21 namespace cc {
22
23 scoped_ptr<DelegatingRenderer> DelegatingRenderer::Create(
24 RendererClient* client,
25 const RendererSettings* settings,
26 OutputSurface* output_surface,
27 ResourceProvider* resource_provider) {
28 return make_scoped_ptr(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)
36 : Renderer(client, settings),
37 output_surface_(output_surface),
38 resource_provider_(resource_provider) {
39 DCHECK(resource_provider_);
40
41 capabilities_.using_partial_swap = false;
42 capabilities_.max_texture_size = resource_provider_->max_texture_size();
43 capabilities_.best_texture_format = resource_provider_->best_texture_format();
44 capabilities_.allow_partial_texture_updates =
45 output_surface->capabilities().can_force_reclaim_resources;
46
47 if (!output_surface_->context_provider()) {
48 capabilities_.using_shared_memory_resources = true;
49 } else {
50 const ContextProvider::Capabilities& caps =
51 output_surface_->context_provider()->ContextCapabilities();
52
53 DCHECK(!caps.gpu.iosurface || caps.gpu.texture_rectangle);
54
55 capabilities_.using_egl_image = caps.gpu.egl_image_external;
56 capabilities_.using_image = caps.gpu.image;
57
58 capabilities_.allow_rasterize_on_demand = false;
59 }
60 }
61
62 DelegatingRenderer::~DelegatingRenderer() {}
63
64 const RendererCapabilitiesImpl& DelegatingRenderer::Capabilities() const {
65 return capabilities_;
66 }
67
68 static ResourceProvider::ResourceId AppendToArray(
69 ResourceProvider::ResourceIdArray* array,
70 ResourceProvider::ResourceId id) {
71 array->push_back(id);
72 return id;
73 }
74
75 void DelegatingRenderer::DrawFrame(RenderPassList* render_passes_in_draw_order,
76 float device_scale_factor,
77 const gfx::Rect& device_viewport_rect,
78 const gfx::Rect& device_clip_rect,
79 bool disable_picture_quad_image_filtering) {
80 TRACE_EVENT0("cc", "DelegatingRenderer::DrawFrame");
81
82 DCHECK(!delegated_frame_data_);
83
84 delegated_frame_data_ = make_scoped_ptr(new DelegatedFrameData);
85 DelegatedFrameData& out_data = *delegated_frame_data_;
86 out_data.device_scale_factor = device_scale_factor;
87 // Move the render passes and resources into the |out_frame|.
88 out_data.render_pass_list.swap(*render_passes_in_draw_order);
89
90 // Collect all resource ids in the render passes into a ResourceIdArray.
91 ResourceProvider::ResourceIdArray resources;
92 DrawQuad::ResourceIteratorCallback append_to_array =
93 base::Bind(&AppendToArray, &resources);
94 for (const auto& render_pass : out_data.render_pass_list) {
95 for (const auto& quad : render_pass->quad_list)
96 quad->IterateResources(append_to_array);
97 }
98 resource_provider_->PrepareSendToParent(resources, &out_data.resource_list);
99 }
100
101 void DelegatingRenderer::SwapBuffers(const CompositorFrameMetadata& metadata) {
102 TRACE_EVENT0("cc,benchmark", "DelegatingRenderer::SwapBuffers");
103 CompositorFrame compositor_frame;
104 compositor_frame.metadata = metadata;
105 compositor_frame.delegated_frame_data = delegated_frame_data_.Pass();
106 output_surface_->SwapBuffers(&compositor_frame);
107 }
108
109 void DelegatingRenderer::ReceiveSwapBuffersAck(
110 const CompositorFrameAck& ack) {
111 resource_provider_->ReceiveReturnsFromParent(ack.resources);
112 }
113
114 void DelegatingRenderer::DidChangeVisibility() {
115 ContextProvider* context_provider = output_surface_->context_provider();
116 if (!visible()) {
117 TRACE_EVENT0("cc", "DelegatingRenderer::SetVisible dropping resources");
118 resource_provider_->ReleaseCachedData();
119 if (context_provider) {
120 context_provider->DeleteCachedResources();
121 context_provider->ContextGL()->Flush();
122 }
123 }
124 // We loop visibility to the GPU process, since that's what manages memory.
125 // That will allow it to feed us with memory allocations that we can act
126 // upon.
127 if (context_provider)
128 context_provider->ContextSupport()->SetSurfaceVisible(visible());
129 }
130
131 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/delegating_renderer.h ('k') | cc/output/delegating_renderer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698