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

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

Issue 23961003: cc: Remove most methods from RendererClient. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rendererclient: rebase Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « cc/output/direct_renderer.h ('k') | cc/output/gl_renderer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/direct_renderer.h" 5 #include "cc/output/direct_renderer.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/containers/hash_tables.h" 10 #include "base/containers/hash_tables.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 const gfx::RectF& draw_rect) const { 120 const gfx::RectF& draw_rect) const {
121 gfx::Rect window_rect = gfx::ToEnclosingRect(draw_rect); 121 gfx::Rect window_rect = gfx::ToEnclosingRect(draw_rect);
122 window_rect -= current_draw_rect_.OffsetFromOrigin(); 122 window_rect -= current_draw_rect_.OffsetFromOrigin();
123 window_rect += current_viewport_rect_.OffsetFromOrigin(); 123 window_rect += current_viewport_rect_.OffsetFromOrigin();
124 if (FlippedFramebuffer()) 124 if (FlippedFramebuffer())
125 window_rect.set_y(current_surface_size_.height() - window_rect.bottom()); 125 window_rect.set_y(current_surface_size_.height() - window_rect.bottom());
126 return window_rect; 126 return window_rect;
127 } 127 }
128 128
129 DirectRenderer::DirectRenderer(RendererClient* client, 129 DirectRenderer::DirectRenderer(RendererClient* client,
130 const LayerTreeSettings* settings,
130 OutputSurface* output_surface, 131 OutputSurface* output_surface,
131 ResourceProvider* resource_provider) 132 ResourceProvider* resource_provider)
132 : Renderer(client), 133 : Renderer(client, settings),
133 output_surface_(output_surface), 134 output_surface_(output_surface),
134 resource_provider_(resource_provider) {} 135 resource_provider_(resource_provider) {}
135 136
136 DirectRenderer::~DirectRenderer() {} 137 DirectRenderer::~DirectRenderer() {}
137 138
138 bool DirectRenderer::CanReadPixels() const { return true; } 139 bool DirectRenderer::CanReadPixels() const { return true; }
139 140
140 void DirectRenderer::SetEnlargePassTextureAmountForTesting( 141 void DirectRenderer::SetEnlargePassTextureAmountForTesting(
141 gfx::Vector2d amount) { 142 gfx::Vector2d amount) {
142 enlarge_pass_texture_amount_ = amount; 143 enlarge_pass_texture_amount_ = amount;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 if (!render_pass_textures_.contains(render_passes_in_draw_order[i]->id)) { 188 if (!render_pass_textures_.contains(render_passes_in_draw_order[i]->id)) {
188 scoped_ptr<CachedResource> texture = 189 scoped_ptr<CachedResource> texture =
189 CachedResource::Create(resource_provider_); 190 CachedResource::Create(resource_provider_);
190 render_pass_textures_.set(render_passes_in_draw_order[i]->id, 191 render_pass_textures_.set(render_passes_in_draw_order[i]->id,
191 texture.Pass()); 192 texture.Pass());
192 } 193 }
193 } 194 }
194 } 195 }
195 196
196 void DirectRenderer::DrawFrame(RenderPassList* render_passes_in_draw_order, 197 void DirectRenderer::DrawFrame(RenderPassList* render_passes_in_draw_order,
197 ContextProvider* offscreen_context_provider) { 198 ContextProvider* offscreen_context_provider,
199 float device_scale_factor,
200 bool allow_partial_swap) {
198 TRACE_EVENT0("cc", "DirectRenderer::DrawFrame"); 201 TRACE_EVENT0("cc", "DirectRenderer::DrawFrame");
199 UMA_HISTOGRAM_COUNTS("Renderer4.renderPassCount", 202 UMA_HISTOGRAM_COUNTS("Renderer4.renderPassCount",
200 render_passes_in_draw_order->size()); 203 render_passes_in_draw_order->size());
201 204
202 const RenderPass* root_render_pass = render_passes_in_draw_order->back(); 205 const RenderPass* root_render_pass = render_passes_in_draw_order->back();
203 DCHECK(root_render_pass); 206 DCHECK(root_render_pass);
204 207
205 DrawingFrame frame; 208 DrawingFrame frame;
206 frame.root_render_pass = root_render_pass; 209 frame.root_render_pass = root_render_pass;
207 frame.root_damage_rect = 210 frame.root_damage_rect =
208 Capabilities().using_partial_swap && client_->AllowPartialSwap() ? 211 Capabilities().using_partial_swap && allow_partial_swap
209 root_render_pass->damage_rect : root_render_pass->output_rect; 212 ? root_render_pass->damage_rect
213 : root_render_pass->output_rect;
210 frame.root_damage_rect.Intersect(gfx::Rect(client_->DeviceViewport().size())); 214 frame.root_damage_rect.Intersect(gfx::Rect(client_->DeviceViewport().size()));
211 frame.offscreen_context_provider = offscreen_context_provider; 215 frame.offscreen_context_provider = offscreen_context_provider;
212 216
213 EnsureBackbuffer(); 217 EnsureBackbuffer();
214 218
215 // Only reshape when we know we are going to draw. Otherwise, the reshape 219 // Only reshape when we know we are going to draw. Otherwise, the reshape
216 // can leave the window at the wrong size if we never draw and the proper 220 // can leave the window at the wrong size if we never draw and the proper
217 // viewport size is never set. 221 // viewport size is never set.
218 output_surface_->Reshape(client_->DeviceViewport().size(), 222 output_surface_->Reshape(client_->DeviceViewport().size(),
219 client_->DeviceScaleFactor()); 223 device_scale_factor);
220 224
221 BeginDrawingFrame(&frame); 225 BeginDrawingFrame(&frame);
222 for (size_t i = 0; i < render_passes_in_draw_order->size(); ++i) { 226 for (size_t i = 0; i < render_passes_in_draw_order->size(); ++i) {
223 RenderPass* pass = render_passes_in_draw_order->at(i); 227 RenderPass* pass = render_passes_in_draw_order->at(i);
224 DrawRenderPass(&frame, pass); 228 DrawRenderPass(&frame, pass, allow_partial_swap);
225 229
226 for (ScopedPtrVector<CopyOutputRequest>::iterator it = 230 for (ScopedPtrVector<CopyOutputRequest>::iterator it =
227 pass->copy_requests.begin(); 231 pass->copy_requests.begin();
228 it != pass->copy_requests.end(); 232 it != pass->copy_requests.end();
229 ++it) { 233 ++it) {
230 if (i > 0) { 234 if (i > 0) {
231 // Doing a readback is destructive of our state on Mac, so make sure 235 // Doing a readback is destructive of our state on Mac, so make sure
232 // we restore the state between readbacks. http://crbug.com/99393. 236 // we restore the state between readbacks. http://crbug.com/99393.
233 UseRenderPass(&frame, pass); 237 UseRenderPass(&frame, pass);
234 } 238 }
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 gfx::RectF draw_space_rect) { 316 gfx::RectF draw_space_rect) {
313 gfx::Rect window_space_rect = MoveFromDrawToWindowSpace(draw_space_rect); 317 gfx::Rect window_space_rect = MoveFromDrawToWindowSpace(draw_space_rect);
314 if (NeedDeviceClip(frame)) 318 if (NeedDeviceClip(frame))
315 window_space_rect.Intersect(DeviceClipRect(frame)); 319 window_space_rect.Intersect(DeviceClipRect(frame));
316 SetScissorTestRect(window_space_rect); 320 SetScissorTestRect(window_space_rect);
317 } 321 }
318 322
319 void DirectRenderer::FinishDrawingQuadList() {} 323 void DirectRenderer::FinishDrawingQuadList() {}
320 324
321 void DirectRenderer::DrawRenderPass(DrawingFrame* frame, 325 void DirectRenderer::DrawRenderPass(DrawingFrame* frame,
322 const RenderPass* render_pass) { 326 const RenderPass* render_pass,
327 bool allow_partial_swap) {
323 TRACE_EVENT0("cc", "DirectRenderer::DrawRenderPass"); 328 TRACE_EVENT0("cc", "DirectRenderer::DrawRenderPass");
324 if (!UseRenderPass(frame, render_pass)) 329 if (!UseRenderPass(frame, render_pass))
325 return; 330 return;
326 331
327 bool using_scissor_as_optimization = 332 bool using_scissor_as_optimization =
328 Capabilities().using_partial_swap && client_->AllowPartialSwap(); 333 Capabilities().using_partial_swap && allow_partial_swap;
329 gfx::RectF render_pass_scissor; 334 gfx::RectF render_pass_scissor;
330 335
331 if (using_scissor_as_optimization) { 336 if (using_scissor_as_optimization) {
332 render_pass_scissor = ComputeScissorRectForRenderPass(frame); 337 render_pass_scissor = ComputeScissorRectForRenderPass(frame);
333 SetScissorTestRectInDrawSpace(frame, render_pass_scissor); 338 SetScissorTestRectInDrawSpace(frame, render_pass_scissor);
334 } 339 }
335 340
336 if (frame->current_render_pass != frame->root_render_pass || 341 if (frame->current_render_pass != frame->root_render_pass ||
337 client_->ShouldClearRootRenderPass()) { 342 settings_->should_clear_root_render_pass) {
338 if (NeedDeviceClip(frame)) 343 if (NeedDeviceClip(frame))
339 SetScissorTestRect(DeviceClipRect(frame)); 344 SetScissorTestRect(DeviceClipRect(frame));
340 else if (!using_scissor_as_optimization) 345 else if (!using_scissor_as_optimization)
341 EnsureScissorTestDisabled(); 346 EnsureScissorTestDisabled();
342 ClearFramebuffer(frame); 347 ClearFramebuffer(frame);
343 } 348 }
344 349
345 const QuadList& quad_list = render_pass->quad_list; 350 const QuadList& quad_list = render_pass->quad_list;
346 for (QuadList::ConstBackToFrontIterator it = quad_list.BackToFrontBegin(); 351 for (QuadList::ConstBackToFrontIterator it = quad_list.BackToFrontBegin();
347 it != quad_list.BackToFrontEnd(); 352 it != quad_list.BackToFrontEnd();
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 !texture->Allocate(size, 400 !texture->Allocate(size,
396 RenderPassTextureFormat(render_pass), 401 RenderPassTextureFormat(render_pass),
397 ResourceProvider::TextureUsageFramebuffer)) 402 ResourceProvider::TextureUsageFramebuffer))
398 return false; 403 return false;
399 404
400 return BindFramebufferToTexture(frame, texture, render_pass->output_rect); 405 return BindFramebufferToTexture(frame, texture, render_pass->output_rect);
401 } 406 }
402 407
403 bool DirectRenderer::HaveCachedResourcesForRenderPassId(RenderPass::Id id) 408 bool DirectRenderer::HaveCachedResourcesForRenderPassId(RenderPass::Id id)
404 const { 409 const {
405 if (!Settings().cache_render_pass_contents) 410 if (!settings_->cache_render_pass_contents)
406 return false; 411 return false;
407 412
408 CachedResource* texture = render_pass_textures_.get(id); 413 CachedResource* texture = render_pass_textures_.get(id);
409 return texture && texture->id() && texture->is_complete(); 414 return texture && texture->id() && texture->is_complete();
410 } 415 }
411 416
412 // static 417 // static
413 gfx::Size DirectRenderer::RenderPassTextureSize(const RenderPass* render_pass) { 418 gfx::Size DirectRenderer::RenderPassTextureSize(const RenderPass* render_pass) {
414 return render_pass->output_rect.size(); 419 return render_pass->output_rect.size();
415 } 420 }
416 421
417 // static 422 // static
418 GLenum DirectRenderer::RenderPassTextureFormat(const RenderPass* render_pass) { 423 GLenum DirectRenderer::RenderPassTextureFormat(const RenderPass* render_pass) {
419 return GL_RGBA; 424 return GL_RGBA;
420 } 425 }
421 426
422 } // namespace cc 427 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/direct_renderer.h ('k') | cc/output/gl_renderer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698