OLD | NEW |
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 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 SkMatrix content_mat; | 519 SkMatrix content_mat; |
520 content_mat.setRectToRect(content_rect, dest_rect, | 520 content_mat.setRectToRect(content_rect, dest_rect, |
521 SkMatrix::kFill_ScaleToFit); | 521 SkMatrix::kFill_ScaleToFit); |
522 | 522 |
523 const SkBitmap* content = lock.sk_bitmap(); | 523 const SkBitmap* content = lock.sk_bitmap(); |
524 | 524 |
525 SkBitmap filter_bitmap; | 525 SkBitmap filter_bitmap; |
526 if (!quad->filters.IsEmpty()) { | 526 if (!quad->filters.IsEmpty()) { |
527 skia::RefPtr<SkImageFilter> filter = RenderSurfaceFilters::BuildImageFilter( | 527 skia::RefPtr<SkImageFilter> filter = RenderSurfaceFilters::BuildImageFilter( |
528 quad->filters, content_texture->size()); | 528 quad->filters, content_texture->size()); |
529 // TODO(ajuma): In addition origin translation, the canvas should also be | |
530 // scaled to accomodate device pixel ratio and pinch zoom. See | |
531 // crbug.com/281516 and crbug.com/281518. | |
532 // TODO(ajuma): Apply the filter in the same pass as the content where | 529 // TODO(ajuma): Apply the filter in the same pass as the content where |
533 // possible (e.g. when there's no origin offset). See crbug.com/308201. | 530 // possible (e.g. when there's no origin offset). See crbug.com/308201. |
534 if (filter) { | 531 if (filter) { |
535 SkImageInfo info = SkImageInfo::MakeN32Premul( | 532 SkImageInfo info = SkImageInfo::MakeN32Premul( |
536 content_texture->size().width(), content_texture->size().height()); | 533 content_texture->size().width(), content_texture->size().height()); |
537 if (filter_bitmap.allocPixels(info)) { | 534 if (filter_bitmap.allocPixels(info)) { |
538 SkCanvas canvas(filter_bitmap); | 535 SkCanvas canvas(filter_bitmap); |
539 SkPaint paint; | 536 SkPaint paint; |
540 paint.setImageFilter(filter.get()); | 537 paint.setImageFilter(filter.get()); |
541 canvas.clear(SK_ColorTRANSPARENT); | 538 canvas.clear(SK_ColorTRANSPARENT); |
542 canvas.translate(SkIntToScalar(-quad->rect.origin().x()), | 539 canvas.translate(SkIntToScalar(-quad->rect.origin().x()), |
543 SkIntToScalar(-quad->rect.origin().y())); | 540 SkIntToScalar(-quad->rect.origin().y())); |
| 541 canvas.scale(quad->filters_scale.x(), quad->filters_scale.y()); |
544 canvas.drawSprite(*content, 0, 0, &paint); | 542 canvas.drawSprite(*content, 0, 0, &paint); |
545 } | 543 } |
546 } | 544 } |
547 } | 545 } |
548 | 546 |
549 skia::RefPtr<SkShader> shader; | 547 skia::RefPtr<SkShader> shader; |
550 if (filter_bitmap.isNull()) { | 548 if (filter_bitmap.isNull()) { |
551 shader = skia::AdoptRef(SkShader::CreateBitmapShader( | 549 shader = skia::AdoptRef(SkShader::CreateBitmapShader( |
552 *content, content_tile_mode, content_tile_mode, &content_mat)); | 550 *content, content_tile_mode, content_tile_mode, &content_mat)); |
553 } else { | 551 } else { |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
646 } | 644 } |
647 | 645 |
648 void SoftwareRenderer::DidChangeVisibility() { | 646 void SoftwareRenderer::DidChangeVisibility() { |
649 if (visible()) | 647 if (visible()) |
650 EnsureBackbuffer(); | 648 EnsureBackbuffer(); |
651 else | 649 else |
652 DiscardBackbuffer(); | 650 DiscardBackbuffer(); |
653 } | 651 } |
654 | 652 |
655 } // namespace cc | 653 } // namespace cc |
OLD | NEW |