1 // Copyright 2013 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "webkit/renderer/compositor_bindings/web_filter_operations_impl.h" 6 7 #include "base/basictypes.h" 8 #include "skia/ext/refptr.h" 9 #include "third_party/WebKit/public/platform/WebColor.h" 10 #include "third_party/WebKit/public/platform/WebPoint.h" 11 #include "third_party/skia/include/core/SkScalar.h" 12 13 namespace webkit { 14 WebFilterOperationsImpl()15WebFilterOperationsImpl::WebFilterOperationsImpl() {} 16 ~WebFilterOperationsImpl()17WebFilterOperationsImpl::~WebFilterOperationsImpl() {} 18 AsFilterOperations() const19const cc::FilterOperations& WebFilterOperationsImpl::AsFilterOperations() 20 const { 21 return filter_operations_; 22 } 23 appendGrayscaleFilter(float amount)24void WebFilterOperationsImpl::appendGrayscaleFilter(float amount) { 25 filter_operations_.Append(cc::FilterOperation::CreateGrayscaleFilter(amount)); 26 } 27 appendSepiaFilter(float amount)28void WebFilterOperationsImpl::appendSepiaFilter(float amount) { 29 filter_operations_.Append(cc::FilterOperation::CreateSepiaFilter(amount)); 30 } 31 appendSaturateFilter(float amount)32void WebFilterOperationsImpl::appendSaturateFilter(float amount) { 33 filter_operations_.Append(cc::FilterOperation::CreateSaturateFilter(amount)); 34 } 35 appendHueRotateFilter(float amount)36void WebFilterOperationsImpl::appendHueRotateFilter(float amount) { 37 filter_operations_.Append(cc::FilterOperation::CreateHueRotateFilter(amount)); 38 } 39 appendInvertFilter(float amount)40void WebFilterOperationsImpl::appendInvertFilter(float amount) { 41 filter_operations_.Append(cc::FilterOperation::CreateInvertFilter(amount)); 42 } 43 appendBrightnessFilter(float amount)44void WebFilterOperationsImpl::appendBrightnessFilter(float amount) { 45 filter_operations_.Append( 46 cc::FilterOperation::CreateBrightnessFilter(amount)); 47 } 48 appendContrastFilter(float amount)49void WebFilterOperationsImpl::appendContrastFilter(float amount) { 50 filter_operations_.Append(cc::FilterOperation::CreateContrastFilter(amount)); 51 } 52 appendOpacityFilter(float amount)53void WebFilterOperationsImpl::appendOpacityFilter(float amount) { 54 filter_operations_.Append(cc::FilterOperation::CreateOpacityFilter(amount)); 55 } 56 appendBlurFilter(float amount)57void WebFilterOperationsImpl::appendBlurFilter(float amount) { 58 filter_operations_.Append(cc::FilterOperation::CreateBlurFilter(amount)); 59 } 60 appendDropShadowFilter(blink::WebPoint offset,float std_deviation,blink::WebColor color)61void WebFilterOperationsImpl::appendDropShadowFilter(blink::WebPoint offset, 62 float std_deviation, 63 blink::WebColor color) { 64 filter_operations_.Append(cc::FilterOperation::CreateDropShadowFilter( 65 offset, std_deviation, color)); 66 } 67 appendColorMatrixFilter(SkScalar matrix[20])68void WebFilterOperationsImpl::appendColorMatrixFilter(SkScalar matrix[20]) { 69 filter_operations_.Append( 70 cc::FilterOperation::CreateColorMatrixFilter(matrix)); 71 } 72 appendZoomFilter(float amount,int inset)73void WebFilterOperationsImpl::appendZoomFilter(float amount, int inset) { 74 filter_operations_.Append( 75 cc::FilterOperation::CreateZoomFilter(amount, inset)); 76 } 77 appendSaturatingBrightnessFilter(float amount)78void WebFilterOperationsImpl::appendSaturatingBrightnessFilter(float amount) { 79 filter_operations_.Append( 80 cc::FilterOperation::CreateSaturatingBrightnessFilter(amount)); 81 } 82 appendReferenceFilter(SkImageFilter * image_filter)83void WebFilterOperationsImpl::appendReferenceFilter( 84 SkImageFilter* image_filter) { 85 filter_operations_.Append( 86 cc::FilterOperation::CreateReferenceFilter(skia::SharePtr(image_filter))); 87 } 88 clear()89void WebFilterOperationsImpl::clear() { 90 filter_operations_.Clear(); 91 } 92 93 } // namespace webkit 94