haiku/headers/private/servers/app/DrawingEngine.h

169 lines
4.2 KiB
C
Raw Normal View History

/*
* Copyright 2001-2005, Haiku, Inc.
* Distributed under the terms of the MIT License.
*
* Authors:
* DarkWyrm <bpmagic@columbus.rr.com>
* Gabe Yoder <gyoder@stny.rr.com>
* Stephan Aßmus <superstippi@gmx.de>
*/
#ifndef DRAWING_ENGINE_H_
#define DRAWING_ENGINE_H_
#include <Accelerant.h>
#include <Font.h>
#include <Locker.h>
#include <Point.h>
class BPoint;
class BRect;
class BRegion;
class DrawState;
class HWInterface;
class Painter;
class RGBColor;
class ServerBitmap;
class ServerCursor;
class ServerFont;
typedef struct {
BPoint pt1;
BPoint pt2;
rgb_color color;
} LineArrayData;
class DrawingEngine {
public:
DrawingEngine(HWInterface* interface = NULL);
virtual ~DrawingEngine();
// when implementing, be sure to call the inherited version
status_t Initialize();
void Shutdown();
// locking
bool Lock();
void Unlock();
bool WriteLock();
void WriteUnlock();
// for "changing" hardware
void Update();
void SetHWInterface(HWInterface* interface);
offscreen bitmaps work, tested on Haiku as well, supports all colorspaces that BBitmap::ImportBits() supports. It uses a fallback for non-B_RGB(A)32 bitmaps. Added support for B_SUB_PIXEL_PRECISION view flags, though it is a bit hacky, since I had to add it to LayerData, even though it is not a true part of stack data. Added Layer::SetFlags() to enforce code path and update fLayerData. Cleaned up DisplayDriverPainter and DisplayDriver API (changed some const BRect& rect to simply BRect rect in order to be able to reuse it in the code), moved Painter.h, the test environment only draws the changed part of the frame buffer again - this causes a lot less CPU overhead, Painter special cases stroke width of 1.0 to use square caps, which is similar to R5 implementation and removes a lot of problems with non-straight line drawing, ServerWindow uses the DisplayDriver from it's WinBorder instead of the one from the Desktop (needed for offscreen windows, which have their own DisplayDriverPainter), it also checks for GetRootLayer() == NULL, because offscreen layers are not attached to a RootLayer, there was a fix for scrolling which worked at least in the test environment, it is now defunced, because Adi moved _CopyBits to Layer... I need to reenable it later, LayerData has no more fEscapementDelta, also fixed fFontAliasing (which was thought to overriding the font flags, and now works as such again), Desktop initialises the menu_info and scroll_bar_info stuff, which makes ScrollBars work actually... hope I didn't forget something. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13448 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-07-05 20:17:16 +04:00
// for screen shots
bool DumpToFile(const char *path);
ServerBitmap* DumpToBitmap();
// clipping for all drawing functions, passing a NULL region
// will remove any clipping (drawing allowed everywhere)
void ConstrainClippingRegion(const BRegion* region);
// drawing functions
void CopyRegion(/*const*/ BRegion* region,
int32 xOffset, int32 yOffset);
void InvertRect(BRect r);
void DrawBitmap(ServerBitmap *bitmap,
const BRect &source, const BRect &dest,
const DrawState *d);
// drawing primitives
void DrawArc(BRect r, const float &angle,
const float &span,
const DrawState *d,
bool filled);
void DrawBezier(BPoint *pts, const DrawState *d,
bool filled);
void DrawEllipse(BRect r, const DrawState *d,
bool filled);
void DrawPolygon(BPoint *ptlist, int32 numpts,
BRect bounds, const DrawState *d,
bool filled, bool closed);
// this version used by Decorator
void StrokeRect(BRect r, const RGBColor &color);
void FillRect(BRect r, const RGBColor &color);
void StrokeRect(BRect r, const DrawState *d);
void FillRect(BRect r, const DrawState *d);
// for debugging purposes?
// void StrokeRegion(BRegion &r, const DrawState *d);
void FillRegion(BRegion &r, const DrawState *d);
void FillRegion(BRegion &r, const RGBColor& color);
void DrawRoundRect(BRect r, float xrad,
float yrad, const DrawState *d,
bool filled);
void DrawShape(const BRect &bounds,
int32 opcount, const uint32 *oplist,
int32 ptcount, const BPoint *ptlist,
const DrawState *d, bool filled);
void DrawTriangle(BPoint *pts, const BRect &bounds,
const DrawState *d, bool filled);
// this version used by Decorator
void StrokeLine(const BPoint &start,
const BPoint &end, const RGBColor &color);
void StrokeLine(const BPoint &start,
const BPoint &end, DrawState *d);
void StrokeLineArray(int32 numlines,
const LineArrayData *data,
const DrawState *d);
// this version used by Decorator
void StrokePoint(const BPoint &pt,
const RGBColor &color);
void StrokePoint(const BPoint &pt,
DrawState *d);
// -------- text related calls
// DrawState is NOT const because this call updates the pen position in the passed DrawState
BPoint DrawString(const char* string, int32 length,
const BPoint& pt, DrawState* d,
escapement_delta* delta = NULL);
float StringWidth(const char* string, int32 length,
const DrawState* d,
escapement_delta* delta = NULL);
float StringWidth(const char* string,
int32 length, const ServerFont& font,
escapement_delta* delta = NULL);
float StringHeight(const char* string,
int32 length, const DrawState* d);
private:
BRect _CopyRect(BRect r, int32 xOffset,
int32 yOffset) const;
void _CopyRect(uint8* bits, uint32 width,
uint32 height, uint32 bytesPerRow,
int32 xOffset, int32 yOffset) const;
Painter* fPainter;
HWInterface* fGraphicsCard;
uint32 fAvailableHWAccleration;
};
#endif // DRAWING_ENGINE_H_