2 // Copyright (C) 2010 Free Software Foundation, Inc
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 3 of the License, or
7 // (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 #include "gnashconfig.h"
30 #include <boost/assign/list_of.hpp>
34 #include "GnashDevice.h"
35 #include "RawFBDevice.h"
39 using namespace gnash
;
41 using namespace renderer
;
43 // The debug log used by all the gnash libraries.
44 static LogFile
& dbglogfile
= LogFile::getDefaultInstance();
47 unsigned short red
[256], green
[256], blue
[256];
48 struct fb_cmap map332
= {0, 256, red
, green
, blue
, NULL
};
49 unsigned short red_b
[256], green_b
[256], blue_b
[256];
50 struct fb_cmap map_back
= {0, 256, red_b
, green_b
, blue_b
, NULL
};
53 main(int argc
, char *argv
[])
55 // FIXME: for now, always run verbose till this supports command line args
56 dbglogfile
.setVerbosity();
58 rawfb::RawFBDevice rfb
;
60 if (!rfb
.initDevice(argc
, argv
)) {
61 runtest
.fail("RawFBDevice:InitDevice()");
63 runtest
.pass("RawFBDevice:InitDevice()");
66 bool ret
= rfb
.attachWindow(rfb
.getHandle());
67 if (rfb
.getFBMemory()) {
68 runtest
.pass("RawFBDevice::attachWindow()");
70 runtest
.fail("RawFBDevice::attachWindow()");
73 #ifdef ENABLE_DOUBLE_BUFFERING
74 if (rfb
.getOffscreenBuffer()) {
75 runtest
.pass("RawFBDevice::getOffscreenBuffer()");
77 runtest
.fail("RawFBDevice::getOffscreenBuffer()");
81 if (ret
&& rfb
.getStride()) {
82 runtest
.pass("RawFBDevice::getStride()");
84 runtest
.fail("RawFBDevice::getStride()");
87 if (ret
&& rfb
.getWidth()) {
88 runtest
.pass("RawFBDevice::getWidth()");
90 runtest
.fail("RawFBDevice::getWidth()");
93 if (ret
&& rfb
.getHeight()) {
94 runtest
.pass("RawFBDevice::getHeight()");
96 runtest
.fail("DirecTFBDevice::getHeight()");
99 if (ret
&& rfb
.isSingleBuffered()) {
100 runtest
.pass("RawFBDevice::is*Buffered()");
102 runtest
.fail("RawFBDevice::is*Buffered()");
105 if (ret
&& rfb
.getDepth()) {
106 runtest
.pass("RawFBDevice::getDepth()");
108 runtest
.fail("RawFBDevice::getDepth()");
111 if (ret
&& rfb
.getRedSize() > 0) {
112 runtest
.pass("RawFBDevice::getRedSize()");
114 runtest
.fail("RawFBDevice::getRedSize()");
117 if (ret
&& rfb
.getGreenSize() > 0) {
118 runtest
.pass("RawFBDevice::getGreenSize()");
120 runtest
.fail("RawFBDevice::getGreenSize()");
123 if (ret
&& rfb
.getBlueSize() > 0) {
124 runtest
.pass("RawFBDevice::getBlueSize()");
126 runtest
.fail("RawFBDevice::getBlueSize()");
130 if (rfb
.setGrayscaleLUT8()) {
131 runtest
.pass("RawFBDevice::setGrayscaleLUT8()");
133 runtest
.fail("RawFBDevice::setGrayscaleLUT8()");
137 // AGG uses these to calculate the poixel format
139 if (ret
&& rfb
.getRedOffset() > 0) {
140 runtest
.pass("RawFBDevice::getRedOffset()");
142 runtest
.fail("RawFBDevice::getRedOffset()");
145 if (ret
&& rfb
.getGreenOffset() > 0) {
146 runtest
.pass("RawFBDevice::getGreenOffset()");
148 runtest
.fail("RawFBDevice::getGreenOffset()");
151 if (ret
&& rfb
.getBlueOffset() == 0) {
152 runtest
.pass("RawFBDevice::getBlueOffset()");
154 runtest
.fail("RawFBDevice::getBlueOffset()");
158 // This is a manual test to see if we can draw a line on the
159 // raw framebuffer to make sure it got initialized correctly.
162 int line_length
= rfb
.getWidth() * ((rfb
.getDepth()+7)/8);
164 boost::uint8_t *fbp
= rfb
.getFBMemory();
166 for(y
=100; y
<102; y
++); /* Where we are going to put the pixel */
168 for(x
=0; x
<200; x
++) {
169 /* Figure out where in memory to put the pixel */
170 location
= x
* (rfb
.getDepth()/8) + y
* line_length
;
172 *(fbp
+ location
) = 89; /* Some blue */
173 *(fbp
+ location
+ 1) = 40; /* A little green */
174 *(fbp
+ location
+ 2) = 200; /* A lot of red */
175 *(fbp
+ location
+ 3) = 0; /* No transparency */
182 // indent-tabs-mode: nil