From 8b600b7cb7bc7a9eff2ed82b726241a2c4c9f26b Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Wed, 29 Dec 2010 07:53:21 +0000 Subject: [PATCH] Implement RP_DRAW_STRING_WITH_OFFSETS. Untested though, especially the bounding box part should be validated. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40016 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/remotedesktop/RemoteView.cpp | 43 ++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/src/apps/remotedesktop/RemoteView.cpp b/src/apps/remotedesktop/RemoteView.cpp index 62f6aa30da..485c4752cf 100644 --- a/src/apps/remotedesktop/RemoteView.cpp +++ b/src/apps/remotedesktop/RemoteView.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2009, Haiku, Inc. + * Copyright 2009-2010, Haiku, Inc. * Distributed under the terms of the MIT License. * * Authors: @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -1228,6 +1229,46 @@ RemoteView::_DrawThread() break; } + case RP_DRAW_STRING_WITH_OFFSETS: + { + size_t length; + char *string; + message.ReadString(&string, length); + int32 count = UTF8CountChars(string, length); + + BPoint offsets[count]; + if (message.ReadList(offsets, count) != B_OK) { + free(string); + continue; + } + + offscreen->DrawString(string, offsets, count); + + free(string); + reply.Start(RP_DRAW_STRING_RESULT); + reply.Add(token); + reply.Add(offscreen->PenLocation()); + reply.Flush(); + + BFont font; + offscreen->GetFont(&font); + + BRect boxes[count]; + font.GetBoundingBoxesAsGlyphs(string, count, B_SCREEN_METRIC, + boxes); + + font_height height; + offscreen->GetFontHeight(&height); + + for (int32 i = 0; i < count; i++) { + // TODO: validate + boxes[i].OffsetBy(offsets[i] + BPoint(0, -height.ascent)); + invalidRegion.Include(boxes[i]); + } + + break; + } + case RP_READ_BITMAP: { BRect bounds;