[Libreoffice-commits] core.git: Branch 'feature/tiledrendering' - include/touch ios/shared sw/source

Ptyl Dragon ptyl at cloudon.com
Thu Oct 31 14:20:57 CET 2013


 include/touch/touch.h                                                               |   98 ++++++----
 ios/shared/ios_sharedlo/objective_c/view_controllers/testing_tiles/MLOTestingTile.m |    8 
 sw/source/core/view/viewsh.cxx                                                      |   46 ++--
 3 files changed, 90 insertions(+), 62 deletions(-)

New commits:
commit d1528ec8e05d2a8bde93facbe338bde4cc1e017a
Author: Ptyl Dragon <ptyl at cloudon.com>
Date:   Thu Oct 31 15:20:13 2013 +0200

    added units MLODpxes and MLORips
    
    Change-Id: Ica09fbd0f6a822f464df302dba4cf40d1d089697

diff --git a/include/touch/touch.h b/include/touch/touch.h
index 6601a05..5902376 100644
--- a/include/touch/touch.h
+++ b/include/touch/touch.h
@@ -71,69 +71,89 @@ typedef basegfx::B2IBox MLORect;
 
 // MLODip - Device Independent Pixels
 
-typedef long long MLOPixel;
-static const MLOPixel LO_TWIPS_TO_MLO_PIXEL_RATIO = 10L;
-struct MLOPixelSize {
-    MLOPixel width;
-    MLOPixel height;
+typedef long long MLORip;
+typedef CGFloat MLODpx;
+typedef CGPoint MLODpxPoint;
+typedef CGSize MLODpxSize;
+
+CG_INLINE MLODpxPoint
+MLODpxPointByDpxes(MLODpx x, MLODpx y)
+{
+    return CGPointMake(x, y);
+}
+
+CG_INLINE MLODpxSize
+MLODpxSizeByDpxes(MLODpx width, MLODpx height)
+{
+    return CGSizeMake(width, height);
+}
+
+static const MLORip LO_TWIPS_TO_MLO_RIP_RATIO = 10L;
+
+struct MLORipSize
+{
+    MLORip width;
+    MLORip height;
 };
-typedef struct MLOPixelSize MLOPixelSize;
-struct MLOPixelPoint {
-    MLOPixel x;
-    MLOPixel y;
+typedef struct MLORipSize MLORipSize;
+
+struct MLORipPoint
+{
+    MLORip x;
+    MLORip y;
 };
-typedef struct MLOPixelPoint MLOPixelPoint;
+typedef struct MLORipPoint MLORipPoint;
 
-CG_INLINE CGFloat
-MLOPixelToCGFloat(MLOPixel mloPixel)
+CG_INLINE MLODpx
+MLODpxByRip(MLORip rip)
 {
-    return (CGFloat) (mloPixel / LO_TWIPS_TO_MLO_PIXEL_RATIO);
+    return (MLODpx) (rip / LO_TWIPS_TO_MLO_RIP_RATIO);
 }
 
-CG_INLINE MLOPixel
-CGFloatToMLOPixel(CGFloat cgFloat)
+CG_INLINE MLORip
+MLORipByDpx(MLODpx dpx)
 {
-    return (MLOPixel) cgFloat * LO_TWIPS_TO_MLO_PIXEL_RATIO;
+    return (MLORip) (dpx * LO_TWIPS_TO_MLO_RIP_RATIO);
 }
 
-CG_INLINE MLOPixelSize
-MLOPixelSizeMake(MLOPixel width, MLOPixel height)
+CG_INLINE MLORipSize
+MLORipSizeByRips(MLORip width, MLORip height)
 {
-    MLOPixelSize size; size.width = width; size.height = height; return size;
+    MLORipSize ripSize; ripSize.width = width; ripSize.height = height; return ripSize;
 }
 
-CG_INLINE MLOPixelPoint
-MLOPixelPointMake(MLOPixel x, MLOPixel y)
+CG_INLINE MLORipPoint
+MLORipPointByRips(MLORip x, MLORip y)
 {
-    MLOPixelPoint point; point.x = x; point.y = y; return point;
+    MLORipPoint point; point.x = x; point.y = y; return point;
 }
 
-CG_INLINE MLOPixelSize
-CGSizeToMLOPixelSize(CGSize cgSize)
+CG_INLINE MLORipSize
+MLORipSizeByDpxSize(MLODpxSize dpxSize)
 {
-    MLOPixelSize mloPixelSize;
-    mloPixelSize.width = MLOPixelToCGFloat(cgSize.width);
-    mloPixelSize.height = MLOPixelToCGFloat(cgSize.height);
-    return mloPixelSize;
+    MLORipSize ripSize;
+    ripSize.width = MLORipByDpx(dpxSize.width);
+    ripSize.height = MLORipByDpx(dpxSize.height);
+    return ripSize;
 }
 
-CG_INLINE CGSize
-MLOPixelsToCGSize(MLOPixel width, MLOPixel height)
+CG_INLINE MLODpxSize
+MLODpxSizeByRips(MLORip width, MLORip height)
 {
-    CGFloat fWidth = MLOPixelToCGFloat(width);
-    CGFloat fHeight = MLOPixelToCGFloat(height);
+    CGFloat fWidth = MLODpxByRip(width);
+    CGFloat fHeight = MLODpxByRip(height);
     return CGSizeMake(fWidth, fHeight);
 }
 
-CG_INLINE CGSize
-MLOPixelSizeToCGSize(MLOPixelSize mloPixelSize)
+CG_INLINE MLODpxSize
+MLODpxSizeByRipSize(MLORipSize ripSize)
 {
-    return MLOPixelsToCGSize(mloPixelSize.width, mloPixelSize.height);
+    return MLODpxSizeByRips(ripSize.width, ripSize.height);
 }
 
-MLOPixelPoint CGPointToMLOPixelPoint(CGPoint cgPoint);
+MLORipPoint MLORipPointByDpxPoint(MLODpxPoint mloDpxPoint);
 
-CGPoint MLOPixelPointToCGPoint(MLOPixelPoint mloPixelPoint);
+MLODpxPoint MLODpxPointByMLORipPoint(MLORipPoint mloRipPoint);
 
 
 // selection
@@ -178,9 +198,9 @@ void touch_lo_keyboard_input(int c);
 tilePosX, tilePosY, tileWidth, tileHeight address the part of the document to be drawn.
 context, contextHeight, contextWidth specify where to draw.
 */
-void touch_lo_draw_tile(void *context, int contextWidth, int contextHeight, int tilePosX, int tilePosY, int tileWidth, int tileHeight);
+void touch_lo_draw_tile(void *context, int contextWidth, int contextHeight, MLODpxPoint tilePosition, MLODpxSize tileSize);
 void touch_lo_copy_buffer(const void * source, size_t sourceWidth, size_t sourceHeight, size_t sourceBytesPerRow, void * target, size_t targetWidth, size_t targetHeight);
-CGSize touch_lo_get_content_size();
+MLODpxSize touch_lo_get_content_size();
 void touch_lo_mouse_drag(int x, int y, MLOMouseButtonState state);
 
 // Move the start of the selection to (x,y)
diff --git a/ios/shared/ios_sharedlo/objective_c/view_controllers/testing_tiles/MLOTestingTile.m b/ios/shared/ios_sharedlo/objective_c/view_controllers/testing_tiles/MLOTestingTile.m
index 14428ce..f066116 100644
--- a/ios/shared/ios_sharedlo/objective_c/view_controllers/testing_tiles/MLOTestingTile.m
+++ b/ios/shared/ios_sharedlo/objective_c/view_controllers/testing_tiles/MLOTestingTile.m
@@ -53,14 +53,12 @@
     touch_lo_draw_tile(context,
                        self.tester.params.contextWidth,
                        self.tester.params.contextHeight,
-                       self.tester.params.tilePosX,
-                       self.tester.params.tilePosY,
-                       self.tester.params.tileWidth,
-                       self.tester.params.tileHeight);
+                       MLODpxPointByDpxes(self.tester.params.tilePosX,self.tester.params.tilePosY),
+                       MLODpxSizeByDpxes(self.tester.params.tileWidth,self.tester.params.tileHeight));
 
     CGContextRestoreGState(context);
 
-    CGSize size = touch_lo_get_content_size();
+    MLODpxSize size = touch_lo_get_content_size();
     NSLog(@"touch_lo_get_content_size: width=%f, height=%f",size.width, size.height);
 }
 
diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx
index 8606126..6d1837c 100644
--- a/sw/source/core/view/viewsh.cxx
+++ b/sw/source/core/view/viewsh.cxx
@@ -1773,8 +1773,18 @@ void ViewShell::PaintTile(OutputDevice *pOut, const Rectangle &rRect)
 
 #if !HAVE_FEATURE_DESKTOP
 extern "C"
-void touch_lo_draw_tile(void * context, int contextWidth, int contextHeight, int tilePosX, int tilePosY, int tileWidth, int tileHeight)
-{
+void touch_lo_draw_tile(void *context, int contextWidth, int contextHeight, MLODpxPoint tileDpxPosition, MLODpxSize tileDpxSize)
+{
+    MLORipPoint tileRipPosition = MLORipPointByDpxPoint(tileDpxPosition);
+    MLORipSize rileRipSize = MLORipSizeByDpxSize(tileDpxSize);
+    MLORip tileRipPosX = tileRipPosition.x;
+    MLORip tileRipPosY = tileRipPosition.y;
+    MLORip tileRipWidth = rileRipSize.width;
+    MLORip tileRipHeight = rileRipSize.height;
+    int tilePosX = tileRipPosX;
+    int tilePosY = tileRipPosY;
+    int tileWidth  = tileRipWidth;
+    int tileHeight = tileRipHeight;
     // Currently we expect that only one document is open, so we are using the
     // current shell.  Should it turn out that we need to have more documents
     // open, we need to add a documentHandle that would hold the right
@@ -1818,36 +1828,36 @@ void touch_lo_draw_tile(void * context, int contextWidth, int contextHeight, int
     Application::ReleaseSolarMutex();
 }
 extern "C"
-CGSize touch_lo_get_content_size()
+MLODpxSize touch_lo_get_content_size()
 {
     SwWrtShell *pViewShell = GetActiveWrtShell();
     if (pViewShell)
     {
-        static const long WIDTH_ADDITION  = 6L * DOCUMENTBORDER;
-        static const long HEIGHT_ADDITION = 2L * DOCUMENTBORDER;
+        static const MLORip WIDTH_ADDITION  = 6L * DOCUMENTBORDER;
+        static const MLORip HEIGHT_ADDITION = 2L * DOCUMENTBORDER;
         Size documentSize =pViewShell->GetView().GetDocSz();
-        return MLOPixelsToCGSize(documentSize.Width() + WIDTH_ADDITION,
-                                  documentSize.Height() + HEIGHT_ADDITION);
+        return MLODpxSizeByRips(((MLORip)documentSize.Width()) + WIDTH_ADDITION,
+                               ((MLORip)documentSize.Height()) + HEIGHT_ADDITION);
     }
-    return CGSizeMake(0,0);
+    return MLODpxSizeByDpxes(0,0);
 }
 
 extern "C"
-MLOPixelPoint CGPointToMLOPixelPoint(CGPoint cgPoint)
+MLORipPoint MLORipPointByDpxPoint(MLODpxPoint mloDpxPoint)
 {
-    CGSize contentSize = touch_lo_get_content_size();
-    MLOPixel x = CGFloatToMLOPixel(cgPoint.x - (contentSize.width/2.0f));
-    MLOPixel y = CGFloatToMLOPixel(cgPoint.y);
-    return MLOPixelPointMake(x,y);
+    MLODpxSize contentSize = touch_lo_get_content_size();
+    MLORip x = MLORipByDpx(mloDpxPoint.x - (contentSize.width/2.0f));
+    MLORip y = MLORipByDpx(mloDpxPoint.y);
+    return MLORipPointByRips(x,y);
 }
 
 extern "C"
-CGPoint MLOPixelPointToCGPoint(MLOPixelPoint mloPixelPoint)
+MLODpxPoint MLODpxPointByRipPoint(MLORipPoint mloRipPoint)
 {
-    CGSize contentSize = touch_lo_get_content_size();
-    CGFloat x = MLOPixelToCGFloat(mloPixelPoint.x) + (contentSize.width/2.0f);
-    CGFloat y = MLOPixelToCGFloat(mloPixelPoint.y);
-    return CGPointMake(x,y);
+    MLODpxSize contentSize = touch_lo_get_content_size();
+    MLODpx x = MLODpxByRip(mloRipPoint.x) + (contentSize.width/2.0f);
+    MLODpx y = MLODpxByRip(mloRipPoint.y);
+    return MLODpxPointByDpxes(x,y);
 }
 #endif
 


More information about the Libreoffice-commits mailing list