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

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

Issue 23171014: Fix UpdateTilePriorities viewport in Android WebView. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase to 221292 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
« no previous file with comments | « cc/output/direct_renderer.h ('k') | cc/output/gl_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
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 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 // Only intersect inverse-projected damage if the transform is invertible. 253 // Only intersect inverse-projected damage if the transform is invertible.
254 gfx::RectF damage_rect_in_render_pass_space = 254 gfx::RectF damage_rect_in_render_pass_space =
255 MathUtil::ProjectClippedRect(inverse_transform, 255 MathUtil::ProjectClippedRect(inverse_transform,
256 frame->root_damage_rect); 256 frame->root_damage_rect);
257 render_pass_scissor.Intersect(damage_rect_in_render_pass_space); 257 render_pass_scissor.Intersect(damage_rect_in_render_pass_space);
258 } 258 }
259 259
260 return render_pass_scissor; 260 return render_pass_scissor;
261 } 261 }
262 262
263 bool DirectRenderer::NeedDeviceClip(const DrawingFrame* frame) const {
264 if (frame->current_render_pass != frame->root_render_pass)
265 return false;
266
267 return !client_->DeviceClip().Contains(client_->DeviceViewport());
268 }
269
270 gfx::Rect DirectRenderer::DeviceClipRect(const DrawingFrame* frame) const {
271 gfx::Rect device_clip_rect = client_->DeviceClip();
272 if (FlippedFramebuffer())
273 device_clip_rect.set_y(current_surface_size_.height() -
274 device_clip_rect.bottom());
275 return device_clip_rect;
276 }
277
263 void DirectRenderer::SetScissorStateForQuad(const DrawingFrame* frame, 278 void DirectRenderer::SetScissorStateForQuad(const DrawingFrame* frame,
264 const DrawQuad& quad) { 279 const DrawQuad& quad) {
265 if (quad.isClipped()) { 280 if (quad.isClipped()) {
266 gfx::RectF quad_scissor_rect = quad.clipRect(); 281 SetScissorTestRectInDrawSpace(frame, quad.clipRect());
267 SetScissorTestRect(MoveFromDrawToWindowSpace(quad_scissor_rect)); 282 return;
268 } else {
269 EnsureScissorTestDisabled();
270 } 283 }
284 if (NeedDeviceClip(frame)) {
285 SetScissorTestRect(DeviceClipRect(frame));
286 return;
287 }
288
289 EnsureScissorTestDisabled();
271 } 290 }
272 291
273 void DirectRenderer::SetScissorStateForQuadWithRenderPassScissor( 292 void DirectRenderer::SetScissorStateForQuadWithRenderPassScissor(
274 const DrawingFrame* frame, 293 const DrawingFrame* frame,
275 const DrawQuad& quad, 294 const DrawQuad& quad,
276 const gfx::RectF& render_pass_scissor, 295 const gfx::RectF& render_pass_scissor,
277 bool* should_skip_quad) { 296 bool* should_skip_quad) {
278 gfx::RectF quad_scissor_rect = render_pass_scissor; 297 gfx::RectF quad_scissor_rect = render_pass_scissor;
279 298
280 if (quad.isClipped()) 299 if (quad.isClipped())
281 quad_scissor_rect.Intersect(quad.clipRect()); 300 quad_scissor_rect.Intersect(quad.clipRect());
282 301
283 if (quad_scissor_rect.IsEmpty()) { 302 if (quad_scissor_rect.IsEmpty()) {
284 *should_skip_quad = true; 303 *should_skip_quad = true;
285 return; 304 return;
286 } 305 }
287 306
288 *should_skip_quad = false; 307 *should_skip_quad = false;
289 SetScissorTestRect(MoveFromDrawToWindowSpace(quad_scissor_rect)); 308 SetScissorTestRectInDrawSpace(frame, quad_scissor_rect);
309 }
310
311 void DirectRenderer::SetScissorTestRectInDrawSpace(const DrawingFrame* frame,
312 gfx::RectF draw_space_rect) {
313 gfx::Rect window_space_rect = MoveFromDrawToWindowSpace(draw_space_rect);
314 if (NeedDeviceClip(frame))
315 window_space_rect.Intersect(DeviceClipRect(frame));
316 SetScissorTestRect(window_space_rect);
290 } 317 }
291 318
292 void DirectRenderer::FinishDrawingQuadList() {} 319 void DirectRenderer::FinishDrawingQuadList() {}
293 320
294 void DirectRenderer::DrawRenderPass(DrawingFrame* frame, 321 void DirectRenderer::DrawRenderPass(DrawingFrame* frame,
295 const RenderPass* render_pass) { 322 const RenderPass* render_pass) {
296 TRACE_EVENT0("cc", "DirectRenderer::DrawRenderPass"); 323 TRACE_EVENT0("cc", "DirectRenderer::DrawRenderPass");
297 if (!UseRenderPass(frame, render_pass)) 324 if (!UseRenderPass(frame, render_pass))
298 return; 325 return;
299 326
300 bool using_scissor_as_optimization = 327 bool using_scissor_as_optimization =
301 Capabilities().using_partial_swap && client_->AllowPartialSwap(); 328 Capabilities().using_partial_swap && client_->AllowPartialSwap();
302 gfx::RectF render_pass_scissor; 329 gfx::RectF render_pass_scissor;
303 330
304 if (using_scissor_as_optimization) { 331 if (using_scissor_as_optimization) {
305 render_pass_scissor = ComputeScissorRectForRenderPass(frame); 332 render_pass_scissor = ComputeScissorRectForRenderPass(frame);
306 SetScissorTestRect(MoveFromDrawToWindowSpace(render_pass_scissor)); 333 SetScissorTestRectInDrawSpace(frame, render_pass_scissor);
307 } 334 }
308 335
309 if (frame->current_render_pass != frame->root_render_pass || 336 if (frame->current_render_pass != frame->root_render_pass ||
310 client_->ShouldClearRootRenderPass()) { 337 client_->ShouldClearRootRenderPass()) {
311 if (!using_scissor_as_optimization) 338 if (NeedDeviceClip(frame))
339 SetScissorTestRect(DeviceClipRect(frame));
340 else if (!using_scissor_as_optimization)
312 EnsureScissorTestDisabled(); 341 EnsureScissorTestDisabled();
313 ClearFramebuffer(frame); 342 ClearFramebuffer(frame);
314 } 343 }
315 344
316 const QuadList& quad_list = render_pass->quad_list; 345 const QuadList& quad_list = render_pass->quad_list;
317 for (QuadList::ConstBackToFrontIterator it = quad_list.BackToFrontBegin(); 346 for (QuadList::ConstBackToFrontIterator it = quad_list.BackToFrontBegin();
318 it != quad_list.BackToFrontEnd(); 347 it != quad_list.BackToFrontEnd();
319 ++it) { 348 ++it) {
320 const DrawQuad& quad = *(*it); 349 const DrawQuad& quad = *(*it);
321 bool should_skip_quad = false; 350 bool should_skip_quad = false;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 gfx::Size DirectRenderer::RenderPassTextureSize(const RenderPass* render_pass) { 413 gfx::Size DirectRenderer::RenderPassTextureSize(const RenderPass* render_pass) {
385 return render_pass->output_rect.size(); 414 return render_pass->output_rect.size();
386 } 415 }
387 416
388 // static 417 // static
389 GLenum DirectRenderer::RenderPassTextureFormat(const RenderPass* render_pass) { 418 GLenum DirectRenderer::RenderPassTextureFormat(const RenderPass* render_pass) {
390 return GL_RGBA; 419 return GL_RGBA;
391 } 420 }
392 421
393 } // namespace cc 422 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/direct_renderer.h ('k') | cc/output/gl_renderer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698