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

Unified Diff: src/utils/SkShadowPaintFilterCanvas.cpp

Issue 2224163005: Made shadows blurry (thru implementing variance mapping) (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: made req changes Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: src/utils/SkShadowPaintFilterCanvas.cpp
diff --git a/src/utils/SkShadowPaintFilterCanvas.cpp b/src/utils/SkShadowPaintFilterCanvas.cpp
index 31b7661296151023a8266cf67d5d74468b181dc5..3c1f712a848e3f556a283b91cb4ed8b83b8353dc 100644
--- a/src/utils/SkShadowPaintFilterCanvas.cpp
+++ b/src/utils/SkShadowPaintFilterCanvas.cpp
@@ -11,7 +11,12 @@
#ifdef SK_EXPERIMENTAL_SHADOWING
SkShadowPaintFilterCanvas::SkShadowPaintFilterCanvas(SkCanvas *canvas)
- : SkPaintFilterCanvas(canvas) { }
+ : SkPaintFilterCanvas(canvas) {
+ fShType.fShadowRadius = 0.0f;
+ fShType.fBlurAlgorithm = SkShadowType::kNoBlur_BlurAlgorithm;
+ fShType.fBiasingConstant = 0.0f;
+ fShType.fMinVariance = 0.0f;
+}
// TODO use a shader instead
bool SkShadowPaintFilterCanvas::onFilter(SkTCopyOnFirstWrite<SkPaint>* paint, Type type) const {
@@ -24,6 +29,15 @@ bool SkShadowPaintFilterCanvas::onFilter(SkTCopyOnFirstWrite<SkPaint>* paint, Ty
SkColor color = 0xFF000000; // init color to opaque black
color |= z; // Put the index into the blue component
+
+ if (fShType.fBlurAlgorithm == SkShadowType::kVariance_BlurAlgorithm) {
+ int z2 = z * z;
+ if (z2 > 255 * 256) {
+ color |= (255) << 8;
+ } else {
+ color |= (z2 / 256) << 8;
jvanverth1 2016/08/12 17:39:09 I think (z2/256) << 8 is the same as (z2 & ~0xff).
vjiaoblack 2016/08/12 19:07:42 Done.
+ }
+ }
newPaint.setColor(color);
*paint->writable() = newPaint;
@@ -42,6 +56,9 @@ SkISize SkShadowPaintFilterCanvas::ComputeDepthMapSize(const SkLights::Light& li
return SkISize::Make(dMapWidth, dMapHeight);
}
+void SkShadowPaintFilterCanvas::setShadowType(SkShadowType sType) {
+ fShType = sType;
+}
void SkShadowPaintFilterCanvas::onDrawPicture(const SkPicture *picture, const SkMatrix *matrix,
const SkPaint *paint) {

Powered by Google App Engine
This is Rietveld 408576698