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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/filters/FELighting.cpp

Issue 1387573003: Pass SkiaImageFilterBuilder& to FilterEffect::createImageFilter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 University of Szeged 2 * Copyright (C) 2010 University of Szeged
3 * Copyright (C) 2010 Zoltan Herczeg 3 * Copyright (C) 2010 Zoltan Herczeg
4 * Copyright (C) 2013 Google Inc. All rights reserved. 4 * Copyright (C) 2013 Google Inc. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 } 52 }
53 53
54 FloatRect FELighting::mapPaintRect(const FloatRect& rect, bool) 54 FloatRect FELighting::mapPaintRect(const FloatRect& rect, bool)
55 { 55 {
56 FloatRect result = rect; 56 FloatRect result = rect;
57 // The areas affected need to be a pixel bigger to accommodate the Sobel ker nel. 57 // The areas affected need to be a pixel bigger to accommodate the Sobel ker nel.
58 result.inflate(1); 58 result.inflate(1);
59 return result; 59 return result;
60 } 60 }
61 61
62 PassRefPtr<SkImageFilter> FELighting::createImageFilter(SkiaImageFilterBuilder* builder) 62 PassRefPtr<SkImageFilter> FELighting::createImageFilter(SkiaImageFilterBuilder& builder)
63 { 63 {
64 if (!m_lightSource) 64 if (!m_lightSource)
65 return createTransparentBlack(builder); 65 return createTransparentBlack(builder);
66 66
67 SkImageFilter::CropRect rect = getCropRect(builder ? builder->cropOffset() : FloatSize()); 67 SkImageFilter::CropRect rect = getCropRect(builder.cropOffset());
68 Color lightColor = adaptColorToOperatingColorSpace(m_lightingColor); 68 Color lightColor = adaptColorToOperatingColorSpace(m_lightingColor);
69 RefPtr<SkImageFilter> input(builder ? builder->build(inputEffect(0), operati ngColorSpace()) : nullptr); 69 RefPtr<SkImageFilter> input(builder.build(inputEffect(0), operatingColorSpac e()));
70 switch (m_lightSource->type()) { 70 switch (m_lightSource->type()) {
71 case LS_DISTANT: { 71 case LS_DISTANT: {
72 DistantLightSource* distantLightSource = static_cast<DistantLightSource* >(m_lightSource.get()); 72 DistantLightSource* distantLightSource = static_cast<DistantLightSource* >(m_lightSource.get());
73 float azimuthRad = deg2rad(distantLightSource->azimuth()); 73 float azimuthRad = deg2rad(distantLightSource->azimuth());
74 float elevationRad = deg2rad(distantLightSource->elevation()); 74 float elevationRad = deg2rad(distantLightSource->elevation());
75 const SkPoint3 direction = SkPoint3::Make(cosf(azimuthRad) * cosf(elevat ionRad), sinf(azimuthRad) * cosf(elevationRad), sinf(elevationRad)); 75 const SkPoint3 direction = SkPoint3::Make(cosf(azimuthRad) * cosf(elevat ionRad), sinf(azimuthRad) * cosf(elevationRad), sinf(elevationRad));
76 if (m_specularConstant > 0) 76 if (m_specularConstant > 0)
77 return adoptRef(SkLightingImageFilter::CreateDistantLitSpecular(dire ction, lightColor.rgb(), m_surfaceScale, m_specularConstant, m_specularExponent, input.get(), &rect)); 77 return adoptRef(SkLightingImageFilter::CreateDistantLitSpecular(dire ction, lightColor.rgb(), m_surfaceScale, m_specularConstant, m_specularExponent, input.get(), &rect));
78 return adoptRef(SkLightingImageFilter::CreateDistantLitDiffuse(direction , lightColor.rgb(), m_surfaceScale, m_diffuseConstant, input.get(), &rect)); 78 return adoptRef(SkLightingImageFilter::CreateDistantLitDiffuse(direction , lightColor.rgb(), m_surfaceScale, m_diffuseConstant, input.get(), &rect));
79 } 79 }
(...skipping 17 matching lines...) Expand all
97 return adoptRef(SkLightingImageFilter::CreateSpotLitSpecular(locatio n, target, specularExponent, limitingConeAngle, lightColor.rgb(), m_surfaceScale , m_specularConstant, m_specularExponent, input.get(), &rect)); 97 return adoptRef(SkLightingImageFilter::CreateSpotLitSpecular(locatio n, target, specularExponent, limitingConeAngle, lightColor.rgb(), m_surfaceScale , m_specularConstant, m_specularExponent, input.get(), &rect));
98 return adoptRef(SkLightingImageFilter::CreateSpotLitDiffuse(location, ta rget, specularExponent, limitingConeAngle, lightColor.rgb(), m_surfaceScale, m_d iffuseConstant, input.get(), &rect)); 98 return adoptRef(SkLightingImageFilter::CreateSpotLitDiffuse(location, ta rget, specularExponent, limitingConeAngle, lightColor.rgb(), m_surfaceScale, m_d iffuseConstant, input.get(), &rect));
99 } 99 }
100 default: 100 default:
101 ASSERT_NOT_REACHED(); 101 ASSERT_NOT_REACHED();
102 return nullptr; 102 return nullptr;
103 } 103 }
104 } 104 }
105 105
106 } // namespace blink 106 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698