* Bug fixed: WriteSpoolData didn't pass data to
transport add-on because ";" was missing after "return" statement. * Removed unused getter methods from class GraphicsDriver. * Implemented page rotation (closes #6965) in landscape. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39800 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -22,11 +22,6 @@ class PrinterData;
|
|||||||
class PrinterCap;
|
class PrinterCap;
|
||||||
|
|
||||||
|
|
||||||
enum {
|
|
||||||
kGDFRotateBandBitmap = 1
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class GraphicsDriver {
|
class GraphicsDriver {
|
||||||
public:
|
public:
|
||||||
GraphicsDriver(BMessage* message, PrinterData* printerData,
|
GraphicsDriver(BMessage* message, PrinterData* printerData,
|
||||||
@@ -34,7 +29,7 @@ public:
|
|||||||
virtual ~GraphicsDriver();
|
virtual ~GraphicsDriver();
|
||||||
|
|
||||||
const JobData* GetJobData(BFile* spoolFile);
|
const JobData* GetJobData(BFile* spoolFile);
|
||||||
BMessage* TakeJob(BFile* spoolFile, uint32 flags = 0);
|
BMessage* TakeJob(BFile* spoolFile);
|
||||||
static BPoint GetScale(int32 nup, BRect physicalRect, float scaling);
|
static BPoint GetScale(int32 nup, BRect physicalRect, float scaling);
|
||||||
static BPoint GetOffset(int32 nup, int index,
|
static BPoint GetOffset(int32 nup, int index,
|
||||||
JobData::Orientation orientation, const BPoint* scale,
|
JobData::Orientation orientation, const BPoint* scale,
|
||||||
@@ -70,11 +65,7 @@ protected:
|
|||||||
const SpoolMetaData* GetSpoolMetaData() const;
|
const SpoolMetaData* GetSpoolMetaData() const;
|
||||||
int GetProtocolClass() const;
|
int GetProtocolClass() const;
|
||||||
|
|
||||||
int GetPageWidth() const;
|
|
||||||
int GetPageHeight() const;
|
int GetPageHeight() const;
|
||||||
int GetBandWidth() const;
|
|
||||||
int GetBandHeight() const;
|
|
||||||
int GetPixelDepth() const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool _SetupData(BFile* file);
|
bool _SetupData(BFile* file);
|
||||||
@@ -82,20 +73,25 @@ private:
|
|||||||
void _CleanupData();
|
void _CleanupData();
|
||||||
void _CleanupBitmap();
|
void _CleanupBitmap();
|
||||||
bool _PrintPage(PageDataList* pages);
|
bool _PrintPage(PageDataList* pages);
|
||||||
|
bool _PrintBand(BBitmap* band, BPoint* offset);
|
||||||
|
void _RotateInto(BBitmap* target, const BBitmap* source);
|
||||||
bool _CollectPages(SpoolData* spoolData, PageDataList* pages);
|
bool _CollectPages(SpoolData* spoolData, PageDataList* pages);
|
||||||
bool _SkipPages(SpoolData* spoolData);
|
bool _SkipPages(SpoolData* spoolData);
|
||||||
bool _PrintDocument(SpoolData* spoolData);
|
bool _PrintDocument(SpoolData* spoolData);
|
||||||
bool PrintJob(BFile* file);
|
bool _PrintJob(BFile* file);
|
||||||
|
|
||||||
|
bool _NeedRotateBitmapBand() const;
|
||||||
|
|
||||||
static void _ConvertRGB32ToRGB24(const void* src, void* dst, int width);
|
static void _ConvertRGB32ToRGB24(const void* src, void* dst, int width);
|
||||||
static void _ConvertCMAP8ToRGB24(const void* src, void* dst, int width);
|
static void _ConvertCMAP8ToRGB24(const void* src, void* dst, int width);
|
||||||
static uint8 _ConvertToGray(uint8 r, uint8 g, uint8 b);
|
static uint8 _ConvertToGray(uint8 r, uint8 g, uint8 b);
|
||||||
static void _ConvertRGB32ToGray(const void* src, void* dst, int width);
|
static void _ConvertRGB32ToGray(const void* src, void* dst, int width);
|
||||||
static void _ConvertCMAP8ToGray(const void* src, void* dst, int width);
|
static void _ConvertCMAP8ToGray(const void* src, void* dst, int width);
|
||||||
|
|
||||||
uint32 fFlags;
|
|
||||||
BMessage* fMessage;
|
BMessage* fMessage;
|
||||||
BView* fView;
|
BView* fView;
|
||||||
BBitmap* fBitmap;
|
BBitmap* fBitmap;
|
||||||
|
BBitmap* fRotatedBitmap;
|
||||||
Transport* fTransport;
|
Transport* fTransport;
|
||||||
JobData* fOrgJobData;
|
JobData* fOrgJobData;
|
||||||
JobData* fRealJobData;
|
JobData* fRealJobData;
|
||||||
@@ -153,31 +149,11 @@ GraphicsDriver::GetProtocolClass() const
|
|||||||
|
|
||||||
|
|
||||||
inline int
|
inline int
|
||||||
GraphicsDriver::GetPageWidth() const
|
GraphicsDriver::GetPageHeight() const
|
||||||
{
|
{
|
||||||
|
if (!_NeedRotateBitmapBand())
|
||||||
|
return fPageHeight;
|
||||||
return fPageWidth;
|
return fPageWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline int
|
|
||||||
GraphicsDriver::GetPageHeight() const
|
|
||||||
{
|
|
||||||
return fPageHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline int
|
|
||||||
GraphicsDriver::GetBandWidth() const
|
|
||||||
{
|
|
||||||
return fBandWidth;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline int
|
|
||||||
GraphicsDriver::GetBandHeight() const
|
|
||||||
{
|
|
||||||
return fBandHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* __GRAPHICSDRIVER_H */
|
#endif /* __GRAPHICSDRIVER_H */
|
||||||
|
|||||||
@@ -200,10 +200,13 @@ public:
|
|||||||
kDriverSpecificCapabilities,
|
kDriverSpecificCapabilities,
|
||||||
|
|
||||||
// Static boolean settings follow.
|
// Static boolean settings follow.
|
||||||
// For them isSupport() has to be implemented only.
|
// For them Supports() has to be implemented only.
|
||||||
kCopyCommand, // supports printer page copy command?
|
kCopyCommand, // supports printer page copy command?
|
||||||
kHalftone, // needs the printer driver the configuration
|
kHalftone, // needs the printer driver the configuration
|
||||||
// for class Halftone?
|
// for class Halftone?
|
||||||
|
kCanRotatePageInLandscape,
|
||||||
|
// can the printer driver rotate the page
|
||||||
|
// printing in landscape
|
||||||
|
|
||||||
// The driver specific generic capabilities start here
|
// The driver specific generic capabilities start here
|
||||||
kDriverSpecificCapabilitiesBegin = 100
|
kDriverSpecificCapabilitiesBegin = 100
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
#include <Alert.h>
|
#include <Alert.h>
|
||||||
#include <Bitmap.h>
|
#include <Bitmap.h>
|
||||||
|
#include <Debug.h>
|
||||||
#include <Message.h>
|
#include <Message.h>
|
||||||
#include <PrintJob.h>
|
#include <PrintJob.h>
|
||||||
#include <Region.h>
|
#include <Region.h>
|
||||||
@@ -45,10 +46,10 @@ enum {
|
|||||||
GraphicsDriver::GraphicsDriver(BMessage* message, PrinterData* printerData,
|
GraphicsDriver::GraphicsDriver(BMessage* message, PrinterData* printerData,
|
||||||
const PrinterCap* printerCap)
|
const PrinterCap* printerCap)
|
||||||
:
|
:
|
||||||
fFlags(0),
|
|
||||||
fMessage(message),
|
fMessage(message),
|
||||||
fView(NULL),
|
fView(NULL),
|
||||||
fBitmap(NULL),
|
fBitmap(NULL),
|
||||||
|
fRotatedBitmap(NULL),
|
||||||
fTransport(NULL),
|
fTransport(NULL),
|
||||||
fOrgJobData(NULL),
|
fOrgJobData(NULL),
|
||||||
fRealJobData(NULL),
|
fRealJobData(NULL),
|
||||||
@@ -182,8 +183,7 @@ GraphicsDriver::_SetupBitmap()
|
|||||||
fBandHeight = fPageHeight;
|
fBandHeight = fPageHeight;
|
||||||
} else {
|
} else {
|
||||||
fBandCount = (size + kMaxMemorySize - 1) / kMaxMemorySize;
|
fBandCount = (size + kMaxMemorySize - 1) / kMaxMemorySize;
|
||||||
if ((JobData::kLandscape == fRealJobData->GetOrientation())
|
if (_NeedRotateBitmapBand()) {
|
||||||
&& (fFlags & kGDFRotateBandBitmap)) {
|
|
||||||
fBandWidth = (fPageWidth + fBandCount - 1) / fBandCount;
|
fBandWidth = (fPageWidth + fBandCount - 1) / fBandCount;
|
||||||
fBandHeight = fPageHeight;
|
fBandHeight = fPageHeight;
|
||||||
} else {
|
} else {
|
||||||
@@ -204,6 +204,12 @@ GraphicsDriver::_SetupBitmap()
|
|||||||
fBitmap = new BBitmap(rect, fOrgJobData->GetSurfaceType(), true);
|
fBitmap = new BBitmap(rect, fOrgJobData->GetSurfaceType(), true);
|
||||||
fView = new BView(rect, "", B_FOLLOW_ALL, B_WILL_DRAW);
|
fView = new BView(rect, "", B_FOLLOW_ALL, B_WILL_DRAW);
|
||||||
fBitmap->AddChild(fView);
|
fBitmap->AddChild(fView);
|
||||||
|
|
||||||
|
if (_NeedRotateBitmapBand()) {
|
||||||
|
BRect rotatedRect(0, 0, rect.bottom, rect.right);
|
||||||
|
fRotatedBitmap = new BBitmap(rotatedRect, fOrgJobData->GetSurfaceType(),
|
||||||
|
false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -213,6 +219,9 @@ GraphicsDriver::_CleanupBitmap()
|
|||||||
delete fBitmap;
|
delete fBitmap;
|
||||||
fBitmap = NULL;
|
fBitmap = NULL;
|
||||||
fView = NULL;
|
fView = NULL;
|
||||||
|
|
||||||
|
delete fRotatedBitmap;
|
||||||
|
fRotatedBitmap = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -460,7 +469,7 @@ GraphicsDriver::_PrintPage(PageDataList* pages)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!NextBand(fBitmap, &offset))
|
if (!_PrintBand(fBitmap, &offset))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
} while (offset.x >= 0.0f && offset.y >= 0.0f);
|
} while (offset.x >= 0.0f && offset.y >= 0.0f);
|
||||||
@@ -469,6 +478,57 @@ GraphicsDriver::_PrintPage(PageDataList* pages)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
GraphicsDriver::_PrintBand(BBitmap* band, BPoint* offset)
|
||||||
|
{
|
||||||
|
if (!_NeedRotateBitmapBand())
|
||||||
|
return NextBand(band, offset);
|
||||||
|
|
||||||
|
_RotateInto(fRotatedBitmap, band);
|
||||||
|
|
||||||
|
BPoint rotatedOffset(offset->y, offset->x);
|
||||||
|
bool success = NextBand(fRotatedBitmap, &rotatedOffset);
|
||||||
|
offset->x = rotatedOffset.y;
|
||||||
|
offset->y = rotatedOffset.x;
|
||||||
|
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
GraphicsDriver::_RotateInto(BBitmap* target, const BBitmap* source)
|
||||||
|
{
|
||||||
|
ASSERT(target->ColorSpace() == B_RGB32);
|
||||||
|
ASSERT(source->ColorSpace() == B_RGB32);
|
||||||
|
ASSERT(target->Bounds().IntegerWidth() == source->Bounds().IntegerHeight());
|
||||||
|
ASSERT(target->Bounds().IntegerHeight() == source->Bounds().IntegerWidth());
|
||||||
|
|
||||||
|
const int32 width = source->Bounds().IntegerWidth() + 1;
|
||||||
|
const int32 height = source->Bounds().IntegerHeight() + 1;
|
||||||
|
|
||||||
|
const int32 sourceBPR = source->BytesPerRow();
|
||||||
|
const int32 targetBPR = target->BytesPerRow();
|
||||||
|
|
||||||
|
const uint8_t* sourceBits =
|
||||||
|
reinterpret_cast<const uint8_t*>(source->Bits());
|
||||||
|
uint8_t* targetBits = static_cast<uint8_t*>(target->Bits());
|
||||||
|
|
||||||
|
for (int32 y = 0; y < height; y ++) {
|
||||||
|
for (int32 x = 0; x < width; x ++) {
|
||||||
|
const uint32_t* sourcePixel =
|
||||||
|
reinterpret_cast<const uint32_t*>(sourceBits + sourceBPR * y
|
||||||
|
+ sizeof(uint32_t) * x);
|
||||||
|
|
||||||
|
int32 targetX = (height - y - 1);
|
||||||
|
int32 targetY = x;
|
||||||
|
uint32_t* targetPixel =
|
||||||
|
reinterpret_cast<uint32_t*>(targetBits + targetBPR * targetY
|
||||||
|
+ sizeof(uint32_t) * targetX);
|
||||||
|
*targetPixel = *sourcePixel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
GraphicsDriver::_CollectPages(SpoolData* spoolData, PageDataList* pages)
|
GraphicsDriver::_CollectPages(SpoolData* spoolData, PageDataList* pages)
|
||||||
{
|
{
|
||||||
@@ -595,7 +655,7 @@ GraphicsDriver::GetJobData(BFile* spoolFile)
|
|||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
GraphicsDriver::PrintJob(BFile* spoolFile)
|
GraphicsDriver::_PrintJob(BFile* spoolFile)
|
||||||
{
|
{
|
||||||
bool success = true;
|
bool success = true;
|
||||||
if (!_SetupData(spoolFile)) {
|
if (!_SetupData(spoolFile)) {
|
||||||
@@ -653,11 +713,10 @@ GraphicsDriver::PrintJob(BFile* spoolFile)
|
|||||||
|
|
||||||
|
|
||||||
BMessage*
|
BMessage*
|
||||||
GraphicsDriver::TakeJob(BFile* spoolFile, uint32 flags)
|
GraphicsDriver::TakeJob(BFile* spoolFile)
|
||||||
{
|
{
|
||||||
fFlags = flags;
|
|
||||||
BMessage *msg;
|
BMessage *msg;
|
||||||
if (PrintJob(spoolFile))
|
if (_PrintJob(spoolFile))
|
||||||
msg = new BMessage('okok');
|
msg = new BMessage('okok');
|
||||||
else
|
else
|
||||||
msg = new BMessage('baad');
|
msg = new BMessage('baad');
|
||||||
@@ -705,8 +764,7 @@ GraphicsDriver::WriteSpoolData(const void* buffer, size_t size)
|
|||||||
throw (TransportException)
|
throw (TransportException)
|
||||||
{
|
{
|
||||||
if (fTransport == NULL)
|
if (fTransport == NULL)
|
||||||
return
|
return;
|
||||||
|
|
||||||
fTransport->Write(buffer, size);
|
fTransport->Write(buffer, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -738,6 +796,14 @@ GraphicsDriver::WriteSpoolChar(char c)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
GraphicsDriver::_NeedRotateBitmapBand() const
|
||||||
|
{
|
||||||
|
return JobData::kLandscape == fRealJobData->GetOrientation()
|
||||||
|
&& !fPrinterCap->Supports(PrinterCap::kCanRotatePageInLandscape);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
GraphicsDriver::_ConvertRGB32ToRGB24(const void* src, void* dst, int width) {
|
GraphicsDriver::_ConvertRGB32ToRGB24(const void* src, void* dst, int width) {
|
||||||
uint8* d = (uint8*)dst;
|
uint8* d = (uint8*)dst;
|
||||||
|
|||||||
Reference in New Issue
Block a user