[gimp/metadata-browser] Revert "app: Add /gimptilebackendtilemanager/basic_write unit test"



commit 87a55710154200152c6d65270511f75c6c7268ff
Author: Martin Nordholts <martinn src gnome org>
Date:   Sun Oct 2 18:41:11 2011 +0200

    Revert "app: Add /gimptilebackendtilemanager/basic_write unit test"
    
    This reverts commit e4d6726bde0be63fe80fb1c92922681239faf6ea.
    We need a GEGL release to depend on first.

 app/gegl/gimptilebackendtilemanager.c       |   24 +++++---
 app/tests/test-gimptilebackendtilemanager.c |   84 ++++-----------------------
 2 files changed, 27 insertions(+), 81 deletions(-)
---
diff --git a/app/gegl/gimptilebackendtilemanager.c b/app/gegl/gimptilebackendtilemanager.c
index b457c4d..46dab38 100644
--- a/app/gegl/gimptilebackendtilemanager.c
+++ b/app/gegl/gimptilebackendtilemanager.c
@@ -37,7 +37,7 @@
 #include "gimp-gegl-utils.h"
 
 
-struct _GimpTileBackendTileManagerPrivate
+struct _GimpTileBackendTileManagerPrivate 
 {
   GHashTable      *entries;
   TileManager     *tile_manager;
@@ -176,23 +176,29 @@ gimp_tile_backend_tile_manager_command (GeglTileSource  *tile_store,
     case GEGL_TILE_GET:
       {
         GeglTile *tile;
+        gint      tile_size;
         Tile     *gimp_tile;
+        gint      tile_stride;
+        gint      gimp_tile_stride;
+        int       row;
 
         gimp_tile = tile_manager_get_at (backend_tm->priv->tile_manager,
                                          x, y, TRUE, FALSE);
 
         g_return_val_if_fail (gimp_tile != NULL, NULL);
 
-        if (tile_ewidth (gimp_tile)  != TILE_WIDTH ||
-            tile_eheight (gimp_tile) != TILE_HEIGHT)
+        tile_size        = gegl_tile_backend_get_tile_size (backend);
+        tile_stride      = TILE_WIDTH * tile_bpp (gimp_tile);
+        gimp_tile_stride = tile_ewidth (gimp_tile) * tile_bpp (gimp_tile);
+
+        /* XXX: Point to Tile data directly instead of using memcpy */
+        tile = gegl_tile_new (tile_size);
+        for (row = 0; row < tile_eheight (gimp_tile); row++)
           {
-            g_warning ("GimpTileBackendTileManager does not support != %dx%d tiles yet",
-                       TILE_WIDTH, TILE_HEIGHT);
+            memcpy (gegl_tile_get_data (tile) + row * tile_stride,
+                    tile_data_pointer (gimp_tile, 0, row),
+                    gimp_tile_stride);
           }
-        tile = gegl_tile_new_bare ();
-        gegl_tile_set_data (tile,
-                            tile_data_pointer (gimp_tile, 0, 0),
-                            tile_size (gimp_tile));
 
         return tile;
       }
diff --git a/app/tests/test-gimptilebackendtilemanager.c b/app/tests/test-gimptilebackendtilemanager.c
index e6fda09..7206759 100644
--- a/app/tests/test-gimptilebackendtilemanager.c
+++ b/app/tests/test-gimptilebackendtilemanager.c
@@ -51,30 +51,22 @@ typedef struct
 } GimpTestFixture;
 
 
-static const guchar  opaque_magenta8[4]    = { 0xff,   0x00,   0xff,   0xff   };
-static const guchar  transparent_black8[4] = { 0x00,   0x00,   0x00,   0x00   };
-
-static const guint16 opaque_magenta16[4]   = { 0xffff, 0x0000, 0xffff, 0xffff };
-
-/* FIXME: Add tests for non-tile sized rects, they currently won't
- * pass
- */
-static const GeglRectangle rect            = { 0, 0, 64, 64 };
-static const GeglRectangle center_pixel    = { 5, 5, 1,  1  };
-
-
 /**
- * basic_read:
+ * basic_usage:
  * @fixture:
  * @data:
  *
- * Test that the backend can be used for basic reading of TileManager
- * data.
+ * Test basic usage.
  **/
 static void
-basic_read (GimpTestFixture *fixture,
-            gconstpointer    data)
+basic_usage (GimpTestFixture *fixture,
+             gconstpointer    data)
 {
+  GeglRectangle rect                = { 0, 0, 10, 10 };
+  GeglRectangle pixel_rect          = { 5, 5, 1, 1 };
+  guchar        opaque_magenta8[4]  = { 0xff, 0, 0xff, 0xff };
+  guint16       opaque_magenta16[4] = { 0xffff, 0, 0xffff, 0xffff };
+
   PixelRegion      pr;
   TileManager     *tm;
   GeglTileBackend *backend;
@@ -92,59 +84,8 @@ basic_read (GimpTestFixture *fixture,
    */
   backend = gimp_tile_backend_tile_manager_new (tm);
   buffer  = gegl_buffer_new_for_backend (NULL, backend);
-  gegl_buffer_get (buffer, 1.0 /*scale*/, &center_pixel,
-                   babl_format ("RGBA u16"), actual_data,
-                   GEGL_AUTO_ROWSTRIDE);
-  g_assert_cmpint (0, ==, memcmp (opaque_magenta16,
-                                  actual_data,
-                                  sizeof (actual_data)));
-}
-
-/**
- * basic_write:
- * @fixture:
- * @data:
- *
- * Test that the backend can be used for basic writing of TileManager
- * data.
- **/
-static void
-basic_write (GimpTestFixture *fixture,
-             gconstpointer    data)
-{
-  PixelRegion      pr;
-  TileManager     *tm;
-  GeglTileBackend *backend;
-  GeglBuffer      *buffer;
-  guchar           actual_data[4];
-  gint             x, y;
-
-  /* Clear the TileManager */
-  tm = tile_manager_new (rect.width, rect.height, 4);
-  pixel_region_init (&pr, tm, rect.x, rect.y, rect.width, rect.height, TRUE);
-  color_region (&pr, transparent_black8);
-
-  /* Write some data using the GeglBuffer and the backend. Use u16 to
-   * complicate code paths, decreasing risk of the test accidentally
-   * passing
-   */
-  backend = gimp_tile_backend_tile_manager_new (tm);
-  buffer  = gegl_buffer_new_for_backend (NULL, backend);
-  for (y = 0; y < rect.height; y++)
-    for (x = 0; x < rect.width; x++)
-      {
-        GeglRectangle moving_rect = { x, y, 1, 1 };
-        gegl_buffer_set (buffer, &moving_rect,
-                         babl_format ("RGBA u16"), (gpointer) opaque_magenta16,
-                         GEGL_AUTO_ROWSTRIDE);
-      }
-
-  /* Make sure we can read the written data from the TileManager */
-  tile_manager_read_pixel_data_1 (tm, center_pixel.x, center_pixel.y,
-                                  actual_data);
-  g_assert_cmpint (0, ==, memcmp (opaque_magenta8,
-                                  actual_data,
-                                  sizeof (actual_data)));
+  gegl_buffer_get (buffer, 1.0 /*scale*/, &pixel_rect, babl_format ("RGBA u16"), actual_data, GEGL_AUTO_ROWSTRIDE);
+  g_assert_cmpint (0, ==, memcmp (opaque_magenta16, actual_data, sizeof (actual_data)));
 }
 
 int
@@ -156,8 +97,7 @@ main (int    argc,
   gegl_init (&argc, &argv);
   g_test_init (&argc, &argv, NULL);
 
-  ADD_TEST (basic_read);
-  ADD_TEST (basic_write);
+  ADD_TEST (basic_usage);
 
   return g_test_run ();
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]