* make sure that the ApproximationScale() implementation of any Transformer

not negative
* PathSource can now remember a global scale, and the IconRenderer sets
  it, since this value is used in the curve converter for on the fly
  generation of vertices, this change does not affect anything and doesn't
  create the need to "update" the conversion pipeline to render an icon at
  different sizes (like Icon-O-Matic does)

-> this change fixes edgy curves on icons rendered bigger than 64x64 as
  reported by Axel some time ago


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23093 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus 2007-12-09 15:36:28 +00:00
parent 9226faeadb
commit 12a257d7f8
8 changed files with 46 additions and 12 deletions

View File

@ -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

View File

@ -482,6 +482,13 @@ Shape::VertexSource()
return *source;
}
// SetGlobalScale
void
Shape::SetGlobalScale(double scale)
{
fPathSource.SetGlobalScale(scale);
}
// AddTransformer
bool
Shape::AddTransformer(Transformer* transformer)

View File

@ -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,

View File

@ -93,7 +93,7 @@ AffineTransformer::SetSource(VertexSource& source)
double
AffineTransformer::ApproximationScale() const
{
return fSource.ApproximationScale() * scale();
return fabs(fSource.ApproximationScale() * scale());
}
// #pragma mark -

View File

@ -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 -

View File

@ -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);
}

View File

@ -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

View File

@ -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 -