refactoring and cleanup in LayerData and friends, it shows what I mean by "forced code paths" for example in coupled font size and view scale, added a couple TODOs, disabled decoupled frame buffer transfers, it is buggy and deadlocks for some reason...
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12441 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// Copyright (c) 2001-2002, Haiku, Inc.
|
||||
// Copyright (c) 2001-2005, Haiku, Inc.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
@@ -22,82 +22,223 @@
|
||||
// File Name: LayerData.h
|
||||
// Author: DarkWyrm <[email protected]>
|
||||
// Adi Oanca <[email protected]>
|
||||
// Stephan Aßmus <[email protected]>
|
||||
// Description: Data classes for working with BView states and draw parameters
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
#ifndef LAYERDATA_H_
|
||||
#define LAYERDATA_H_
|
||||
#ifndef LAYER_DATA_H_
|
||||
#define LAYER_DATA_H_
|
||||
|
||||
#include <Point.h>
|
||||
#include <Font.h>
|
||||
#include <Region.h>
|
||||
#include <RGBColor.h>
|
||||
#include <FontServer.h>
|
||||
#include <ServerFont.h>
|
||||
#include <PatternHandler.h>
|
||||
#include <GraphicsDefs.h>
|
||||
#include <InterfaceDefs.h>
|
||||
#include <Point.h>
|
||||
#include <View.h> // for B_FONT_ALL
|
||||
|
||||
#include "RGBColor.h"
|
||||
#include "FontServer.h"
|
||||
#include "ServerFont.h"
|
||||
#include "PatternHandler.h"
|
||||
|
||||
class BRegion;
|
||||
class LinkMsgReader;
|
||||
class LinkMsgSender;
|
||||
class ServerBitmap;
|
||||
class ServerFont;
|
||||
class ServerPicture;
|
||||
class Layer;
|
||||
|
||||
class DrawData
|
||||
{
|
||||
public:
|
||||
DrawData(void);
|
||||
DrawData(const DrawData &data);
|
||||
virtual ~DrawData(void);
|
||||
DrawData& operator=(const DrawData &from);
|
||||
// TODO: uncomment and implement DrawData::PrintToStream when needed.
|
||||
// virtual void PrintToStream() const;
|
||||
class DrawData {
|
||||
public:
|
||||
DrawData();
|
||||
DrawData(const DrawData& from);
|
||||
virtual ~DrawData();
|
||||
|
||||
BPoint penlocation;
|
||||
DrawData& operator=(const DrawData& from);
|
||||
|
||||
RGBColor highcolor,
|
||||
lowcolor;
|
||||
// coordinate transformation
|
||||
void SetOrigin(const BPoint& origin);
|
||||
inline const BPoint& Origin() const
|
||||
{ return fOrigin; }
|
||||
|
||||
float pensize;
|
||||
Pattern patt;
|
||||
drawing_mode draw_mode;
|
||||
|
||||
cap_mode lineCap;
|
||||
join_mode lineJoin;
|
||||
float miterLimit;
|
||||
|
||||
source_alpha alphaSrcMode;
|
||||
alpha_function alphaFncMode;
|
||||
float scale;
|
||||
bool fontAliasing;
|
||||
ServerFont font;
|
||||
|
||||
BRegion* clipReg;
|
||||
|
||||
escapement_delta edelta;
|
||||
void SetScale(float scale);
|
||||
inline float Scale() const
|
||||
{ return fScale; }
|
||||
|
||||
// additional clipping as requested by client
|
||||
void SetClippingRegion(const BRegion& region);
|
||||
inline const BRegion* ClippingRegion() const
|
||||
{ return fClippingRegion; }
|
||||
/* inline int32 CountClippingRects() const
|
||||
{ return fClippingRegion ? fClippingRegion.CountRects() : 0; }
|
||||
inline BRect ClippingRectAt(int32 index) const;*/
|
||||
|
||||
// color
|
||||
void SetHighColor(const RGBColor& color);
|
||||
inline const RGBColor& HighColor() const
|
||||
{ return fHighColor; }
|
||||
|
||||
void SetLowColor(const RGBColor& color);
|
||||
inline const RGBColor& LowColor() const
|
||||
{ return fLowColor; }
|
||||
|
||||
void SetPattern(const Pattern& pattern);
|
||||
inline const Pattern& GetPattern() const
|
||||
{ return fPattern; }
|
||||
|
||||
// drawing/blending mode
|
||||
void SetDrawingMode(drawing_mode mode);
|
||||
inline drawing_mode GetDrawingMode() const
|
||||
{ return fDrawingMode; }
|
||||
|
||||
void SetBlendingMode(source_alpha srcMode,
|
||||
alpha_function fncMode);
|
||||
inline source_alpha AlphaSrcMode() const
|
||||
{ return fAlphaSrcMode; }
|
||||
inline alpha_function AlphaFncMode() const
|
||||
{ return fAlphaFncMode; }
|
||||
|
||||
// pen
|
||||
void SetPenLocation(const BPoint& location);
|
||||
const BPoint& PenLocation() const;
|
||||
|
||||
void SetPenSize(float size);
|
||||
float PenSize() const;
|
||||
|
||||
// font
|
||||
void SetFont(const ServerFont& font,
|
||||
uint32 flags = B_FONT_ALL);
|
||||
inline const ServerFont& Font() const
|
||||
{ return fFont; }
|
||||
|
||||
void SetFontAntiAliasing(bool antiAliasing);
|
||||
inline bool FontAntiAliasing() const
|
||||
{ return fFontAntiAliasing; }
|
||||
|
||||
void SetEscapementDelta(escapement_delta delta);
|
||||
inline escapement_delta EscapementDelta() const
|
||||
{ return fEscapementDelta; }
|
||||
|
||||
// postscript style settings
|
||||
void SetLineCapMode(cap_mode mode);
|
||||
inline cap_mode LineCapMode() const
|
||||
{ return fLineCapMode; }
|
||||
|
||||
void SetLineJoinMode(join_mode mode);
|
||||
inline join_mode LineJoinMode() const
|
||||
{ return fLineJoinMode; }
|
||||
|
||||
void SetMiterLimit(float limit);
|
||||
inline float MiterLimit() const
|
||||
{ return fMiterLimit; }
|
||||
|
||||
// convenience functions
|
||||
inline BPoint Transform(const BPoint& point) const;
|
||||
inline BRect Transform(const BRect& rect) const;
|
||||
|
||||
|
||||
protected:
|
||||
BPoint fOrigin;
|
||||
float fScale;
|
||||
|
||||
BRegion* fClippingRegion;
|
||||
|
||||
RGBColor fHighColor;
|
||||
RGBColor fLowColor;
|
||||
Pattern fPattern;
|
||||
|
||||
drawing_mode fDrawingMode;
|
||||
source_alpha fAlphaSrcMode;
|
||||
alpha_function fAlphaFncMode;
|
||||
|
||||
BPoint fPenLocation;
|
||||
float fPenSize;
|
||||
|
||||
ServerFont fFont;
|
||||
bool fFontAntiAliasing;
|
||||
escapement_delta fEscapementDelta;
|
||||
|
||||
cap_mode fLineCapMode;
|
||||
join_mode fLineJoinMode;
|
||||
float fMiterLimit;
|
||||
|
||||
float fUnscaledFontSize;
|
||||
};
|
||||
|
||||
class LayerData : public DrawData
|
||||
{
|
||||
public:
|
||||
LayerData(void);
|
||||
LayerData(const Layer *layer);
|
||||
class LayerData : public DrawData {
|
||||
public:
|
||||
LayerData();
|
||||
LayerData(const LayerData &data);
|
||||
virtual ~LayerData(void);
|
||||
LayerData &operator=(const LayerData &from);
|
||||
virtual ~LayerData();
|
||||
|
||||
LayerData& operator=(const LayerData &from);
|
||||
|
||||
// automatic background blanking by app_server
|
||||
void SetViewColor(const RGBColor& color);
|
||||
inline const RGBColor& ViewColor() const
|
||||
{ return fViewColor; }
|
||||
|
||||
void SetBackgroundBitmap(const ServerBitmap* bitmap);
|
||||
inline const ServerBitmap* BackgroundBitmap() const
|
||||
{ return fBackgroundBitmap; }
|
||||
|
||||
// overlay support
|
||||
// TODO: This can't be all, what about color key?
|
||||
void SetOverlayBitmap(const ServerBitmap* bitmap);
|
||||
inline const ServerBitmap* OverlayBitmap() const
|
||||
{ return fOverlayBitmap; }
|
||||
|
||||
// convenience functions
|
||||
virtual void PrintToStream() const;
|
||||
|
||||
BPoint coordOrigin;
|
||||
void ReadFontFromLink(LinkMsgReader& link);
|
||||
// NOTE: ReadFromLink() does not read Font state!!
|
||||
// It was separate in ServerWindow, and I didn't
|
||||
// want to change it without knowing implications.
|
||||
void ReadFromLink(LinkMsgReader& link);
|
||||
void WriteToLink(LinkMsgSender& link) const;
|
||||
|
||||
RGBColor viewcolor;
|
||||
protected:
|
||||
|
||||
// We have both because we are not going to suffer from the limitation that R5
|
||||
// places on us. We can have both. :)
|
||||
ServerBitmap* background;
|
||||
ServerBitmap* overlay;
|
||||
RGBColor fViewColor;
|
||||
|
||||
// We have both because we are not going to suffer
|
||||
// from the limitation that R5 places on us.
|
||||
// We can have both. :)
|
||||
const ServerBitmap* fBackgroundBitmap;
|
||||
const ServerBitmap* fOverlayBitmap;
|
||||
|
||||
public:
|
||||
// used for the state stack
|
||||
LayerData* prevState;
|
||||
};
|
||||
#endif
|
||||
|
||||
// inline implementations
|
||||
|
||||
// Transform
|
||||
BPoint
|
||||
DrawData::Transform(const BPoint& point) const
|
||||
{
|
||||
BPoint p(point);
|
||||
p += fOrigin;
|
||||
p.x *= fScale;
|
||||
p.y *= fScale;
|
||||
return p;
|
||||
}
|
||||
|
||||
// Transform
|
||||
BRect
|
||||
DrawData::Transform(const BRect& rect) const
|
||||
{
|
||||
return BRect(Transform(rect.LeftTop()),
|
||||
Transform(rect.LeftBottom()));
|
||||
}
|
||||
/*
|
||||
// ClippingRectAt
|
||||
BRect
|
||||
DrawData::ClippingRectAt(int32 index) const
|
||||
{
|
||||
BRect r;
|
||||
if (fClippingRegion) {
|
||||
r = fClippingRegion.RectAt(index);
|
||||
}
|
||||
return r;
|
||||
}*/
|
||||
|
||||
#endif // LAYER_DATA_H_
|
||||
|
||||
@@ -46,6 +46,9 @@ class Pattern {
|
||||
Pattern(const Pattern& src)
|
||||
{ fPattern.type64 = src.fPattern.type64; }
|
||||
|
||||
Pattern(const pattern& src)
|
||||
{ fPattern.type64 = *(uint64*)src.data; }
|
||||
|
||||
inline const int8* GetInt8(void) const
|
||||
{ return fPattern.type8; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user