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 <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
765 | 765 |
766 if (disable_blending) | 766 if (disable_blending) |
767 SetBlendEnabled(true); | 767 SetBlendEnabled(true); |
768 } | 768 } |
769 | 769 |
770 // TODO(senorblanco): Cache this value so that we don't have to do it for both | 770 // TODO(senorblanco): Cache this value so that we don't have to do it for both |
771 // the surface and its replica. Apply filters to the contents texture. | 771 // the surface and its replica. Apply filters to the contents texture. |
772 SkBitmap filter_bitmap; | 772 SkBitmap filter_bitmap; |
773 SkScalar color_matrix[20]; | 773 SkScalar color_matrix[20]; |
774 bool use_color_matrix = false; | 774 bool use_color_matrix = false; |
775 if (quad->filter) { | 775 // TODO(ajuma): Always use RenderSurfaceFilters::BuildImageFilter, not just |
776 skia::RefPtr<SkColorFilter> cf; | 776 // when we have a reference filter. |
| 777 if (quad->filters.HasReferenceFilter()) { |
| 778 skia::RefPtr<SkImageFilter> filter = RenderSurfaceFilters::BuildImageFilter( |
| 779 quad->filters, contents_texture->size()); |
| 780 if (filter) { |
| 781 skia::RefPtr<SkColorFilter> cf; |
777 | 782 |
778 { | 783 { |
779 SkColorFilter* colorfilter_rawptr = NULL; | 784 SkColorFilter* colorfilter_rawptr = NULL; |
780 quad->filter->asColorFilter(&colorfilter_rawptr); | 785 filter->asColorFilter(&colorfilter_rawptr); |
781 cf = skia::AdoptRef(colorfilter_rawptr); | 786 cf = skia::AdoptRef(colorfilter_rawptr); |
782 } | 787 } |
783 | 788 |
784 if (cf && cf->asColorMatrix(color_matrix) && !quad->filter->getInput(0)) { | 789 if (cf && cf->asColorMatrix(color_matrix) && !filter->getInput(0)) { |
785 // We have a single color matrix as a filter; apply it locally | 790 // We have a single color matrix as a filter; apply it locally |
786 // in the compositor. | 791 // in the compositor. |
787 use_color_matrix = true; | 792 use_color_matrix = true; |
788 } else { | 793 } else { |
789 filter_bitmap = ApplyImageFilter(this, | 794 filter_bitmap = ApplyImageFilter(this, |
790 frame->offscreen_context_provider, | 795 frame->offscreen_context_provider, |
791 quad->rect.origin(), | 796 quad->rect.origin(), |
792 quad->filter.get(), | 797 filter.get(), |
793 contents_texture); | 798 contents_texture); |
| 799 } |
794 } | 800 } |
795 } else if (!quad->filters.IsEmpty()) { | 801 } else if (!quad->filters.IsEmpty()) { |
796 FilterOperations optimized_filters = | 802 FilterOperations optimized_filters = |
797 RenderSurfaceFilters::Optimize(quad->filters); | 803 RenderSurfaceFilters::Optimize(quad->filters); |
798 | 804 |
799 if ((optimized_filters.size() == 1) && | 805 if ((optimized_filters.size() == 1) && |
800 (optimized_filters.at(0).type() == FilterOperation::COLOR_MATRIX)) { | 806 (optimized_filters.at(0).type() == FilterOperation::COLOR_MATRIX)) { |
801 memcpy( | 807 memcpy( |
802 color_matrix, optimized_filters.at(0).matrix(), sizeof(color_matrix)); | 808 color_matrix, optimized_filters.at(0).matrix(), sizeof(color_matrix)); |
803 use_color_matrix = true; | 809 use_color_matrix = true; |
(...skipping 2328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3132 // The Skia GPU backend requires a stencil buffer. See ReinitializeGrCanvas | 3138 // The Skia GPU backend requires a stencil buffer. See ReinitializeGrCanvas |
3133 // implementation. | 3139 // implementation. |
3134 return gr_context_ && context_->getContextAttributes().stencil; | 3140 return gr_context_ && context_->getContextAttributes().stencil; |
3135 } | 3141 } |
3136 | 3142 |
3137 bool GLRenderer::IsContextLost() { | 3143 bool GLRenderer::IsContextLost() { |
3138 return (context_->getGraphicsResetStatusARB() != GL_NO_ERROR); | 3144 return (context_->getGraphicsResetStatusARB() != GL_NO_ERROR); |
3139 } | 3145 } |
3140 | 3146 |
3141 } // namespace cc | 3147 } // namespace cc |
OLD | NEW |