Removed SurfaceCap, added ColorCap.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2756 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
d68992bc82
commit
924b4f90f0
@ -37,11 +37,12 @@ using namespace std;
|
||||
GraphicsDriver::GraphicsDriver(BMessage *msg, PrinterData *printer_data, const PrinterCap *printer_cap)
|
||||
: __msg(msg), __printer_data(printer_data), __printer_cap(printer_cap)
|
||||
{
|
||||
__view = NULL;
|
||||
__bitmap = NULL;
|
||||
__transport = NULL;
|
||||
__org_job_data = NULL;
|
||||
__real_job_data = NULL;
|
||||
__view = NULL;
|
||||
__bitmap = NULL;
|
||||
__transport = NULL;
|
||||
__org_job_data = NULL;
|
||||
__real_job_data = NULL;
|
||||
__spool_meta_data = NULL;
|
||||
}
|
||||
|
||||
GraphicsDriver::~GraphicsDriver()
|
||||
@ -82,14 +83,18 @@ void GraphicsDriver::setupData(BFile *spool_file, long page_count)
|
||||
} else {
|
||||
__internal_copies = 1;
|
||||
}
|
||||
|
||||
__spool_meta_data = new SpoolMetaData(spool_file);
|
||||
}
|
||||
|
||||
void GraphicsDriver::cleanupData()
|
||||
{
|
||||
delete __real_job_data;
|
||||
delete __org_job_data;
|
||||
__real_job_data = NULL;
|
||||
__org_job_data = NULL;
|
||||
delete __spool_meta_data;
|
||||
__real_job_data = NULL;
|
||||
__org_job_data = NULL;
|
||||
__spool_meta_data = NULL;
|
||||
}
|
||||
|
||||
#define MAX_MEMORY_SIZE (4 *1024 *1024)
|
||||
@ -576,3 +581,74 @@ void GraphicsDriver::writeSpoolChar(char c) throw(TransportException)
|
||||
__transport->write(&c, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GraphicsDriver::rgb32_to_rgb24(void* src, void* dst, int width) {
|
||||
uint8* d = (uint8*)dst;
|
||||
rgb_color* s = (rgb_color*)src;
|
||||
for (int i = width; i > 0; i --) {
|
||||
*d ++ = s->red;
|
||||
*d ++ = s->green;
|
||||
*d ++ = s->blue;
|
||||
s++;
|
||||
}
|
||||
}
|
||||
|
||||
void GraphicsDriver::cmap8_to_rgb24(void* src, void* dst, int width) {
|
||||
uint8* d = (uint8*)dst;
|
||||
uint8* s = (uint8*)src;
|
||||
const color_map* cmap = system_colors();
|
||||
for (int i = width; i > 0; i --) {
|
||||
const rgb_color* rgb = &cmap->color_list[*s];
|
||||
*d ++ = rgb->red;
|
||||
*d ++ = rgb->green;
|
||||
*d ++ = rgb->blue;
|
||||
s ++;
|
||||
}
|
||||
}
|
||||
|
||||
void GraphicsDriver::convert_to_rgb24(void* src, void* dst, int width, color_space cs) {
|
||||
if (cs == B_RGB32) rgb32_to_rgb24(src, dst, width);
|
||||
else if (cs == B_CMAP8) cmap8_to_rgb24(src, dst, width);
|
||||
else {
|
||||
DBGMSG(("color_space %d not supported", cs));
|
||||
}
|
||||
}
|
||||
|
||||
uint8 GraphicsDriver::gray(uint8 r, uint8 g, uint8 b) {
|
||||
if (r == g && g == b) {
|
||||
return r;
|
||||
} else {
|
||||
return (r * 3 + g * 6 + b) / 10;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GraphicsDriver::rgb32_to_gray(void* src, void* dst, int width) {
|
||||
uint8* d = (uint8*)dst;
|
||||
rgb_color* s = (rgb_color*)src;
|
||||
for (int i = width; i > 0; i --) {
|
||||
*d ++ = gray(s->red, s->green, s->blue);
|
||||
s++;
|
||||
}
|
||||
}
|
||||
|
||||
void GraphicsDriver::cmap8_to_gray(void* src, void* dst, int width) {
|
||||
uint8* d = (uint8*)dst;
|
||||
uint8* s = (uint8*)src;
|
||||
const color_map* cmap = system_colors();
|
||||
for (int i = width; i > 0; i --) {
|
||||
const rgb_color* rgb = &cmap->color_list[*s];
|
||||
*d ++ = gray(rgb->red, rgb->green, rgb->blue);
|
||||
s ++;
|
||||
}
|
||||
}
|
||||
|
||||
void GraphicsDriver::convert_to_gray(void* src, void* dst, int width, color_space cs) {
|
||||
if (cs == B_RGB32) rgb32_to_gray(src, dst, width);
|
||||
else if (cs == B_CMAP8) cmap8_to_gray(src, dst, width);
|
||||
else {
|
||||
DBGMSG(("color_space %d not supported", cs));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
#include "JobData.h"
|
||||
#include "PrintProcess.h"
|
||||
#include "SpoolMetaData.h"
|
||||
#include "Transport.h"
|
||||
|
||||
class BView;
|
||||
@ -35,9 +36,13 @@ protected:
|
||||
void writeSpoolString(const char *buffer, ...) throw(TransportException);
|
||||
void writeSpoolChar(char c) throw(TransportException);
|
||||
|
||||
static void convert_to_rgb24(void* src, void* dst, int width, color_space cs);
|
||||
static void convert_to_gray(void* src, void* dst, int width, color_space cs);
|
||||
|
||||
const JobData *getJobData() const;
|
||||
const PrinterData *getPrinterData() const;
|
||||
const PrinterCap *getPrinterCap() const;
|
||||
const SpoolMetaData *getSpoolMetaData() const;
|
||||
|
||||
int getPageWidth() const;
|
||||
int getPageHeight() const;
|
||||
@ -56,6 +61,11 @@ private:
|
||||
bool printPage(PageDataList *pages);
|
||||
bool printDocument(SpoolData *spool_data);
|
||||
bool printJob(BFile *file);
|
||||
static void rgb32_to_rgb24(void* src, void* dst, int width);
|
||||
static void cmap8_to_rgb24(void* src, void* dst, int width);
|
||||
static uint8 gray(uint8 r, uint8 g, uint8 b);
|
||||
static void rgb32_to_gray(void* src, void* dst, int width);
|
||||
static void cmap8_to_gray(void* src, void* dst, int width);
|
||||
|
||||
uint32 __flags;
|
||||
BMessage *__msg;
|
||||
@ -66,6 +76,7 @@ private:
|
||||
JobData *__real_job_data;
|
||||
PrinterData *__printer_data;
|
||||
const PrinterCap *__printer_cap;
|
||||
SpoolMetaData *__spool_meta_data;
|
||||
|
||||
int __page_width;
|
||||
int __page_height;
|
||||
@ -91,6 +102,11 @@ inline const PrinterCap *GraphicsDriver::getPrinterCap() const
|
||||
return __printer_cap;
|
||||
}
|
||||
|
||||
inline const SpoolMetaData *GraphicsDriver::getSpoolMetaData() const
|
||||
{
|
||||
return __spool_meta_data;
|
||||
}
|
||||
|
||||
inline int GraphicsDriver::getPageWidth() const
|
||||
{
|
||||
return __page_width;
|
||||
|
@ -13,6 +13,7 @@ StaticLibrary print :
|
||||
PrinterData.cpp
|
||||
PrinterCap.cpp
|
||||
PrintProcess.cpp
|
||||
SpoolMetaData.cpp
|
||||
Transport.cpp
|
||||
UIDriver.cpp
|
||||
ValidRect.cpp
|
||||
|
@ -29,6 +29,7 @@ const char *JD_REVERSE = "JJJJ_reverse";
|
||||
const char *JD_PRINT_STYLE = "JJJJ_print_style";
|
||||
const char *JD_BINDING_LOCATION = "JJJJ_binding_location";
|
||||
const char *JD_PAGE_ORDER = "JJJJ_page_order";
|
||||
const char *JD_COLOR = "JJJJ_color";
|
||||
|
||||
JobData::JobData(BMessage *msg, const PrinterCap *cap)
|
||||
{
|
||||
@ -61,6 +62,7 @@ JobData::JobData(const JobData &job_data)
|
||||
__binding_location = job_data.__binding_location;
|
||||
__page_order = job_data.__page_order;
|
||||
__msg = job_data.__msg;
|
||||
__color = job_data.__color;
|
||||
}
|
||||
|
||||
JobData &JobData::operator = (const JobData &job_data)
|
||||
@ -85,6 +87,7 @@ JobData &JobData::operator = (const JobData &job_data)
|
||||
__binding_location = job_data.__binding_location;
|
||||
__page_order = job_data.__page_order;
|
||||
__msg = job_data.__msg;
|
||||
__color = job_data.__color;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -204,6 +207,11 @@ void JobData::load(BMessage *msg, const PrinterCap *cap)
|
||||
__page_order = (PAGEORDER)msg->FindInt32(JD_PAGE_ORDER);
|
||||
else
|
||||
__page_order = ACROSS_FROM_LEFT;
|
||||
|
||||
if (msg->HasBool(JD_COLOR))
|
||||
__color = msg->FindBool(JD_COLOR);
|
||||
else
|
||||
__color = false;
|
||||
}
|
||||
|
||||
void JobData::save(BMessage *msg)
|
||||
@ -306,4 +314,9 @@ void JobData::save(BMessage *msg)
|
||||
msg->ReplaceInt32(JD_PAGE_ORDER, __page_order);
|
||||
else
|
||||
msg->AddInt32(JD_PAGE_ORDER, __page_order);
|
||||
|
||||
if (msg->HasBool(JD_COLOR))
|
||||
msg->ReplaceBool(JD_COLOR, __color);
|
||||
else
|
||||
msg->AddBool(JD_COLOR, __color);
|
||||
}
|
||||
|
@ -200,12 +200,12 @@ public:
|
||||
MEDIUM = -3,
|
||||
HIGH = -4
|
||||
};
|
||||
|
||||
enum COLOR {
|
||||
MONOCHROME = 1,
|
||||
COLOR
|
||||
};
|
||||
*/
|
||||
enum COLOR {
|
||||
kMONOCHROME = 1,
|
||||
kCOLOR
|
||||
};
|
||||
|
||||
|
||||
private:
|
||||
PAPER __paper;
|
||||
@ -228,6 +228,7 @@ private:
|
||||
BINDINGLOCATION __binding_location;
|
||||
PAGEORDER __page_order;
|
||||
BMessage *__msg;
|
||||
bool __color;
|
||||
|
||||
public:
|
||||
JobData(BMessage *msg, const PrinterCap *cap);
|
||||
@ -272,7 +273,7 @@ public:
|
||||
int32 getLastPage() const { return __last_page; }
|
||||
void setLastPage(int32 last_page) { __last_page = last_page; }
|
||||
|
||||
color_space getSurfaceType() const { return __surface_type; }
|
||||
color_space getSurfaceType() const { return B_RGB32; /* __surface_type;*/ }
|
||||
void setSurfaceType(color_space surface_type) { __surface_type = surface_type; }
|
||||
|
||||
float getGamma() const { return __gamma; }
|
||||
@ -295,6 +296,9 @@ public:
|
||||
|
||||
PAGEORDER getPageOrder() const { return __page_order; }
|
||||
void setPageOrder(PAGEORDER page_order) { __page_order = page_order; }
|
||||
|
||||
COLOR getColor() const { return __color ? kCOLOR : kMONOCHROME; }
|
||||
void setColor(COLOR color) { __color = color == kCOLOR; }
|
||||
/*
|
||||
protected:
|
||||
JobData(const JobData &job_data);
|
||||
|
@ -298,9 +298,11 @@ void JobSetupView::AttachedToWindow()
|
||||
AddChild(box);
|
||||
box->SetLabel("Quality");
|
||||
|
||||
marked = false;
|
||||
/*
|
||||
// always B_RGB32
|
||||
__surface_type = new BPopUpMenu("");
|
||||
__surface_type->SetRadioMode(true);
|
||||
|
||||
count = sizeof(surfaces) / sizeof(surfaces[0]);
|
||||
const SurfaceCap **surface_cap = surfaces;
|
||||
uint32 support_flags;
|
||||
@ -317,9 +319,34 @@ void JobSetupView::AttachedToWindow()
|
||||
}
|
||||
menufield = new BMenuField(bpp_rect, "", "Surface Type", __surface_type);
|
||||
box->AddChild(menufield);
|
||||
width = StringWidth("Surface Type") + 10;
|
||||
width = StringWidth("Color") + 10;
|
||||
menufield->SetDivider(width);
|
||||
*/
|
||||
|
||||
/* color */
|
||||
marked = false;
|
||||
__color_type = new BPopUpMenu("");
|
||||
__color_type->SetRadioMode(true);
|
||||
|
||||
count = __printer_cap->countCap(PrinterCap::COLOR);
|
||||
const ColorCap **color_cap = (const ColorCap **)__printer_cap->enumCap(PrinterCap::COLOR);
|
||||
while (count--) {
|
||||
item = new BMenuItem((*color_cap)->label.c_str(), NULL);
|
||||
__color_type->AddItem(item);
|
||||
if ((*color_cap)->color == __job_data->getColor()) {
|
||||
item->SetMarked(true);
|
||||
marked = true;
|
||||
}
|
||||
color_cap++;
|
||||
}
|
||||
if (!marked && item)
|
||||
item->SetMarked(true);
|
||||
menufield = new BMenuField(bpp_rect, "", "Color", __color_type);
|
||||
|
||||
box->AddChild(menufield);
|
||||
width = StringWidth("Color") + 10;
|
||||
menufield->SetDivider(width);
|
||||
|
||||
__gamma = new BTextControl(gamma_rect, "", "Gamma", "", NULL);
|
||||
box->AddChild(__gamma);
|
||||
__gamma->SetDivider(width);
|
||||
@ -491,6 +518,7 @@ bool JobSetupView::UpdateJobData()
|
||||
{
|
||||
int count;
|
||||
|
||||
/*
|
||||
count = sizeof(surfaces) / sizeof(surfaces[0]);
|
||||
const SurfaceCap **surface_cap = surfaces;
|
||||
const char *surface_label = __surface_type->FindMarked()->Label();
|
||||
@ -501,7 +529,18 @@ bool JobSetupView::UpdateJobData()
|
||||
}
|
||||
surface_cap++;
|
||||
}
|
||||
|
||||
*/
|
||||
count = __printer_cap->countCap(PrinterCap::COLOR);
|
||||
const ColorCap **color_cap = (const ColorCap**)__printer_cap->enumCap(PrinterCap::COLOR);
|
||||
const char *color_label = __color_type->FindMarked()->Label();
|
||||
while (count--) {
|
||||
if (!strcmp((*color_cap)->label.c_str(), color_label)) {
|
||||
__job_data->setColor((*color_cap)->color);
|
||||
break;
|
||||
}
|
||||
color_cap++;
|
||||
}
|
||||
|
||||
__job_data->setGamma(atof(__gamma->Text()));
|
||||
|
||||
int first_page;
|
||||
|
@ -37,7 +37,8 @@ private:
|
||||
BRadioButton *__all;
|
||||
BCheckBox *__collate;
|
||||
BCheckBox *__reverse;
|
||||
BPopUpMenu *__surface_type;
|
||||
// BPopUpMenu *__surface_type;
|
||||
BPopUpMenu *__color_type;
|
||||
BPopUpMenu *__paper_feed;
|
||||
BCheckBox *__duplex;
|
||||
BPopUpMenu *__nup;
|
||||
|
@ -63,6 +63,12 @@ struct BindingLocationCap : public BaseCap {
|
||||
: BaseCap(n, d), binding_location(b) {}
|
||||
};
|
||||
|
||||
struct ColorCap : public BaseCap {
|
||||
JobData::COLOR color;
|
||||
ColorCap(const string &n, bool d, JobData::COLOR c)
|
||||
: BaseCap(n, d), color(c) {}
|
||||
};
|
||||
|
||||
class PrinterData;
|
||||
|
||||
class PrinterCap {
|
||||
@ -79,7 +85,8 @@ public:
|
||||
RESOLUTION,
|
||||
ORIENTATION,
|
||||
PRINTSTYLE,
|
||||
BINDINGLOCATION
|
||||
BINDINGLOCATION,
|
||||
COLOR
|
||||
};
|
||||
|
||||
virtual int countCap(CAPID) const = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user