OLD | NEW |
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 21 matching lines...) Expand all Loading... |
32 #include "SkPoint3.h" | 32 #include "SkPoint3.h" |
33 #include "platform/graphics/filters/DistantLightSource.h" | 33 #include "platform/graphics/filters/DistantLightSource.h" |
34 #include "platform/graphics/filters/PointLightSource.h" | 34 #include "platform/graphics/filters/PointLightSource.h" |
35 #include "platform/graphics/filters/SkiaImageFilterBuilder.h" | 35 #include "platform/graphics/filters/SkiaImageFilterBuilder.h" |
36 #include "platform/graphics/filters/SpotLightSource.h" | 36 #include "platform/graphics/filters/SpotLightSource.h" |
37 | 37 |
38 namespace blink { | 38 namespace blink { |
39 | 39 |
40 FELighting::FELighting(Filter* filter, LightingType lightingType, const Color& l
ightingColor, float surfaceScale, | 40 FELighting::FELighting(Filter* filter, LightingType lightingType, const Color& l
ightingColor, float surfaceScale, |
41 float diffuseConstant, float specularConstant, float specularExponent, | 41 float diffuseConstant, float specularConstant, float specularExponent, |
42 float kernelUnitLengthX, float kernelUnitLengthY, PassRefPtr<LightSource> li
ghtSource) | 42 PassRefPtr<LightSource> lightSource) |
43 : FilterEffect(filter) | 43 : FilterEffect(filter) |
44 , m_lightingType(lightingType) | 44 , m_lightingType(lightingType) |
45 , m_lightSource(lightSource) | 45 , m_lightSource(lightSource) |
46 , m_lightingColor(lightingColor) | 46 , m_lightingColor(lightingColor) |
47 , m_surfaceScale(surfaceScale) | 47 , m_surfaceScale(surfaceScale) |
48 , m_diffuseConstant(std::max(diffuseConstant, 0.0f)) | 48 , m_diffuseConstant(std::max(diffuseConstant, 0.0f)) |
49 , m_specularConstant(std::max(specularConstant, 0.0f)) | 49 , m_specularConstant(std::max(specularConstant, 0.0f)) |
50 , m_specularExponent(std::min(std::max(specularExponent, 1.0f), 128.0f)) | 50 , m_specularExponent(std::min(std::max(specularExponent, 1.0f), 128.0f)) |
51 , m_kernelUnitLengthX(kernelUnitLengthX) | |
52 , m_kernelUnitLengthY(kernelUnitLengthY) | |
53 { | 51 { |
54 } | 52 } |
55 | 53 |
56 FloatRect FELighting::mapPaintRect(const FloatRect& rect, bool) | 54 FloatRect FELighting::mapPaintRect(const FloatRect& rect, bool) |
57 { | 55 { |
58 FloatRect result = rect; | 56 FloatRect result = rect; |
59 // 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. |
60 result.inflate(1); | 58 result.inflate(1); |
61 return result; | 59 return result; |
62 } | 60 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 return adoptRef(SkLightingImageFilter::CreateSpotLitSpecular(locatio
n, target, specularExponent, limitingConeAngle, lightColor.rgb(), m_surfaceScale
, m_specularConstant, m_specularExponent, input.get(), &rect)); | 94 return adoptRef(SkLightingImageFilter::CreateSpotLitSpecular(locatio
n, target, specularExponent, limitingConeAngle, lightColor.rgb(), m_surfaceScale
, m_specularConstant, m_specularExponent, input.get(), &rect)); |
97 return adoptRef(SkLightingImageFilter::CreateSpotLitDiffuse(location, ta
rget, specularExponent, limitingConeAngle, lightColor.rgb(), m_surfaceScale, m_d
iffuseConstant, input.get(), &rect)); | 95 return adoptRef(SkLightingImageFilter::CreateSpotLitDiffuse(location, ta
rget, specularExponent, limitingConeAngle, lightColor.rgb(), m_surfaceScale, m_d
iffuseConstant, input.get(), &rect)); |
98 } | 96 } |
99 default: | 97 default: |
100 ASSERT_NOT_REACHED(); | 98 ASSERT_NOT_REACHED(); |
101 return nullptr; | 99 return nullptr; |
102 } | 100 } |
103 } | 101 } |
104 | 102 |
105 } // namespace blink | 103 } // namespace blink |
OLD | NEW |