| OLD | NEW |
| 1 // Copyright 2010 The Chromium Authors. All rights reserved. | 1 // Copyright 2010 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/gl_renderer.h" | 5 #include "cc/output/gl_renderer.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 642 skia::RefPtr<SkSurface> surface = skia::AdoptRef(SkSurface::NewRenderTarget( | 642 skia::RefPtr<SkSurface> surface = skia::AdoptRef(SkSurface::NewRenderTarget( |
| 643 use_gr_context->context(), SkBudgeted::kYes, dst_info, 0)); | 643 use_gr_context->context(), SkBudgeted::kYes, dst_info, 0)); |
| 644 if (!surface) { | 644 if (!surface) { |
| 645 TRACE_EVENT_INSTANT0("cc", "ApplyImageFilter surface allocation failed", | 645 TRACE_EVENT_INSTANT0("cc", "ApplyImageFilter surface allocation failed", |
| 646 TRACE_EVENT_SCOPE_THREAD); | 646 TRACE_EVENT_SCOPE_THREAD); |
| 647 return skia::RefPtr<SkImage>(); | 647 return skia::RefPtr<SkImage>(); |
| 648 } | 648 } |
| 649 | 649 |
| 650 SkMatrix local_matrix; | 650 SkMatrix local_matrix; |
| 651 local_matrix.setScale(scale.x(), scale.y()); | 651 local_matrix.setScale(scale.x(), scale.y()); |
| 652 skia::RefPtr<SkImageFilter> filter_with_local_scale = | |
| 653 skia::AdoptRef(filter->newWithLocalMatrix(local_matrix)); | |
| 654 | 652 |
| 655 SkPaint paint; | 653 SkPaint paint; |
| 656 paint.setImageFilter(filter_with_local_scale.get()); | 654 paint.setImageFilter(filter->makeWithLocalMatrix(local_matrix)); |
| 657 surface->getCanvas()->translate(-dst_rect.x(), -dst_rect.y()); | 655 surface->getCanvas()->translate(-dst_rect.x(), -dst_rect.y()); |
| 658 surface->getCanvas()->drawImage(srcImage.get(), src_rect.x(), src_rect.y(), | 656 surface->getCanvas()->drawImage(srcImage.get(), src_rect.x(), src_rect.y(), |
| 659 &paint); | 657 &paint); |
| 660 // Flush the drawing before source texture read lock goes out of scope. | 658 // Flush the drawing before source texture read lock goes out of scope. |
| 661 // Skia API does not guarantee that when the SkImage goes out of scope, | 659 // Skia API does not guarantee that when the SkImage goes out of scope, |
| 662 // its externally referenced resources would force the rendering to be | 660 // its externally referenced resources would force the rendering to be |
| 663 // flushed. | 661 // flushed. |
| 664 surface->getCanvas()->flush(); | 662 surface->getCanvas()->flush(); |
| 665 skia::RefPtr<SkImage> image = skia::AdoptRef(surface->newImageSnapshot()); | 663 skia::RefPtr<SkImage> image = skia::AdoptRef(surface->newImageSnapshot()); |
| 666 if (!image || !image->isTextureBacked()) { | 664 if (!image || !image->isTextureBacked()) { |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 992 // the surface and its replica. Apply filters to the contents texture. | 990 // the surface and its replica. Apply filters to the contents texture. |
| 993 skia::RefPtr<SkImage> filter_image; | 991 skia::RefPtr<SkImage> filter_image; |
| 994 GLuint filter_image_id = 0; | 992 GLuint filter_image_id = 0; |
| 995 SkScalar color_matrix[20]; | 993 SkScalar color_matrix[20]; |
| 996 bool use_color_matrix = false; | 994 bool use_color_matrix = false; |
| 997 gfx::RectF rect = gfx::RectF(quad->rect); | 995 gfx::RectF rect = gfx::RectF(quad->rect); |
| 998 if (!quad->filters.IsEmpty()) { | 996 if (!quad->filters.IsEmpty()) { |
| 999 skia::RefPtr<SkImageFilter> filter = RenderSurfaceFilters::BuildImageFilter( | 997 skia::RefPtr<SkImageFilter> filter = RenderSurfaceFilters::BuildImageFilter( |
| 1000 quad->filters, gfx::SizeF(contents_texture->size())); | 998 quad->filters, gfx::SizeF(contents_texture->size())); |
| 1001 if (filter) { | 999 if (filter) { |
| 1002 skia::RefPtr<SkColorFilter> cf; | 1000 SkColorFilter* colorfilter_rawptr = NULL; |
| 1003 | 1001 filter->asColorFilter(&colorfilter_rawptr); |
| 1004 { | 1002 sk_sp<SkColorFilter> cf(colorfilter_rawptr); |
| 1005 SkColorFilter* colorfilter_rawptr = NULL; | |
| 1006 filter->asColorFilter(&colorfilter_rawptr); | |
| 1007 cf = skia::AdoptRef(colorfilter_rawptr); | |
| 1008 } | |
| 1009 | 1003 |
| 1010 if (cf && cf->asColorMatrix(color_matrix) && !filter->getInput(0)) { | 1004 if (cf && cf->asColorMatrix(color_matrix) && !filter->getInput(0)) { |
| 1011 // We have a single color matrix as a filter; apply it locally | 1005 // We have a single color matrix as a filter; apply it locally |
| 1012 // in the compositor. | 1006 // in the compositor. |
| 1013 use_color_matrix = true; | 1007 use_color_matrix = true; |
| 1014 } else { | 1008 } else { |
| 1015 gfx::Vector2dF scale = quad->filters_scale; | 1009 gfx::Vector2dF scale = quad->filters_scale; |
| 1016 SkMatrix scale_matrix; | 1010 SkMatrix scale_matrix; |
| 1017 scale_matrix.setScale(scale.x(), scale.y()); | 1011 scale_matrix.setScale(scale.x(), scale.y()); |
| 1018 SkIRect result_rect = | 1012 SkIRect result_rect = |
| (...skipping 2580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3599 texture_id = pending_overlay_resources_.back()->texture_id(); | 3593 texture_id = pending_overlay_resources_.back()->texture_id(); |
| 3600 } | 3594 } |
| 3601 | 3595 |
| 3602 context_support_->ScheduleOverlayPlane( | 3596 context_support_->ScheduleOverlayPlane( |
| 3603 overlay.plane_z_order, overlay.transform, texture_id, | 3597 overlay.plane_z_order, overlay.transform, texture_id, |
| 3604 ToNearestRect(overlay.display_rect), overlay.uv_rect); | 3598 ToNearestRect(overlay.display_rect), overlay.uv_rect); |
| 3605 } | 3599 } |
| 3606 } | 3600 } |
| 3607 | 3601 |
| 3608 } // namespace cc | 3602 } // namespace cc |
| OLD | NEW |