diff TaskManager/Test/test_render/spe/DrawSpan.cpp @ 156:cd5ad7adc5e1

fix
author gongo@gendarme.local
date Thu, 04 Dec 2008 14:25:00 +0900
parents 77dac07efd79
children 1f4c3f3238e6
line wrap: on
line diff
--- a/TaskManager/Test/test_render/spe/DrawSpan.cpp	Thu Dec 04 13:58:41 2008 +0900
+++ b/TaskManager/Test/test_render/spe/DrawSpan.cpp	Thu Dec 04 14:25:00 2008 +0900
@@ -104,32 +104,15 @@
 }
 
 Uint32
-DrawSpan::get_rgb(int tx, int ty, int tw, int th, void *texture)
+DrawSpan::get_rgb(int tx, int ty, void *addr)
 {
     Uint8 red, green, blue, alpha;
-
-    if (tx<0) tx = 0;
-    if (tw-1< tx) tx = tw-1 ;
-    if (ty<0) ty = 0;
-    if (th-1< ty) ty = th-1 ;
-
-    void *texture_addr;
     TilePtr tile;
 
-#if 0
-    int blockX = tx / TEXTURE_SPLIT_PIXEL;
-    int blockY = ty / TEXTURE_SPLIT_PIXEL;
-    void** addrList = (void**)global_get(TEXTURE2_ID);
-
-    texture_addr = addrList[blockX + (tw/TEXTURE_SPLIT_PIXEL)*blockY];
-#else
-    texture_addr = texture;
-#endif
-
     /**
      * get,put はオブジェクト(Hashとか?)を作ってアクセスするかな
      */
-    tile = get(texture_addr);
+    tile = get(addr);
     if (tile == NULL) {
 	if (tileList->size >= MAX_TILE) {
 	    tileList->init();
@@ -137,9 +120,9 @@
 	}
 
 	tile = &tileList->tile[tileList->size];
-	tile->texture_addr = texture_addr;
+	tile->texture_addr = addr;
 
-	smanager->dma_load(tile->pixel, (uint32)texture_addr,
+	smanager->dma_load(tile->pixel, (uint32)addr,
 			   sizeof(uint32)*64, TEX_LOAD);
 
 	int index = put(tile->texture_addr, tile);
@@ -159,8 +142,7 @@
 	smanager->dma_wait(TEX_LOAD);
     }
 
-    char *p = get_pixel(tx%TEXTURE_SPLIT_PIXEL,
-			ty%TEXTURE_SPLIT_PIXEL, tile->pixel);
+    char *p = get_pixel(tx, ty, tile->pixel);
     
     alpha = 255;
     red   = (Uint8) p[0];
@@ -254,26 +236,18 @@
 		    continue;
 		}
 
+#if 1
+		tex_xpos = tilist->tileinfo[0].tix;
+		tex_ypos = tilist->tileinfo[0].tiy;
+		texture_image = tilist->tileinfo[0].tile;
+#else
 		tex_xpos = (int)((span->tex_width-1) * tex1);
 		tex_ypos = (int)((span->tex_height-1) * tey1);
 		tex_zpos = (int)z;
+#endif					
 
-#if 1
-		if (tex_xpos != tilist->tileinfo[0].tix
-		    && tex_xpos != tilist->tileinfo[0].tix) {
-		    fprintf(stderr, "1: (%3d, %3d), (%3d, %3d)\n",
-			    tex_xpos, tex_ypos, tilist->tileinfo[0].tix,
-			    tilist->tileinfo[0].tiy);
-		}
-#endif
-
-		tex_xpos = tilist->tileinfo[0].tix;
-		tex_ypos = tilist->tileinfo[0].tiy;
-		texture_image = tilist->tileinfo[0].tile;
-					
 		if (zpos < zRow[localx + (rangex * localy)]) {
-		    rgb = get_rgb(tex_xpos, tex_ypos, span->tex_width,
-				  span->tex_height, texture_image);
+		    rgb = get_rgb(tex_xpos, tex_ypos, texture_image);
 		    zRow[localx + (rangex * localy)] = zpos;
 		    linebuf[localy][localx] = rgb;
 		}
@@ -330,34 +304,25 @@
 		    float tex_x, tex_y, tex_z;
 
 		    for (int j = cur_x; j <= cur_x + len; j++) {
+			TileInfoPtr tinfo = &tilist->tileinfo[j%MAX_TILE_LIST];
 			localx = getLocalX(x-1+j);
 			tex_z = z*(x_len-1-j)/(x_len-1) + zpos*j/(x_len-1);
-			
+
+#if 1
+			tex_xpos = tinfo->tix;
+			tex_ypos = tinfo->tiy;
+			texture_image = tinfo->tile;
+#else
 			tex_x = tex1*(x_len-1-j)/(x_len-1) + tex2*j/(x_len-1);
 			tex_y = tey1*(x_len-1-j)/(x_len-1) + tey2*j/(x_len-1);
 			if (tex_x > 1) tex_x = 1;
 			if (tex_y > 1) tex_y = 1;
 			tex_xpos = (int)((span->tex_width-1) * tex_x);
 			tex_ypos = (int)((span->tex_height-1) * tex_y);
+#endif
 
-			if (tex_xpos != tilist->tileinfo[j%MAX_TILE_LIST].tix
-			    && tex_xpos != tilist->tileinfo[j%MAX_TILE_LIST].tix)  {
-			    fprintf(stderr, "size = %d\n", tilist->size);
-			    fprintf(stderr, "(%3d ..%3d) %d, %d %d\n",
-				    x, x + x_len, js, max_x, j%MAX_TILE_LIST);
-			    fprintf(stderr, "(%3d, %3d), (%3d, %3d)\n",
-				    tex_xpos, tex_ypos,
-				    tilist->tileinfo[j%MAX_TILE_LIST].tix,
-				    tilist->tileinfo[j%MAX_TILE_LIST].tiy);
-			}
-
-			tex_xpos = tilist->tileinfo[j%MAX_TILE_LIST].tix;
-			tex_ypos = tilist->tileinfo[j%MAX_TILE_LIST].tiy;
-			texture_image = tilist->tileinfo[j%MAX_TILE_LIST].tile;
-			
 			if (tex_z < zRow[localx + (rangex*localy)]) {
-			    rgb = get_rgb(tex_xpos, tex_ypos, span->tex_width,
-					  span->tex_height, texture_image);
+			    rgb = get_rgb(tex_xpos, tex_ypos, texture_image);
 			    zRow[localx + (rangex*localy)] = tex_z;
 			    linebuf[localy][localx] = rgb;
 			}