| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2016 Google Inc. | 3 * Copyright 2016 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 #include "SampleCode.h" | 8 #include "SampleCode.h" |
| 9 #include "SkBlurMask.h" | 9 #include "SkBlurMask.h" |
| 10 #include "SkBlurMaskFilter.h" | 10 #include "SkBlurMaskFilter.h" |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 pad *= scaleFactors[0]; | 192 pad *= scaleFactors[0]; |
| 193 SkASSERT(radius < 16384); | 193 SkASSERT(radius < 16384); |
| 194 SkASSERT(pad < 64); | 194 SkASSERT(pad < 64); |
| 195 // Convert radius to 14.2 fixed point and place in the R & G components. | 195 // Convert radius to 14.2 fixed point and place in the R & G components. |
| 196 // Convert pad to 6.2 fixed point and place in the B component. | 196 // Convert pad to 6.2 fixed point and place in the B component. |
| 197 uint16_t iRadius = (uint16_t)(radius*4.0f); | 197 uint16_t iRadius = (uint16_t)(radius*4.0f); |
| 198 unsigned char alpha = (unsigned char)(ambientAlpha*255.999f); | 198 unsigned char alpha = (unsigned char)(ambientAlpha*255.999f); |
| 199 paint.setColor(SkColorSetARGB(alpha, iRadius >> 8, iRadius & 0xff, | 199 paint.setColor(SkColorSetARGB(alpha, iRadius >> 8, iRadius & 0xff, |
| 200 (unsigned char)(4.0f*pad))); | 200 (unsigned char)(4.0f*pad))); |
| 201 | 201 |
| 202 paint.setShader(SkGaussianEdgeShader::Make(true)); | 202 paint.setShader(SkGaussianEdgeShader::Make()); |
| 203 canvas->drawRRect(pathRRect, paint); | 203 canvas->drawRRect(pathRRect, paint); |
| 204 } | 204 } |
| 205 | 205 |
| 206 void drawSpotShadow(SkCanvas* canvas, const SkPath& path, SkScalar zValue, | 206 void drawSpotShadow(SkCanvas* canvas, const SkPath& path, SkScalar zValue, |
| 207 SkPoint3 lightPos, SkScalar lightWidth, SkScalar spotAlp
ha) { | 207 SkPoint3 lightPos, SkScalar lightWidth, SkScalar spotAlp
ha) { |
| 208 if (spotAlpha <= 0) { | 208 if (spotAlpha <= 0) { |
| 209 return; | 209 return; |
| 210 } | 210 } |
| 211 | 211 |
| 212 SkScalar zRatio = zValue / (lightPos.fZ - zValue); | 212 SkScalar zRatio = zValue / (lightPos.fZ - zValue); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 // If the area of the stroked geometry is larger than the fill geometry,
or | 313 // If the area of the stroked geometry is larger than the fill geometry,
or |
| 314 // if our pad is too big to convert to 6.2 fixed point, just fill it. | 314 // if our pad is too big to convert to 6.2 fixed point, just fill it. |
| 315 if (strokedArea > filledArea || pad >= 64) { | 315 if (strokedArea > filledArea || pad >= 64) { |
| 316 pad = 0; | 316 pad = 0; |
| 317 paint.setStyle(SkPaint::kStrokeAndFill_Style); | 317 paint.setStyle(SkPaint::kStrokeAndFill_Style); |
| 318 paint.setStrokeWidth(radius); | 318 paint.setStrokeWidth(radius); |
| 319 } else { | 319 } else { |
| 320 paint.setStyle(SkPaint::kStroke_Style); | 320 paint.setStyle(SkPaint::kStroke_Style); |
| 321 paint.setStrokeWidth(strokeWidth); | 321 paint.setStrokeWidth(strokeWidth); |
| 322 } | 322 } |
| 323 paint.setShader(SkGaussianEdgeShader::Make(true)); | 323 paint.setShader(SkGaussianEdgeShader::Make()); |
| 324 // handle scale of radius due to CTM | 324 // handle scale of radius due to CTM |
| 325 radius *= scaleFactors[0]; | 325 radius *= scaleFactors[0]; |
| 326 // don't need to scale pad as it was computed from the transformed offse
t | 326 // don't need to scale pad as it was computed from the transformed offse
t |
| 327 SkASSERT(radius < 16384); | 327 SkASSERT(radius < 16384); |
| 328 SkASSERT(pad < 64); | 328 SkASSERT(pad < 64); |
| 329 // Convert radius to 14.2 fixed point and place in the R & G components. | 329 // Convert radius to 14.2 fixed point and place in the R & G components. |
| 330 // Convert pad to 6.2 fixed point and place in the B component. | 330 // Convert pad to 6.2 fixed point and place in the B component. |
| 331 uint16_t iRadius = (uint16_t)(radius*4.0f); | 331 uint16_t iRadius = (uint16_t)(radius*4.0f); |
| 332 unsigned char alpha = (unsigned char)(spotAlpha*255.999f); | 332 unsigned char alpha = (unsigned char)(spotAlpha*255.999f); |
| 333 paint.setColor(SkColorSetARGB(alpha, iRadius >> 8, iRadius & 0xff, | 333 paint.setColor(SkColorSetARGB(alpha, iRadius >> 8, iRadius & 0xff, |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 } | 420 } |
| 421 | 421 |
| 422 private: | 422 private: |
| 423 typedef SkView INHERITED; | 423 typedef SkView INHERITED; |
| 424 }; | 424 }; |
| 425 | 425 |
| 426 ////////////////////////////////////////////////////////////////////////////// | 426 ////////////////////////////////////////////////////////////////////////////// |
| 427 | 427 |
| 428 static SkView* MyFactory() { return new ShadowsView; } | 428 static SkView* MyFactory() { return new ShadowsView; } |
| 429 static SkViewRegister reg(MyFactory); | 429 static SkViewRegister reg(MyFactory); |
| OLD | NEW |