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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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) |
| 65 return createTransparentBlack(builder); |
| 66 |
64 SkImageFilter::CropRect rect = getCropRect(builder ? builder->cropOffset() :
FloatSize()); | 67 SkImageFilter::CropRect rect = getCropRect(builder ? builder->cropOffset() :
FloatSize()); |
65 Color lightColor = adaptColorToOperatingColorSpace(m_lightingColor); | 68 Color lightColor = adaptColorToOperatingColorSpace(m_lightingColor); |
66 RefPtr<SkImageFilter> input(builder ? builder->build(inputEffect(0), operati
ngColorSpace()) : nullptr); | 69 RefPtr<SkImageFilter> input(builder ? builder->build(inputEffect(0), operati
ngColorSpace()) : nullptr); |
67 switch (m_lightSource->type()) { | 70 switch (m_lightSource->type()) { |
68 case LS_DISTANT: { | 71 case LS_DISTANT: { |
69 DistantLightSource* distantLightSource = static_cast<DistantLightSource*
>(m_lightSource.get()); | 72 DistantLightSource* distantLightSource = static_cast<DistantLightSource*
>(m_lightSource.get()); |
70 float azimuthRad = deg2rad(distantLightSource->azimuth()); | 73 float azimuthRad = deg2rad(distantLightSource->azimuth()); |
71 float elevationRad = deg2rad(distantLightSource->elevation()); | 74 float elevationRad = deg2rad(distantLightSource->elevation()); |
72 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)); |
73 if (m_specularConstant > 0) | 76 if (m_specularConstant > 0) |
(...skipping 20 matching lines...) Expand all Loading... |
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::CreateSpotLitSpecular(locatio
n, target, specularExponent, limitingConeAngle, lightColor.rgb(), m_surfaceScale
, m_specularConstant, m_specularExponent, input.get(), &rect)); |
95 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)); |
96 } | 99 } |
97 default: | 100 default: |
98 ASSERT_NOT_REACHED(); | 101 ASSERT_NOT_REACHED(); |
99 return nullptr; | 102 return nullptr; |
100 } | 103 } |
101 } | 104 } |
102 | 105 |
103 } // namespace blink | 106 } // namespace blink |
OLD | NEW |