* 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:
parent
9226faeadb
commit
12a257d7f8
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2006, Haiku.
|
* Copyright 2006-2007, Haiku. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
|
@ -100,7 +100,7 @@ StyleHandler::color(unsigned styleIndex)
|
||||||
{
|
{
|
||||||
StyleItem* styleItem = (StyleItem*)fStyles.ItemAt(styleIndex);
|
StyleItem* styleItem = (StyleItem*)fStyles.ItemAt(styleIndex);
|
||||||
if (!styleItem) {
|
if (!styleItem) {
|
||||||
printf("no style at index: %d!\n", styleIndex);
|
printf("no style at index: %u!\n", styleIndex);
|
||||||
return fTransparent;
|
return fTransparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ StyleHandler::generate_span(agg::rgba8* span, int x, int y,
|
||||||
{
|
{
|
||||||
StyleItem* styleItem = (StyleItem*)fStyles.ItemAt(styleIndex);
|
StyleItem* styleItem = (StyleItem*)fStyles.ItemAt(styleIndex);
|
||||||
if (!styleItem || !styleItem->style->Gradient()) {
|
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?
|
// TODO: memset() span?
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -397,6 +397,7 @@ IconRenderer::_Render(const BRect& r)
|
||||||
styleIndex++;
|
styleIndex++;
|
||||||
|
|
||||||
// global scale
|
// global scale
|
||||||
|
shape->SetGlobalScale(max_c(1.0, transform.scale()));
|
||||||
ScaledPath scaledPath(shape->VertexSource(), transform);
|
ScaledPath scaledPath(shape->VertexSource(), transform);
|
||||||
if (shape->Hinting()) {
|
if (shape->Hinting()) {
|
||||||
// additional hinting
|
// additional hinting
|
||||||
|
|
|
@ -482,6 +482,13 @@ Shape::VertexSource()
|
||||||
return *source;
|
return *source;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetGlobalScale
|
||||||
|
void
|
||||||
|
Shape::SetGlobalScale(double scale)
|
||||||
|
{
|
||||||
|
fPathSource.SetGlobalScale(scale);
|
||||||
|
}
|
||||||
|
|
||||||
// AddTransformer
|
// AddTransformer
|
||||||
bool
|
bool
|
||||||
Shape::AddTransformer(Transformer* transformer)
|
Shape::AddTransformer(Transformer* transformer)
|
||||||
|
|
|
@ -105,6 +105,7 @@ class Shape : public BPrivate::Icon::Transformable {
|
||||||
BRect Bounds(bool updateLast = false) const;
|
BRect Bounds(bool updateLast = false) const;
|
||||||
|
|
||||||
::VertexSource& VertexSource();
|
::VertexSource& VertexSource();
|
||||||
|
void SetGlobalScale(double scale);
|
||||||
|
|
||||||
bool AddTransformer(Transformer* transformer);
|
bool AddTransformer(Transformer* transformer);
|
||||||
bool AddTransformer(Transformer* transformer,
|
bool AddTransformer(Transformer* transformer,
|
||||||
|
|
|
@ -93,7 +93,7 @@ AffineTransformer::SetSource(VertexSource& source)
|
||||||
double
|
double
|
||||||
AffineTransformer::ApproximationScale() const
|
AffineTransformer::ApproximationScale() const
|
||||||
{
|
{
|
||||||
return fSource.ApproximationScale() * scale();
|
return fabs(fSource.ApproximationScale() * scale());
|
||||||
}
|
}
|
||||||
|
|
||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
|
@ -111,7 +111,11 @@ ContourTransformer::SetSource(VertexSource& source)
|
||||||
double
|
double
|
||||||
ContourTransformer::ApproximationScale() const
|
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 -
|
// #pragma mark -
|
||||||
|
|
|
@ -13,10 +13,13 @@
|
||||||
|
|
||||||
// constructor
|
// constructor
|
||||||
PathSource::PathSource(PathContainer* paths)
|
PathSource::PathSource(PathContainer* paths)
|
||||||
: VertexSource(),
|
: VertexSource()
|
||||||
fPaths(paths),
|
, fPaths(paths)
|
||||||
fAGGPath(),
|
, fAGGPath()
|
||||||
fAGGCurvedPath(fAGGPath)
|
, fAGGCurvedPath(fAGGPath)
|
||||||
|
|
||||||
|
, fGlobalScale(1.0)
|
||||||
|
, fLastTransformerScale(1.0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,6 +71,15 @@ PathSource::Update(bool leavePathsOpen, double approximationScale)
|
||||||
fAGGPath.close_polygon();
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,12 +37,17 @@ class PathSource : public VertexSource {
|
||||||
|
|
||||||
// PathSource
|
// PathSource
|
||||||
void Update(bool leavePathsOpen,
|
void Update(bool leavePathsOpen,
|
||||||
double approximationScale);
|
double approximationScale);
|
||||||
|
|
||||||
|
void SetGlobalScale(double scale);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PathContainer* fPaths;
|
PathContainer* fPaths;
|
||||||
AGGPath fAGGPath;
|
AGGPath fAGGPath;
|
||||||
AGGCurvedPath fAGGCurvedPath;
|
AGGCurvedPath fAGGCurvedPath;
|
||||||
|
|
||||||
|
double fGlobalScale;
|
||||||
|
double fLastTransformerScale;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Icon
|
} // namespace Icon
|
||||||
|
|
|
@ -121,7 +121,11 @@ StrokeTransformer::WantsOpenPaths() const
|
||||||
double
|
double
|
||||||
StrokeTransformer::ApproximationScale() const
|
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 -
|
// #pragma mark -
|
||||||
|
|
Loading…
Reference in New Issue