diff --git a/src/libs/icon/IconRenderer.cpp b/src/libs/icon/IconRenderer.cpp index 88fb317159..819297e8ab 100644 --- a/src/libs/icon/IconRenderer.cpp +++ b/src/libs/icon/IconRenderer.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2006, Haiku. + * Copyright 2006-2007, Haiku. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -100,7 +100,7 @@ StyleHandler::color(unsigned styleIndex) { StyleItem* styleItem = (StyleItem*)fStyles.ItemAt(styleIndex); if (!styleItem) { - printf("no style at index: %d!\n", styleIndex); + printf("no style at index: %u!\n", styleIndex); return fTransparent; } @@ -120,7 +120,7 @@ StyleHandler::generate_span(agg::rgba8* span, int x, int y, { StyleItem* styleItem = (StyleItem*)fStyles.ItemAt(styleIndex); if (!styleItem || !styleItem->style->Gradient()) { - printf("no style/gradient at index: %d!\n", styleIndex); + printf("no style/gradient at index: %u!\n", styleIndex); // TODO: memset() span? return; } @@ -397,6 +397,7 @@ IconRenderer::_Render(const BRect& r) styleIndex++; // global scale + shape->SetGlobalScale(max_c(1.0, transform.scale())); ScaledPath scaledPath(shape->VertexSource(), transform); if (shape->Hinting()) { // additional hinting diff --git a/src/libs/icon/shape/Shape.cpp b/src/libs/icon/shape/Shape.cpp index 3960de6ca3..90e2a5ca83 100644 --- a/src/libs/icon/shape/Shape.cpp +++ b/src/libs/icon/shape/Shape.cpp @@ -482,6 +482,13 @@ Shape::VertexSource() return *source; } +// SetGlobalScale +void +Shape::SetGlobalScale(double scale) +{ + fPathSource.SetGlobalScale(scale); +} + // AddTransformer bool Shape::AddTransformer(Transformer* transformer) diff --git a/src/libs/icon/shape/Shape.h b/src/libs/icon/shape/Shape.h index 66e11c4377..e0d6ec4dac 100644 --- a/src/libs/icon/shape/Shape.h +++ b/src/libs/icon/shape/Shape.h @@ -105,6 +105,7 @@ class Shape : public BPrivate::Icon::Transformable { BRect Bounds(bool updateLast = false) const; ::VertexSource& VertexSource(); + void SetGlobalScale(double scale); bool AddTransformer(Transformer* transformer); bool AddTransformer(Transformer* transformer, diff --git a/src/libs/icon/transformer/AffineTransformer.cpp b/src/libs/icon/transformer/AffineTransformer.cpp index 9338d69e39..6277239c25 100644 --- a/src/libs/icon/transformer/AffineTransformer.cpp +++ b/src/libs/icon/transformer/AffineTransformer.cpp @@ -93,7 +93,7 @@ AffineTransformer::SetSource(VertexSource& source) double AffineTransformer::ApproximationScale() const { - return fSource.ApproximationScale() * scale(); + return fabs(fSource.ApproximationScale() * scale()); } // #pragma mark - diff --git a/src/libs/icon/transformer/ContourTransformer.cpp b/src/libs/icon/transformer/ContourTransformer.cpp index e5798c77b4..b88870cc3d 100644 --- a/src/libs/icon/transformer/ContourTransformer.cpp +++ b/src/libs/icon/transformer/ContourTransformer.cpp @@ -111,7 +111,11 @@ ContourTransformer::SetSource(VertexSource& source) double ContourTransformer::ApproximationScale() const { - return fSource.ApproximationScale() * width(); + double scale = fSource.ApproximationScale(); + double factor = fabs(width()); + if (factor > 1.0) + scale *= factor; + return scale; } // #pragma mark - diff --git a/src/libs/icon/transformer/PathSource.cpp b/src/libs/icon/transformer/PathSource.cpp index 7422995eb8..174bfb56ec 100644 --- a/src/libs/icon/transformer/PathSource.cpp +++ b/src/libs/icon/transformer/PathSource.cpp @@ -13,10 +13,13 @@ // constructor PathSource::PathSource(PathContainer* paths) - : VertexSource(), - fPaths(paths), - fAGGPath(), - fAGGCurvedPath(fAGGPath) + : VertexSource() + , fPaths(paths) + , fAGGPath() + , fAGGCurvedPath(fAGGPath) + + , fGlobalScale(1.0) + , fLastTransformerScale(1.0) { } @@ -68,6 +71,15 @@ PathSource::Update(bool leavePathsOpen, double approximationScale) fAGGPath.close_polygon(); } - fAGGCurvedPath.approximation_scale(approximationScale); + fLastTransformerScale = approximationScale; + fAGGCurvedPath.approximation_scale(fLastTransformerScale * fGlobalScale); +} + +// SetGlobalScale +void +PathSource::SetGlobalScale(double scale) +{ + fGlobalScale = scale; + fAGGCurvedPath.approximation_scale(fLastTransformerScale * fGlobalScale); } diff --git a/src/libs/icon/transformer/PathSource.h b/src/libs/icon/transformer/PathSource.h index 10046738e8..3de12de895 100644 --- a/src/libs/icon/transformer/PathSource.h +++ b/src/libs/icon/transformer/PathSource.h @@ -37,12 +37,17 @@ class PathSource : public VertexSource { // PathSource void Update(bool leavePathsOpen, - double approximationScale); + double approximationScale); + + void SetGlobalScale(double scale); private: PathContainer* fPaths; AGGPath fAGGPath; AGGCurvedPath fAGGCurvedPath; + + double fGlobalScale; + double fLastTransformerScale; }; } // namespace Icon diff --git a/src/libs/icon/transformer/StrokeTransformer.cpp b/src/libs/icon/transformer/StrokeTransformer.cpp index 4997a0e394..7ef5726efc 100644 --- a/src/libs/icon/transformer/StrokeTransformer.cpp +++ b/src/libs/icon/transformer/StrokeTransformer.cpp @@ -121,7 +121,11 @@ StrokeTransformer::WantsOpenPaths() const double StrokeTransformer::ApproximationScale() const { - return fSource.ApproximationScale() * width(); + double scale = fSource.ApproximationScale(); + double factor = fabs(width()); + if (factor > 1.0) + scale *= factor; + return scale; } // #pragma mark -