summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kolesa <quaker66@gmail.com>2014-02-04 10:33:55 +0000
committerDaniel Kolesa <quaker66@gmail.com>2014-02-04 10:33:55 +0000
commita7ca11e49361c53e3ec0a60b9fc9f888a65900dc (patch)
tree47dd2b528c515b6314cc5c0ab8735c37dbca4164
parentcfd78f979508f2fdc9d8cbd77fedc3fc40685c07 (diff)
optimize the image data argb tests a bit
-rw-r--r--tests/image_data_argb.lua60
1 files changed, 29 insertions, 31 deletions
diff --git a/tests/image_data_argb.lua b/tests/image_data_argb.lua
index baa4428..ddba5dd 100644
--- a/tests/image_data_argb.lua
+++ b/tests/image_data_argb.lua
@@ -14,8 +14,29 @@ local weights = {
14 13.6851, 23.4462 14 13.6851, 23.4462
15} 15}
16 16
17local pixelfuncs = {
18 function(x, y, f)
19 return bor(bxor(lsh((x * y) + f, 8), x - y - f), 0xFF000000)
20 end,
21 function(x, y, f)
22 local r = (x * y / 7) + f
23 local g = x / 2
24 local b = y / 2
25 local a = x + y
26 r = band(r, 0xFF)
27 g = band(g, 0xFF)
28 b = band(b, 0xFF)
29 a = band(a, 0xFF)
30 r = (a * r) / 255
31 g = (a * g) / 255
32 b = (a * b) / 255
33 return bor(lsh(a, 24), lsh(r, 16), lsh(g, 8), b)
34 end
35}
36
17return function(ui, variant) 37return function(ui, variant)
18 local image 38 local image
39 local pixelfunc = pixelfuncs[variant]
19 return "data.png", names[variant], weights[variant], function() 40 return "data.png", names[variant], weights[variant], function()
20 local win_w, win_h = ui.win_w, ui.win_h 41 local win_w, win_h = ui.win_w, ui.win_h
21 ui.func_set(function() 42 ui.func_set(function()
@@ -23,41 +44,18 @@ return function(ui, variant)
23 end, function(t, f) 44 end, function(t, f)
24 local w = 640 45 local w = 640
25 local h = 480 46 local h = 480
26 local st, data
27 local x = (win_w / 2) - (w / 2) 47 local x = (win_w / 2) - (w / 2)
28 local y = (win_h / 2) - (h / 2) 48 local y = (win_h / 2) - (h / 2)
29 if image then 49 levas.evas_object_move(image, x, y)
30 levas.evas_object_move(image, x, y) 50 levas.evas_object_resize(image, w, h)
31 levas.evas_object_resize(image, w, h) 51 levas.evas_object_image_fill_set(image, 0, 0, w, h)
32 levas.evas_object_image_fill_set(image, 0, 0, w, h) 52 local data = ffi_cast("unsigned int*",
33 data = ffi_cast("unsigned int*", 53 levas.evas_object_image_data_get(image, 1))
34 levas.evas_object_image_data_get(image, 1)) 54 local st = rsh(levas.evas_object_image_stride_get(image), 2)
35 st = levas.evas_object_image_stride_get(image)
36 end
37 st = rsh(st, 2)
38 local p = data 55 local p = data
39 for y = 0, h - 1 do 56 for y = 0, h - 1 do
40 for x = 0, w - 1 do 57 for x = 0, w - 1 do p[x] = pixelfunc(x, y, f) end
41 if variant == 2 then 58 p = p + st
42 local r = (x * y / 7) + f
43 local g = x / 2
44 local b = y / 2
45 local a = x + y
46 r = band(r, 0xFF)
47 g = band(g, 0xFF)
48 b = band(b, 0xFF)
49 a = band(a, 0xFF)
50 r = (a * r) / 255
51 g = (a * g) / 255
52 b = (a * b) / 255
53 p[0] = bor(lsh(a, 24), lsh(r, 16), lsh(g, 8), b)
54 else
55 p[0] = bor(bxor(lsh((x * y) + f, 8), x - y - f),
56 0xFF000000)
57 end
58 p = p + 1
59 end
60 p = p + (st - w)
61 end 59 end
62 levas.evas_object_image_data_set(image, data) 60 levas.evas_object_image_data_set(image, data)
63 levas.evas_object_image_data_update_add(image, 0, 0, w, h) 61 levas.evas_object_image_data_update_add(image, 0, 0, w, h)