[haiku-commits] haiku: hrev52705 - src/servers/app/drawing

  • From: Rene Gollent <rene@xxxxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Thu, 3 Jan 2019 13:19:05 -0500 (EST)

hrev52705 adds 1 changeset to branch 'master'
old head: 6990ae7b8446c1a3b1d560245d63aa017ed4156f
new head: f8550e541b26cb70ad6ba02352ba4879cec0be90
overview: 
https://git.haiku-os.org/haiku/log/?qt=range&q=f8550e541b26+%5E6990ae7b8446

----------------------------------------------------------------------------

f8550e541b26: Added two DrawStringDry() versions for obtaining pen location only
  
  When recording into a BPicture (ServerPicture, actually), one cannot
  simply record the commands only, when the drawing itself would modify
  state. This affects all drawing commands that change the pen location.
  Therefore it is necessary to have a way to "dry-run" drawing a string
  in order to know the pen location that would result. This is what
  these two new methods help achieve.
  
  Change-Id: Ic399a5513f18c12c16c0ab10a55e768c1b30e4e0
  Reviewed-on: https://review.haiku-os.org/816
  Reviewed-by: Rene Gollent <rene@xxxxxxxxxxx>

                                      [ Stephan Aßmus <superstippi@xxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev52705
Commit:      f8550e541b26cb70ad6ba02352ba4879cec0be90
URL:         https://git.haiku-os.org/haiku/commit/?id=f8550e541b26
Author:      Stephan Aßmus <superstippi@xxxxxx>
Date:        Wed Jan  2 17:44:14 2019 UTC
Committer:   Rene Gollent <rene@xxxxxxxxxxx>
Commit-Date: Thu Jan  3 18:19:02 2019 UTC

----------------------------------------------------------------------------

2 files changed, 44 insertions(+), 3 deletions(-)
src/servers/app/drawing/DrawingEngine.cpp | 38 +++++++++++++++++++++++++--
src/servers/app/drawing/DrawingEngine.h   |  9 ++++++-

----------------------------------------------------------------------------

diff --git a/src/servers/app/drawing/DrawingEngine.cpp 
b/src/servers/app/drawing/DrawingEngine.cpp
index eb323a1430..d3df91dc49 100644
--- a/src/servers/app/drawing/DrawingEngine.cpp
+++ b/src/servers/app/drawing/DrawingEngine.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright 2001-2015, Haiku, Inc.
+ * Copyright 2001-2018, Haiku, Inc.
  * Distributed under the terms of the MIT License.
  *
  * Authors:
@@ -1409,7 +1409,7 @@ DrawingEngine::DrawString(const char* string, int32 
length,
 {
        ASSERT_PARALLEL_LOCKED();
 
-       // use a FontCacheRefernece to speed up the second pass of
+       // use a FontCacheReference to speed up the second pass of
        // drawing the string
        FontCacheReference cacheReference;
 
@@ -1450,6 +1450,40 @@ DrawingEngine::StringWidth(const char* string, int32 
length,
 }
 
 
+BPoint
+DrawingEngine::DrawStringDry(const char* string, int32 length,
+       const BPoint& pt, escapement_delta* delta)
+{
+       ASSERT_PARALLEL_LOCKED();
+
+       BPoint penLocation = pt;
+
+       // try a fast path first
+       if (fPainter->Font().Rotation() == 0.0f
+               && fPainter->IsIdentityTransform()) {
+               penLocation.x += StringWidth(string, length, delta);
+               return penLocation;
+       }
+
+       fPainter->BoundingBox(string, length, pt, &penLocation, delta, NULL);
+
+       return penLocation;
+}
+
+
+BPoint
+DrawingEngine::DrawStringDry(const char* string, int32 length,
+       const BPoint* offsets)
+{
+       ASSERT_PARALLEL_LOCKED();
+
+       BPoint penLocation;
+       fPainter->BoundingBox(string, length, offsets, &penLocation, NULL);
+
+       return penLocation;
+}
+
+
 // #pragma mark -
 
 
diff --git a/src/servers/app/drawing/DrawingEngine.h 
b/src/servers/app/drawing/DrawingEngine.h
index 0aafa63d50..dc010bb925 100644
--- a/src/servers/app/drawing/DrawingEngine.h
+++ b/src/servers/app/drawing/DrawingEngine.h
@@ -1,5 +1,5 @@
 /*
- * Copyright 2001-2015, Haiku, Inc.
+ * Copyright 2001-2018, Haiku, Inc.
  * Distributed under the terms of the MIT License.
  *
  * Authors:
@@ -184,6 +184,13 @@ public:
                                                                int32 length, 
const ServerFont& font,
                                                                
escapement_delta* delta = NULL);
 
+                       BPoint                  DrawStringDry(const char* 
string, int32 length,
+                                                               const BPoint& 
pt,
+                                                               
escapement_delta* delta = NULL);
+                       BPoint                  DrawStringDry(const char* 
string, int32 length,
+                                                               const BPoint* 
offsets);
+
+
        // software rendering backend invoked by CopyRegion() for the sorted
        // individual rects
        virtual BRect                   CopyRect(BRect rect, int32 xOffset,


Other related posts:

  • » [haiku-commits] haiku: hrev52705 - src/servers/app/drawing - Rene Gollent