1 /*
2  * Copyright 2015 Chris Young <chris@unsatisfactorysoftware.co.uk>
3  *
4  * This file is part of NetSurf, http://www.netsurf-browser.org/
5  *
6  * NetSurf is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; version 2 of the License.
9  *
10  * NetSurf is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 /** \file
20  * Abstract RTG functions for newer/older/non-P96 systems
21  */
22 
23 #include "amiga/rtg.h"
24 
ami_rtg_allocbitmap(ULONG width,ULONG height,ULONG depth,ULONG flags,struct BitMap * friend,RGBFTYPE format)25 struct BitMap *ami_rtg_allocbitmap(ULONG width, ULONG height, ULONG depth,
26 	ULONG flags, struct BitMap *friend, RGBFTYPE format)
27 {
28 	if(P96Base == NULL) {
29 #ifndef __amigaos4__
30 		if(depth > 8) depth = 8;
31 #endif
32 		return AllocBitMap(width, height, depth, flags, friend);
33 	} else {
34 		return p96AllocBitMap(width, height, depth, flags, friend, format);
35 	}
36 }
37 
ami_rtg_freebitmap(struct BitMap * bm)38 void ami_rtg_freebitmap(struct BitMap *bm)
39 {
40 	if(P96Base == NULL) {
41 		return FreeBitMap(bm);
42 	} else {
43 		return p96FreeBitMap(bm);
44 	}
45 }
46 
ami_rtg_writepixelarray(UBYTE * pixdata,struct BitMap * bm,ULONG width,ULONG height,ULONG bpr,ULONG format)47 void ami_rtg_writepixelarray(UBYTE *pixdata, struct BitMap *bm,
48 	ULONG width, ULONG height, ULONG bpr, ULONG format)
49 {
50 	struct RastPort trp;
51 
52 	InitRastPort(&trp);
53 	trp.BitMap = bm;
54 
55 	/* This requires P96 or gfx.lib v54 currently */
56 	if(P96Base == NULL) {
57 #ifdef __amigaos4__
58 		if(GfxBase->LibNode.lib_Version >= 54) {
59 			WritePixelArray(pixdata, 0, 0, bpr, PIXF_R8G8B8A8, &trp, 0, 0, width, height);
60 		}
61 #endif
62 	} else {
63 		struct RenderInfo ri;
64 
65 		ri.Memory = pixdata;
66 		ri.BytesPerRow = bpr;
67 		ri.RGBFormat = format;
68 
69 		p96WritePixelArray((struct RenderInfo *)&ri, 0, 0, &trp, 0, 0, width, height);
70 	}
71 }
72 
73