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

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: Trying different include path 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
« no previous file with comments | « src/utils/SkShadowPaintFilterCanvas.h ('k') | tools/debugger/SkDebugCanvas.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/utils/SkShadowPaintFilterCanvas.cpp
diff --git a/src/utils/SkShadowPaintFilterCanvas.cpp b/src/utils/SkShadowPaintFilterCanvas.cpp
index f59facb17c8c949c8099a582c22ae23debdbbaef..2a090b78e2a2c097c41ee34d21f2e93831c7689c 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) {
+ fShadowParams.fShadowRadius = 0.0f;
+ fShadowParams.fType = SkShadowParams::kNoBlur_ShadowType;
+ fShadowParams.fBiasingConstant = 0.0f;
+ fShadowParams.fMinVariance = 0.0f;
+}
// TODO use a shader instead
bool SkShadowPaintFilterCanvas::onFilter(SkTCopyOnFirstWrite<SkPaint>* paint, Type type) const {
@@ -24,6 +29,17 @@ 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 (fShadowParams.fType == SkShadowParams::kVariance_ShadowType) {
+ int z2 = z * z;
+ if (z2 > 255 * 256) {
+ color |= 0xff00;
+ } else {
+ // Let's only store the more significant bits of z2 to save space.
+ // In practice, this should barely impact shadow blur quality.
+ color |= z2 & 0x0000ff00;
+ }
+ }
newPaint.setColor(color);
*paint->writable() = newPaint;
@@ -42,6 +58,9 @@ SkISize SkShadowPaintFilterCanvas::ComputeDepthMapSize(const SkLights::Light& li
return SkISize::Make(dMapWidth, dMapHeight);
}
+void SkShadowPaintFilterCanvas::setShadowParams(const SkShadowParams &params) {
+ fShadowParams = params;
+}
void SkShadowPaintFilterCanvas::onDrawPicture(const SkPicture *picture, const SkMatrix *matrix,
const SkPaint *paint) {
« no previous file with comments | « src/utils/SkShadowPaintFilterCanvas.h ('k') | tools/debugger/SkDebugCanvas.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698