00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "Core/precomp.h"
00016 #include <API/Core/Display/cliprect.h>
00017 #include <API/Core/Display/palette.h>
00018 #include <API/Core/Display/vidmode.h>
00019 #include <Core/Display/Generic/colormap.h>
00020 #include <Core/Display/Be/displaycard_be.h>
00021 #include <Core/Display/Generic/displaycard_generic.h>
00022 #include <Core/System/Be/app_beos.h>
00023
00024 #include "clanwindowscreen.h"
00025
00026 CL_DisplayCard_Be::CL_DisplayCard_Be(int card_no) : CL_DisplayCard_Generic(card_no)
00027 {
00028 m_palette = new CL_Palette();
00029 m_target = new CL_Target_Be();
00030
00031 clws = ((LibApplication*)be_app)->clanscreen;
00032 cl_assert(clws);
00033 }
00034
00035 CL_DisplayCard_Be::~CL_DisplayCard_Be()
00036 {
00037
00038
00039 delete m_target;
00040 delete m_palette;
00041 }
00042
00043 void CL_DisplayCard_Be::flip_display(bool sync)
00044 {
00045 signal_preflip();
00046 clws->flip_display();
00047 signal_postflip();
00048 }
00049
00050 void CL_DisplayCard_Be::put_display(const class CL_Rect &rect)
00051 {
00052 signal_preflip();
00053 clws->put_display(rect);
00054 signal_postflip();
00055 }
00056
00057 void CL_DisplayCard_Be::set_palette(CL_Palette *pal)
00058 {
00059 m_palette = new CL_Palette(pal->palette);
00060 }
00061
00062 CL_Palette *CL_DisplayCard_Be::get_palette()
00063 {
00064 return m_palette;
00065 }
00066
00067 void CL_DisplayCard_Be::set_videomode(
00068 int width,
00069 int height,
00070 int bpp,
00071 bool fullscreen,
00072 bool allow_resize,
00073 bool video_memory)
00074 {
00075 set_gfxmode(width, height, bpp, fullscreen, allow_resize);
00076 clws->set_videomode(get_width(), get_height(), bpp, fullscreen, allow_resize, video_memory);
00077 }
00078
00079 bool CL_DisplayCard_Be::is_initialized()
00080 {
00081 return true;
00082 }
00083
00084 const std::list<CL_VidMode*> &CL_DisplayCard_Be::get_videomodes()
00085 {
00086 cl_assert(false);
00087 static std::list<CL_VidMode*> modes;
00088 return modes;
00089 }
00090
00091 void CL_DisplayCard_Be::fill_rect(
00092 int x1,
00093 int y1,
00094 int x2,
00095 int y2,
00096 float r,
00097 float g,
00098 float b,
00099 float a)
00100 {
00101 if (a <= 0.01) return;
00102 if (a <= 0.99 || !clws->fill_rect_accelerated() || (!clws->is_connected()))
00103 {
00104 CL_DisplayCard_Generic::fill_rect(x1, y1, x2, y2, r, g, b, a);
00105 return;
00106 }
00107
00108 CL_ClipRect rect(x1, y1, x2, y2);
00109
00110 CL_ClipRect cur_clip = get_clip_rect();
00111 if (cur_clip.test_all_clipped(rect))
00112 {
00113 return;
00114 }
00115
00116 CL_ClipRect crect = cur_clip.clip(rect);
00117 CL_ColorMap cmap(get_target());
00118
00119 switch (m_target->get_depth())
00120 {
00121 case 8:
00122 uint8 pixelcolor8;
00123 pixelcolor8 = cmap.calc_color(r, g, b, a);
00124 clws->fill_rect8( crect.m_x1, crect.m_y1+get_height()*clws->write_frame, crect.m_x2, crect.m_y2+get_height()*clws->write_frame, pixelcolor8 );
00125 break;
00126 case 16:
00127 uint16 pixelcolor16;
00128 pixelcolor16 = cmap.calc_color(r, g, b, a);
00129 clws->fill_rect16( crect.m_x1, crect.m_y1+get_height()*clws->write_frame, crect.m_x2, crect.m_y2+get_height()*clws->write_frame, pixelcolor16 );
00130 break;
00131 case 32:
00132 uint32 pixelcolor32;
00133 pixelcolor32 = cmap.calc_color(r, g, b, a);
00134 clws->fill_rect32( crect.m_x1, crect.m_y1+get_height()*clws->write_frame, crect.m_x2, crect.m_y2+get_height()*clws->write_frame, pixelcolor32 );
00135 break;
00136 }
00137 }
00138
00139 void CL_DisplayCard_Be::clear_display(
00140 float red,
00141 float green,
00142 float blue,
00143 float alpha)
00144 {
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158 fill_rect(
00159 0,
00160 0,
00161 get_width(),
00162 get_height(),
00163 red,
00164 green,
00165 blue,
00166 alpha);
00167
00168
00169 }