1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Some rendering fixes.

This commit is contained in:
jules 2013-08-08 18:01:47 +01:00
parent a469fa6def
commit 7fb2533bb0
5 changed files with 27 additions and 15 deletions

View file

@ -67,8 +67,7 @@ public:
virtual void setOrigin (int x, int y) = 0;
virtual void addTransform (const AffineTransform&) = 0;
virtual float getScaleFactor() = 0;
virtual float getTargetDeviceScaleFactor() { return 1.0f; }
virtual float getTargetDeviceScaleFactor() = 0;
virtual bool clipToRectangle (const Rectangle<int>&) = 0;
virtual bool clipToRectangleList (const RectangleList<int>&) = 0;

View file

@ -105,11 +105,8 @@ void LowLevelGraphicsPostScriptRenderer::addTransform (const AffineTransform& /*
jassertfalse;
}
float LowLevelGraphicsPostScriptRenderer::getScaleFactor()
{
jassertfalse; //xxx
return 1.0f;
}
float LowLevelGraphicsPostScriptRenderer::getScaleFactor() { return 1.0f; }
float LowLevelGraphicsPostScriptRenderer::getTargetDeviceScaleFactor() { return 1.0f; }
bool LowLevelGraphicsPostScriptRenderer::clipToRectangle (const Rectangle<int>& r)
{

View file

@ -50,6 +50,7 @@ public:
void setOrigin (int x, int y) override;
void addTransform (const AffineTransform&) override;
float getScaleFactor() override;
float getTargetDeviceScaleFactor() override;
bool clipToRectangle (const Rectangle<int>&) override;
bool clipToRectangleList (const RectangleList<int>&) override;

View file

@ -94,7 +94,10 @@ public:
float getScaleFactor() const noexcept
{
return isOnlyTranslated ? 1.0f : complexTransform.getScaleFactor();
return isOnlyTranslated ? 1.0f
: (isRotated ? complexTransform.getScaleFactor()
: jmax (complexTransform.mat00,
complexTransform.mat11));
}
void moveOriginInDeviceSpace (const int dx, const int dy) noexcept
@ -1892,7 +1895,8 @@ struct ClipRegions
const int clipTop = i->getY();
const int clipBottom = i->getBottom();
if (f.totalBottom > clipTop && f.totalTop < clipBottom && f.totalRight > clipLeft && f.totalLeft < clipRight)
if (f.totalBottom > clipTop && f.totalTop < clipBottom
&& f.totalRight > clipLeft && f.totalLeft < clipRight)
{
if (f.isOnePixelWide())
{
@ -2052,6 +2056,16 @@ public:
return clip != nullptr;
}
static Rectangle<int> getLargestIntegerWithin (Rectangle<float> r)
{
const int x1 = (int) std::ceil (r.getX());
const int y1 = (int) std::ceil (r.getY());
const int x2 = (int) std::floor (r.getRight());
const int y2 = (int) std::floor (r.getBottom());
return Rectangle<int> (x1, y1, x2 - x1, y2 - y1);
}
bool excludeClipRectangle (const Rectangle<int>& r)
{
if (clip != nullptr)
@ -2060,11 +2074,11 @@ public:
if (transform.isOnlyTranslated)
{
clip = clip->excludeClipRectangle (transform.translated (r));
clip = clip->excludeClipRectangle (getLargestIntegerWithin (transform.translated (r.toFloat())));
}
else if (! transform.isRotated)
{
clip = clip->excludeClipRectangle (transform.transformed (r));
clip = clip->excludeClipRectangle (getLargestIntegerWithin (transform.transformed (r.toFloat())));
}
else
{
@ -2543,6 +2557,7 @@ public:
void setOrigin (int x, int y) override { stack->transform.setOrigin (x, y); }
void addTransform (const AffineTransform& t) override { stack->transform.addTransform (t); }
float getScaleFactor() override { return stack->transform.getScaleFactor(); }
float getTargetDeviceScaleFactor() override { return stack->transform.getScaleFactor(); }
Rectangle<int> getClipBounds() const override { return stack->getClipBounds(); }
bool isClipEmpty() const override { return stack->clip == nullptr; }
bool clipRegionIntersects (const Rectangle<int>& r) override { return stack->clipRegionIntersects (r); }

View file

@ -365,12 +365,12 @@ public:
bool contains (Point<int> localPos, bool trueIfInAChildWindow) const override
{
if (! (isPositiveAndBelow (localPos.getX(), component.getWidth())
&& isPositiveAndBelow (localPos.getY(), component.getHeight())))
return false;
NSRect frameRect = [view frame];
if (! (isPositiveAndBelow (localPos.getX(), (int) frameRect.size.width)
&& isPositiveAndBelow (localPos.getY(), (int) frameRect.size.height)))
return false;
NSView* v = [view hitTest: NSMakePoint (frameRect.origin.x + localPos.getX(),
frameRect.origin.y + frameRect.size.height - localPos.getY())];