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

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

Issue 191123002: Implement hidpi and pinch-zoom scaling of filter params in cc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixes Created 6 years, 9 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/renderer_pixeltest.cc ('k') | cc/quads/draw_quad_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 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 SkMatrix content_mat; 513 SkMatrix content_mat;
514 content_mat.setRectToRect(content_rect, dest_rect, 514 content_mat.setRectToRect(content_rect, dest_rect,
515 SkMatrix::kFill_ScaleToFit); 515 SkMatrix::kFill_ScaleToFit);
516 516
517 const SkBitmap* content = lock.sk_bitmap(); 517 const SkBitmap* content = lock.sk_bitmap();
518 518
519 SkBitmap filter_bitmap; 519 SkBitmap filter_bitmap;
520 if (!quad->filters.IsEmpty()) { 520 if (!quad->filters.IsEmpty()) {
521 skia::RefPtr<SkImageFilter> filter = RenderSurfaceFilters::BuildImageFilter( 521 skia::RefPtr<SkImageFilter> filter = RenderSurfaceFilters::BuildImageFilter(
522 quad->filters, content_texture->size()); 522 quad->filters, content_texture->size());
523 // TODO(ajuma): In addition origin translation, the canvas should also be 523 // TODO(ajuma): In addition origin translation, the canvas should also be
danakj 2014/03/07 22:05:03 TODO can go \o/
524 // scaled to accomodate device pixel ratio and pinch zoom. See 524 // scaled to accomodate device pixel ratio and pinch zoom. See
525 // crbug.com/281516 and crbug.com/281518. 525 // crbug.com/281516 and crbug.com/281518.
526 // TODO(ajuma): Apply the filter in the same pass as the content where 526 // TODO(ajuma): Apply the filter in the same pass as the content where
527 // possible (e.g. when there's no origin offset). See crbug.com/308201. 527 // possible (e.g. when there's no origin offset). See crbug.com/308201.
528 if (filter) { 528 if (filter) {
529 SkImageInfo info = SkImageInfo::MakeN32Premul( 529 SkImageInfo info = SkImageInfo::MakeN32Premul(
530 content_texture->size().width(), content_texture->size().height()); 530 content_texture->size().width(), content_texture->size().height());
531 if (filter_bitmap.allocPixels(info)) { 531 if (filter_bitmap.allocPixels(info)) {
532 SkCanvas canvas(filter_bitmap); 532 SkCanvas canvas(filter_bitmap);
533 SkPaint paint; 533 SkPaint paint;
534 paint.setImageFilter(filter.get()); 534 paint.setImageFilter(filter.get());
535 canvas.clear(SK_ColorTRANSPARENT); 535 canvas.clear(SK_ColorTRANSPARENT);
536 canvas.translate(SkIntToScalar(-quad->rect.origin().x()), 536 canvas.translate(SkIntToScalar(-quad->rect.origin().x()),
537 SkIntToScalar(-quad->rect.origin().y())); 537 SkIntToScalar(-quad->rect.origin().y()));
538 canvas.scale(quad->filters_scale.x(), quad->filters_scale.y());
538 canvas.drawSprite(*content, 0, 0, &paint); 539 canvas.drawSprite(*content, 0, 0, &paint);
539 } 540 }
540 } 541 }
541 } 542 }
542 543
543 skia::RefPtr<SkShader> shader; 544 skia::RefPtr<SkShader> shader;
544 if (filter_bitmap.isNull()) { 545 if (filter_bitmap.isNull()) {
545 shader = skia::AdoptRef(SkShader::CreateBitmapShader( 546 shader = skia::AdoptRef(SkShader::CreateBitmapShader(
546 *content, content_tile_mode, content_tile_mode)); 547 *content, content_tile_mode, content_tile_mode));
547 } else { 548 } else {
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 return; 657 return;
657 visible_ = visible; 658 visible_ = visible;
658 659
659 if (visible_) 660 if (visible_)
660 EnsureBackbuffer(); 661 EnsureBackbuffer();
661 else 662 else
662 DiscardBackbuffer(); 663 DiscardBackbuffer();
663 } 664 }
664 665
665 } // namespace cc 666 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/renderer_pixeltest.cc ('k') | cc/quads/draw_quad_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698