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

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

Issue 21154002: Add support for converting cc::FilterOperations into an SkImageFilter (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix nit Created 7 years, 3 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
OLDNEW
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 759 matching lines...) Expand 10 before | Expand all | Expand 10 after
770 770
771 if (disable_blending) 771 if (disable_blending)
772 SetBlendEnabled(true); 772 SetBlendEnabled(true);
773 } 773 }
774 774
775 // TODO(senorblanco): Cache this value so that we don't have to do it for both 775 // TODO(senorblanco): Cache this value so that we don't have to do it for both
776 // the surface and its replica. Apply filters to the contents texture. 776 // the surface and its replica. Apply filters to the contents texture.
777 SkBitmap filter_bitmap; 777 SkBitmap filter_bitmap;
778 SkScalar color_matrix[20]; 778 SkScalar color_matrix[20];
779 bool use_color_matrix = false; 779 bool use_color_matrix = false;
780 if (quad->filter) { 780 // TODO(ajuma): Always use RenderSurfaceFilters::BuildImageFilter, not just
781 skia::RefPtr<SkColorFilter> cf; 781 // when we have a reference filter.
782 if (quad->filters.HasReferenceFilter()) {
783 skia::RefPtr<SkImageFilter> filter = RenderSurfaceFilters::BuildImageFilter(
784 quad->filters, contents_texture->size());
785 if (filter) {
786 skia::RefPtr<SkColorFilter> cf;
782 787
783 { 788 {
enne (OOO) 2013/09/11 17:57:24 style nit: this is a seemingly unnecessary block.
danakj 2013/09/11 18:02:46 This is to keep the raw pointer scoped and ensure
784 SkColorFilter* colorfilter_rawptr = NULL; 789 SkColorFilter* colorfilter_rawptr = NULL;
785 quad->filter->asColorFilter(&colorfilter_rawptr); 790 filter->asColorFilter(&colorfilter_rawptr);
786 cf = skia::AdoptRef(colorfilter_rawptr); 791 cf = skia::AdoptRef(colorfilter_rawptr);
787 } 792 }
788 793
789 if (cf && cf->asColorMatrix(color_matrix) && !quad->filter->getInput(0)) { 794 if (cf && cf->asColorMatrix(color_matrix) && !filter->getInput(0)) {
790 // We have a single color matrix as a filter; apply it locally 795 // We have a single color matrix as a filter; apply it locally
791 // in the compositor. 796 // in the compositor.
792 use_color_matrix = true; 797 use_color_matrix = true;
793 } else { 798 } else {
794 filter_bitmap = ApplyImageFilter(this, 799 filter_bitmap = ApplyImageFilter(this,
795 frame->offscreen_context_provider, 800 frame->offscreen_context_provider,
796 quad->rect.origin(), 801 quad->rect.origin(),
797 quad->filter.get(), 802 filter.get(),
798 contents_texture); 803 contents_texture);
804 }
799 } 805 }
800 } else if (!quad->filters.IsEmpty()) { 806 } else if (!quad->filters.IsEmpty()) {
801 FilterOperations optimized_filters = 807 FilterOperations optimized_filters =
802 RenderSurfaceFilters::Optimize(quad->filters); 808 RenderSurfaceFilters::Optimize(quad->filters);
803 809
804 if ((optimized_filters.size() == 1) && 810 if ((optimized_filters.size() == 1) &&
805 (optimized_filters.at(0).type() == FilterOperation::COLOR_MATRIX)) { 811 (optimized_filters.at(0).type() == FilterOperation::COLOR_MATRIX)) {
806 memcpy( 812 memcpy(
807 color_matrix, optimized_filters.at(0).matrix(), sizeof(color_matrix)); 813 color_matrix, optimized_filters.at(0).matrix(), sizeof(color_matrix));
808 use_color_matrix = true; 814 use_color_matrix = true;
(...skipping 2331 matching lines...) Expand 10 before | Expand all | Expand 10 after
3140 return; 3146 return;
3141 offscreen_context_labelled_ = true; 3147 offscreen_context_labelled_ = true;
3142 std::string unique_context_name = base::StringPrintf( 3148 std::string unique_context_name = base::StringPrintf(
3143 "%s-Offscreen-%p", settings_->compositor_name.c_str(), context_); 3149 "%s-Offscreen-%p", settings_->compositor_name.c_str(), context_);
3144 offscreen_context_provider->Context3d() 3150 offscreen_context_provider->Context3d()
3145 ->pushGroupMarkerEXT(unique_context_name.c_str()); 3151 ->pushGroupMarkerEXT(unique_context_name.c_str());
3146 } 3152 }
3147 3153
3148 3154
3149 } // namespace cc 3155 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698