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

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

Issue 789433003: [cc] Add nearest neighbor filtering for PictureLayer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync and rebase Created 6 years 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/renderer_pixeltest.cc ('k') | cc/output/software_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/software_renderer.h" 5 #include "cc/output/software_renderer.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "cc/base/math_util.h" 8 #include "cc/base/math_util.h"
9 #include "cc/output/compositor_frame.h" 9 #include "cc/output/compositor_frame.h"
10 #include "cc/output/compositor_frame_ack.h" 10 #include "cc/output/compositor_frame_ack.h"
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 gfx::RectFToSkRect(quad->tex_coord_rect), 340 gfx::RectFToSkRect(quad->tex_coord_rect),
341 gfx::RectFToSkRect(QuadVertexRect()), 341 gfx::RectFToSkRect(QuadVertexRect()),
342 SkMatrix::kFill_ScaleToFit); 342 SkMatrix::kFill_ScaleToFit);
343 current_canvas_->concat(content_matrix); 343 current_canvas_->concat(content_matrix);
344 344
345 // TODO(aelias): This isn't correct in all cases. We should detect these 345 // TODO(aelias): This isn't correct in all cases. We should detect these
346 // cases and fall back to a persistent bitmap backing 346 // cases and fall back to a persistent bitmap backing
347 // (http://crbug.com/280374). 347 // (http://crbug.com/280374).
348 skia::RefPtr<SkDrawFilter> opacity_filter = 348 skia::RefPtr<SkDrawFilter> opacity_filter =
349 skia::AdoptRef(new skia::OpacityDrawFilter( 349 skia::AdoptRef(new skia::OpacityDrawFilter(
350 quad->opacity(), frame->disable_picture_quad_image_filtering)); 350 quad->opacity(), frame->disable_picture_quad_image_filtering ||
351 quad->nearest_neighbor));
351 DCHECK(!current_canvas_->getDrawFilter()); 352 DCHECK(!current_canvas_->getDrawFilter());
352 current_canvas_->setDrawFilter(opacity_filter.get()); 353 current_canvas_->setDrawFilter(opacity_filter.get());
353 354
354 TRACE_EVENT0("cc", 355 TRACE_EVENT0("cc",
355 "SoftwareRenderer::DrawPictureQuad"); 356 "SoftwareRenderer::DrawPictureQuad");
356 357
357 quad->raster_source->PlaybackToSharedCanvas( 358 quad->raster_source->PlaybackToSharedCanvas(
358 current_canvas_, quad->content_rect, quad->contents_scale); 359 current_canvas_, quad->content_rect, quad->contents_scale);
359 360
360 current_canvas_->setDrawFilter(NULL); 361 current_canvas_->setDrawFilter(NULL);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 if (!lock.valid()) 443 if (!lock.valid())
443 return; 444 return;
444 DCHECK_EQ(GL_CLAMP_TO_EDGE, lock.wrap_mode()); 445 DCHECK_EQ(GL_CLAMP_TO_EDGE, lock.wrap_mode());
445 446
446 gfx::RectF visible_tex_coord_rect = MathUtil::ScaleRectProportional( 447 gfx::RectF visible_tex_coord_rect = MathUtil::ScaleRectProportional(
447 quad->tex_coord_rect, quad->rect, quad->visible_rect); 448 quad->tex_coord_rect, quad->rect, quad->visible_rect);
448 gfx::RectF visible_quad_vertex_rect = MathUtil::ScaleRectProportional( 449 gfx::RectF visible_quad_vertex_rect = MathUtil::ScaleRectProportional(
449 QuadVertexRect(), quad->rect, quad->visible_rect); 450 QuadVertexRect(), quad->rect, quad->visible_rect);
450 451
451 SkRect uv_rect = gfx::RectFToSkRect(visible_tex_coord_rect); 452 SkRect uv_rect = gfx::RectFToSkRect(visible_tex_coord_rect);
452 current_paint_.setFilterLevel(SkPaint::kLow_FilterLevel); 453 current_paint_.setFilterLevel(quad->nearest_neighbor
454 ? SkPaint::kNone_FilterLevel
455 : SkPaint::kLow_FilterLevel);
453 current_canvas_->drawBitmapRectToRect( 456 current_canvas_->drawBitmapRectToRect(
454 *lock.sk_bitmap(), 457 *lock.sk_bitmap(),
455 &uv_rect, 458 &uv_rect,
456 gfx::RectFToSkRect(visible_quad_vertex_rect), 459 gfx::RectFToSkRect(visible_quad_vertex_rect),
457 &current_paint_); 460 &current_paint_);
458 } 461 }
459 462
460 void SoftwareRenderer::DrawRenderPassQuad(const DrawingFrame* frame, 463 void SoftwareRenderer::DrawRenderPassQuad(const DrawingFrame* frame,
461 const RenderPassDrawQuad* quad) { 464 const RenderPassDrawQuad* quad) {
462 ScopedResource* content_texture = 465 ScopedResource* content_texture =
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 } 607 }
605 608
606 void SoftwareRenderer::DidChangeVisibility() { 609 void SoftwareRenderer::DidChangeVisibility() {
607 if (visible()) 610 if (visible())
608 EnsureBackbuffer(); 611 EnsureBackbuffer();
609 else 612 else
610 DiscardBackbuffer(); 613 DiscardBackbuffer();
611 } 614 }
612 615
613 } // namespace cc 616 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/renderer_pixeltest.cc ('k') | cc/output/software_renderer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698