now updates BView::PenLocation() correctly after DrawString(), stuff like DrawChar('a') is working nicely now, for rotated text much better then in BeOS in fact because of subpixel precision in pen location
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14794 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
5fdbbf2ba5
commit
2b97fe884d
@ -167,7 +167,7 @@ public:
|
||||
// -------- text related calls
|
||||
|
||||
// DrawState is NOT const because this call updates the pen position in the passed DrawState
|
||||
void DrawString( const char* string,
|
||||
BPoint DrawString( const char* string,
|
||||
int32 length,
|
||||
const BPoint& pt,
|
||||
DrawState* d,
|
||||
|
@ -1962,7 +1962,10 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link)
|
||||
link.ReadString(&string);
|
||||
|
||||
fCurrentLayer->ConvertToScreen(&location);
|
||||
driver->DrawString(string, length, location, fCurrentLayer->CurrentState(), &delta);
|
||||
BPoint penLocation = driver->DrawString(string, length, location,
|
||||
fCurrentLayer->CurrentState(), &delta);
|
||||
fCurrentLayer->ConvertFromScreen(&penLocation);
|
||||
fCurrentLayer->CurrentState()->SetPenLocation(penLocation);
|
||||
|
||||
free(string);
|
||||
break;
|
||||
|
@ -983,12 +983,13 @@ DrawingEngine::DrawString(const char *string, const int32 &length,
|
||||
}
|
||||
*/
|
||||
// DrawString
|
||||
void
|
||||
BPoint
|
||||
DrawingEngine::DrawString(const char* string, int32 length,
|
||||
const BPoint& pt, DrawState* d,
|
||||
escapement_delta* delta)
|
||||
{
|
||||
// TODO: use delta
|
||||
BPoint penLocation = pt;
|
||||
if (Lock()) {
|
||||
FontLocker locker(d);
|
||||
fPainter->SetDrawState(d);
|
||||
@ -998,7 +999,9 @@ DrawingEngine::DrawString(const char* string, int32 length,
|
||||
// TODO: make the availability of the hardware cursor part of the
|
||||
// HW acceleration flags and skip all calculations for HideSoftwareCursor
|
||||
// in case we don't have one.
|
||||
BRect b = fPainter->BoundingBox(string, length, pt, delta);
|
||||
// TODO: Watch out about penLocation and use Painter::PenLocation() when
|
||||
// not using BoundindBox anymore.
|
||||
BRect b = fPainter->BoundingBox(string, length, pt, &penLocation, delta);
|
||||
// stop here if we're supposed to render outside of the clipping
|
||||
b = fPainter->ClipRect(b);
|
||||
if (b.IsValid()) {
|
||||
@ -1014,6 +1017,7 @@ DrawingEngine::DrawString(const char* string, int32 length,
|
||||
}
|
||||
Unlock();
|
||||
}
|
||||
return penLocation;
|
||||
}
|
||||
|
||||
// StringWidth
|
||||
@ -1053,8 +1057,9 @@ DrawingEngine::StringHeight(const char *string, int32 length,
|
||||
if (Lock()) {
|
||||
FontLocker locker(d);
|
||||
fPainter->SetDrawState(d);
|
||||
static BPoint dummy(0.0, 0.0);
|
||||
height = fPainter->BoundingBox(string, length, dummy).Height();
|
||||
static BPoint dummy1(0.0, 0.0);
|
||||
static BPoint dummy2(0.0, 0.0);
|
||||
height = fPainter->BoundingBox(string, length, dummy1, &dummy2).Height();
|
||||
Unlock();
|
||||
}
|
||||
return height;
|
||||
|
@ -1059,15 +1059,15 @@ Painter::InvertRect(const BRect& r) const
|
||||
// BoundingBox
|
||||
BRect
|
||||
Painter::BoundingBox(const char* utf8String, uint32 length,
|
||||
const BPoint& baseLine, const escapement_delta* delta) const
|
||||
const BPoint& baseLine, BPoint* penLocation,
|
||||
const escapement_delta* delta) const
|
||||
{
|
||||
static BRect dummy;
|
||||
BPoint penPosition;
|
||||
return fTextRenderer->RenderString(utf8String,
|
||||
length,
|
||||
fFontRendererSolid,
|
||||
fFontRendererBin,
|
||||
baseLine, dummy, true, &penPosition,
|
||||
baseLine, dummy, true, penLocation,
|
||||
delta);
|
||||
}
|
||||
|
||||
|
@ -82,6 +82,8 @@ class Painter {
|
||||
void SetPattern(const pattern& p);
|
||||
|
||||
void SetPenLocation(const BPoint& location);
|
||||
BPoint PenLocation() const
|
||||
{ return fPenLocation; }
|
||||
void SetFont(const ServerFont& font);
|
||||
|
||||
// painting functions
|
||||
@ -206,8 +208,11 @@ class Painter {
|
||||
|
||||
BRect InvertRect( const BRect& r) const;
|
||||
|
||||
BRect BoundingBox( const char* utf8String, uint32 length,
|
||||
const BPoint& baseLine, const escapement_delta* delta = NULL) const;
|
||||
BRect BoundingBox( const char* utf8String,
|
||||
uint32 length,
|
||||
const BPoint& baseLine,
|
||||
BPoint* penLocation,
|
||||
const escapement_delta* delta = NULL) const;
|
||||
|
||||
float StringWidth( const char* utf8String,
|
||||
uint32 length) const;
|
||||
|
Loading…
Reference in New Issue
Block a user