2005-11-04 14:37:28 +03:00
|
|
|
/*
|
|
|
|
* 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>
|
|
|
|
*/
|
2005-11-04 18:54:16 +03:00
|
|
|
#ifndef DRAWING_ENGINE_H_
|
|
|
|
#define DRAWING_ENGINE_H_
|
2005-03-26 01:46:10 +03:00
|
|
|
|
2005-11-04 14:37:28 +03:00
|
|
|
|
2005-11-04 18:23:54 +03:00
|
|
|
#include <Accelerant.h>
|
|
|
|
#include <Font.h>
|
|
|
|
#include <Locker.h>
|
|
|
|
#include <Point.h>
|
2005-03-26 01:46:10 +03:00
|
|
|
|
2005-11-04 18:23:54 +03:00
|
|
|
class BPoint;
|
|
|
|
class BRect;
|
|
|
|
class BRegion;
|
|
|
|
|
|
|
|
class DrawState;
|
|
|
|
class HWInterface;
|
2005-03-27 01:09:02 +03:00
|
|
|
class Painter;
|
2005-11-04 18:23:54 +03:00
|
|
|
class RGBColor;
|
|
|
|
class ServerBitmap;
|
|
|
|
class ServerCursor;
|
|
|
|
class ServerFont;
|
|
|
|
|
2005-12-08 15:41:19 +03:00
|
|
|
typedef struct {
|
2005-11-04 18:23:54 +03:00
|
|
|
BPoint pt1;
|
|
|
|
BPoint pt2;
|
|
|
|
rgb_color color;
|
2005-03-27 01:09:02 +03:00
|
|
|
|
2005-11-04 18:23:54 +03:00
|
|
|
} LineArrayData;
|
2005-11-04 14:37:28 +03:00
|
|
|
|
2005-11-04 18:23:54 +03:00
|
|
|
class DrawingEngine {
|
2005-05-26 13:21:51 +04:00
|
|
|
public:
|
2005-12-08 15:41:19 +03:00
|
|
|
DrawingEngine(HWInterface* interface = NULL);
|
|
|
|
virtual ~DrawingEngine();
|
2005-03-26 01:46:10 +03:00
|
|
|
|
2005-11-04 21:22:22 +03:00
|
|
|
// when implementing, be sure to call the inherited version
|
2005-12-08 15:41:19 +03:00
|
|
|
status_t Initialize();
|
|
|
|
void Shutdown();
|
2005-03-26 01:46:10 +03:00
|
|
|
|
2005-11-04 21:22:22 +03:00
|
|
|
// locking
|
2005-12-08 15:41:19 +03:00
|
|
|
bool Lock();
|
|
|
|
void Unlock();
|
2005-06-24 03:46:17 +04:00
|
|
|
|
2005-12-08 15:41:19 +03:00
|
|
|
bool WriteLock();
|
|
|
|
void WriteUnlock();
|
2005-11-04 21:22:22 +03:00
|
|
|
|
|
|
|
// for "changing" hardware
|
2005-12-08 15:41:19 +03:00
|
|
|
void Update();
|
2005-11-04 21:22:22 +03:00
|
|
|
|
2005-12-08 15:41:19 +03:00
|
|
|
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
|
|
|
|
2005-11-04 21:22:22 +03:00
|
|
|
// for screen shots
|
2005-12-08 15:41:19 +03:00
|
|
|
bool DumpToFile(const char *path);
|
|
|
|
ServerBitmap* DumpToBitmap();
|
2005-05-04 01:47:08 +04:00
|
|
|
|
2005-11-04 21:22:22 +03:00
|
|
|
|
|
|
|
// clipping for all drawing functions, passing a NULL region
|
|
|
|
// will remove any clipping (drawing allowed everywhere)
|
2005-12-08 15:41:19 +03:00
|
|
|
void ConstrainClippingRegion(const BRegion* region);
|
2005-11-04 21:22:22 +03:00
|
|
|
|
|
|
|
// drawing functions
|
2005-12-08 15:41:19 +03:00
|
|
|
void CopyRegion(/*const*/ BRegion* region,
|
|
|
|
int32 xOffset, int32 yOffset);
|
2005-03-26 01:46:10 +03:00
|
|
|
|
2005-12-08 15:41:19 +03:00
|
|
|
void InvertRect(BRect r);
|
2005-03-26 01:46:10 +03:00
|
|
|
|
2005-12-08 15:41:19 +03:00
|
|
|
void DrawBitmap(ServerBitmap *bitmap,
|
|
|
|
const BRect &source, const BRect &dest,
|
|
|
|
const DrawState *d);
|
2005-11-04 21:22:22 +03:00
|
|
|
// drawing primitives
|
2005-03-26 01:46:10 +03:00
|
|
|
|
2005-12-08 15:41:19 +03:00
|
|
|
void DrawArc(BRect r, const float &angle,
|
|
|
|
const float &span,
|
|
|
|
const DrawState *d,
|
|
|
|
bool filled);
|
2005-03-26 01:46:10 +03:00
|
|
|
|
2005-12-08 15:41:19 +03:00
|
|
|
void DrawBezier(BPoint *pts, const DrawState *d,
|
|
|
|
bool filled);
|
2005-03-26 01:46:10 +03:00
|
|
|
|
2005-12-08 15:41:19 +03:00
|
|
|
void DrawEllipse(BRect r, const DrawState *d,
|
|
|
|
bool filled);
|
2005-03-26 01:46:10 +03:00
|
|
|
|
2005-12-08 15:41:19 +03:00
|
|
|
void DrawPolygon(BPoint *ptlist, int32 numpts,
|
|
|
|
BRect bounds, const DrawState *d,
|
|
|
|
bool filled, bool closed);
|
2005-11-04 21:22:22 +03:00
|
|
|
|
|
|
|
// this version used by Decorator
|
2005-12-08 15:41:19 +03:00
|
|
|
void StrokeRect(BRect r, const RGBColor &color);
|
|
|
|
void FillRect(BRect r, const RGBColor &color);
|
2005-03-26 01:46:10 +03:00
|
|
|
|
2005-12-08 15:41:19 +03:00
|
|
|
void StrokeRect(BRect r, const DrawState *d);
|
|
|
|
void FillRect(BRect r, const DrawState *d);
|
2005-03-26 01:46:10 +03:00
|
|
|
|
2005-12-08 15:41:19 +03:00
|
|
|
// for debugging purposes?
|
2005-12-21 01:39:54 +03:00
|
|
|
// void StrokeRegion(BRegion &r, const DrawState *d);
|
|
|
|
|
2005-12-08 15:41:19 +03:00
|
|
|
void FillRegion(BRegion &r, const DrawState *d);
|
|
|
|
void FillRegion(BRegion &r, const RGBColor& color);
|
2005-03-26 01:46:10 +03:00
|
|
|
|
2005-12-08 15:41:19 +03:00
|
|
|
void DrawRoundRect(BRect r, float xrad,
|
|
|
|
float yrad, const DrawState *d,
|
|
|
|
bool filled);
|
2005-03-26 01:46:10 +03:00
|
|
|
|
2005-12-08 15:41:19 +03:00
|
|
|
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);
|
2005-03-26 01:46:10 +03:00
|
|
|
|
2005-11-04 21:22:22 +03:00
|
|
|
// this version used by Decorator
|
2005-12-08 15:41:19 +03:00
|
|
|
void StrokeLine(const BPoint &start,
|
|
|
|
const BPoint &end, const RGBColor &color);
|
2005-03-26 01:46:10 +03:00
|
|
|
|
2005-12-08 15:41:19 +03:00
|
|
|
void StrokeLine(const BPoint &start,
|
|
|
|
const BPoint &end, DrawState *d);
|
2005-03-26 01:46:10 +03:00
|
|
|
|
2005-12-08 15:41:19 +03:00
|
|
|
void StrokeLineArray(int32 numlines,
|
|
|
|
const LineArrayData *data,
|
|
|
|
const DrawState *d);
|
2005-05-04 01:47:08 +04:00
|
|
|
|
2005-11-04 21:22:22 +03:00
|
|
|
// this version used by Decorator
|
2005-12-08 15:41:19 +03:00
|
|
|
void StrokePoint(const BPoint &pt,
|
|
|
|
const RGBColor &color);
|
2005-03-26 01:46:10 +03:00
|
|
|
|
2005-12-08 15:41:19 +03:00
|
|
|
void StrokePoint(const BPoint &pt,
|
|
|
|
DrawState *d);
|
2005-03-26 01:46:10 +03:00
|
|
|
|
2005-11-04 21:22:22 +03:00
|
|
|
// -------- text related calls
|
2005-12-08 15:41:19 +03:00
|
|
|
|
2005-11-04 21:22:22 +03:00
|
|
|
// DrawState is NOT const because this call updates the pen position in the passed DrawState
|
2005-12-08 15:41:19 +03:00
|
|
|
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);
|
2005-03-26 01:46:10 +03:00
|
|
|
|
|
|
|
private:
|
2005-12-08 15:41:19 +03:00
|
|
|
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;
|
2005-03-26 01:46:10 +03:00
|
|
|
};
|
|
|
|
|
2005-11-04 18:54:16 +03:00
|
|
|
#endif // DRAWING_ENGINE_H_
|