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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 , m_lightingType(lightingType) | 43 , m_lightingType(lightingType) |
44 , m_lightSource(lightSource) | 44 , m_lightSource(lightSource) |
45 , m_lightingColor(lightingColor) | 45 , m_lightingColor(lightingColor) |
46 , m_surfaceScale(surfaceScale) | 46 , m_surfaceScale(surfaceScale) |
47 , m_diffuseConstant(std::max(diffuseConstant, 0.0f)) | 47 , m_diffuseConstant(std::max(diffuseConstant, 0.0f)) |
48 , m_specularConstant(std::max(specularConstant, 0.0f)) | 48 , m_specularConstant(std::max(specularConstant, 0.0f)) |
49 , m_specularExponent(clampTo(specularExponent, 1.0f, 128.0f)) | 49 , m_specularExponent(clampTo(specularExponent, 1.0f, 128.0f)) |
50 { | 50 { |
51 } | 51 } |
52 | 52 |
53 FloatRect FELighting::mapPaintRect(const FloatRect& rect, bool) const | |
54 { | |
55 FloatRect result = rect; | |
56 // The areas affected need to be a pixel bigger to accommodate the Sobel ker
nel. | |
57 result.inflate(1); | |
58 return result; | |
59 } | |
60 | |
61 sk_sp<SkImageFilter> FELighting::createImageFilter() | 53 sk_sp<SkImageFilter> FELighting::createImageFilter() |
62 { | 54 { |
63 if (!m_lightSource) | 55 if (!m_lightSource) |
64 return createTransparentBlack(); | 56 return createTransparentBlack(); |
65 | 57 |
66 SkImageFilter::CropRect rect = getCropRect(); | 58 SkImageFilter::CropRect rect = getCropRect(); |
67 Color lightColor = adaptColorToOperatingColorSpace(m_lightingColor); | 59 Color lightColor = adaptColorToOperatingColorSpace(m_lightingColor); |
68 sk_sp<SkImageFilter> input(SkiaImageFilterBuilder::build(inputEffect(0), ope
ratingColorSpace())); | 60 sk_sp<SkImageFilter> input(SkiaImageFilterBuilder::build(inputEffect(0), ope
ratingColorSpace())); |
69 switch (m_lightSource->type()) { | 61 switch (m_lightSource->type()) { |
70 case LS_DISTANT: { | 62 case LS_DISTANT: { |
(...skipping 25 matching lines...) Expand all Loading... |
96 return SkLightingImageFilter::MakeSpotLitSpecular(location, target,
specularExponent, limitingConeAngle, lightColor.rgb(), m_surfaceScale, m_specula
rConstant, m_specularExponent, std::move(input), &rect); | 88 return SkLightingImageFilter::MakeSpotLitSpecular(location, target,
specularExponent, limitingConeAngle, lightColor.rgb(), m_surfaceScale, m_specula
rConstant, m_specularExponent, std::move(input), &rect); |
97 return SkLightingImageFilter::MakeSpotLitDiffuse(location, target, specu
larExponent, limitingConeAngle, lightColor.rgb(), m_surfaceScale, m_diffuseConst
ant, std::move(input), &rect); | 89 return SkLightingImageFilter::MakeSpotLitDiffuse(location, target, specu
larExponent, limitingConeAngle, lightColor.rgb(), m_surfaceScale, m_diffuseConst
ant, std::move(input), &rect); |
98 } | 90 } |
99 default: | 91 default: |
100 ASSERT_NOT_REACHED(); | 92 ASSERT_NOT_REACHED(); |
101 return nullptr; | 93 return nullptr; |
102 } | 94 } |
103 } | 95 } |
104 | 96 |
105 } // namespace blink | 97 } // namespace blink |
OLD | NEW |