completely rewritten!

This is the CORE of the NEW drawing code, which WORKS very well! :-)
ATM, only WinBorder remains to be rewritten, but that would be an easy job, because the core is here in Layer class and WinBorder is just a subclass of it...


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6725 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Adi Oanca
2004-02-24 12:02:47 +00:00
parent 6844f6d0eb
commit 296a7f991d
2 changed files with 721 additions and 898 deletions
File diff suppressed because it is too large Load Diff
+45 -83
View File
@@ -1,31 +1,3 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: Layer.h
// Author: DarkWyrm <[email protected]>
// Adi Oanca <[email protected]>
// Description: Class used for rendering to the frame buffer. One layer per
// view on screen and also for window decorators
//
//------------------------------------------------------------------------------
#ifndef _LAYER_H_ #ifndef _LAYER_H_
#define _LAYER_H_ #define _LAYER_H_
@@ -36,76 +8,56 @@
#include <String.h> #include <String.h>
#include <OS.h> #include <OS.h>
#include <Locker.h> #include <Locker.h>
#include "LayerData.h" #include "RGBColor.h"
#include "TokenHandler.h"
class ServerWindow; class ServerWindow;
class PortLink;
class RootLayer; class RootLayer;
class WinBorder; //class MyDriver;
class Screen;
class ServerCursor;
class DisplayDriver; class DisplayDriver;
class Desktop; class LayerData;
class Workspace;
/*!
\class Layer Layer.h
\brief Shadow BView class
Layers provide all sorts of functionality. They are the shadow class for BViews,
but they also provide the base class for other classes which handle drawing to
the frame buffer, like RootLayer and WinBorder.
*/
class Layer class Layer
{ {
public: public:
Layer(BRect frame, const char *name, int32 token, uint32 resize, Layer(BRect frame, const char *name, int32 token, uint32 resize,
uint32 flags, ServerWindow *win); uint32 flags, DisplayDriver *driver);
virtual ~Layer(void); virtual ~Layer(void);
void AddChild(Layer *child, RootLayer *rootLayer); void AddChild(Layer *child, RootLayer *rootLayer = NULL);
void RemoveChild(Layer *child); void RemoveChild(Layer *child);
void RemoveSelf(); void RemoveSelf();
bool HasChild(Layer* layer) const; bool HasChild(Layer* layer);
RootLayer* GetRootLayer() const; RootLayer* GetRootLayer() const { return fRootLayer; }
uint32 CountChildren(void) const; uint32 CountChildren(void) const;
Layer* FindLayer(const int32 token); Layer* FindLayer(const int32 token);
Layer* LayerAt(const BPoint &pt); Layer* LayerAt(const BPoint &pt);
virtual Layer* TopLayer() const { return _topchild; } virtual Layer* VirtualTopChild() const;
virtual Layer* LowerSibling() const { return _lowersibling; } virtual Layer* VirtualLowerSibling() const;
virtual Layer* UpperSibling() const { return _uppersibling; } virtual Layer* VirtualUpperSibling() const;
virtual Layer* BottomLayer() const { return _bottomchild; } virtual Layer* VirtualBottomChild() const;
virtual Layer* VirtualTopChild() const{ return _topchild; }
virtual Layer* VirtualLowerSibling() const{ return _lowersibling; }
virtual Layer* VirtualUpperSibling() const{ return _uppersibling; }
virtual Layer* VirtualBottomChild() const{ return _bottomchild; }
const char* GetName(void) const { return (_name)?_name->String():NULL; } const char* GetName(void) const { return (_name)?_name->String():NULL; }
LayerData* GetLayerData(void) const { return _layerdata; }
void SetLayerCursor(ServerCursor *csr); void FullInvalidate(const BRect &rect);
ServerCursor* GetLayerCursor(void) const; void FullInvalidate(const BRegion &region);
virtual void MouseTransit(uint32 transit);
void Invalidate(const BRect &rect);
void Invalidate(const BRegion &region); void Invalidate(const BRegion &region);
void DoInvalidate(const BRegion &reg, Layer *start);
virtual void RebuildRegions( const BRect& r );
void RebuildChildRegions( const BRect &r, Layer* startFrom );
void RebuildFullRegion(void); void RebuildFullRegion(void);
void MoveRegionsBy(float x, float y); void StartRebuildRegions( const BRegion& reg, Layer *target, uint32 action, BPoint& pt);
void ResizeRegionsBy(float x, float y); void RebuildRegions( const BRegion& reg, uint32 action, BPoint pt, BPoint ptOffset);
uint32 ResizeOthers(float x, float y, BPoint coords[], BPoint *ptOffset);
void RequestClientUpdate(const BRect &rect);
void RequestDraw(const BRect &r); void Redraw(const BRegion& reg, Layer *startFrom=NULL);
void EmptyGlobals();
virtual void Draw(const BRect &r); virtual void Draw(const BRect &r);
void SendViewMovedMsg();
void SendViewResizedMsg();
virtual void Show(void); virtual void Show(void);
virtual void Hide(void); virtual void Hide(void);
bool IsHidden(void) const; bool IsHidden(void) const;
@@ -125,6 +77,8 @@ public:
BRegion ConvertFromTop(BRegion *reg); BRegion ConvertFromTop(BRegion *reg);
BRect ConvertFromTop(BRect rect); BRect ConvertFromTop(BRect rect);
DisplayDriver* GetDisplayDriver() const { return fDriver; }
void PruneTree(void); void PruneTree(void);
void PrintToStream(void); void PrintToStream(void);
@@ -132,7 +86,14 @@ public:
void PrintTree(); void PrintTree();
// server "private" - should not be used // server "private" - should not be used
void SetRootLayer(RootLayer* rl); void SetRootLayer(RootLayer* rl){ fRootLayer = rl; }
void SetServerWindow(ServerWindow *win);
private:
void RequestClientUpdate(const BRegion &reg, Layer *startFrom);
void RequestDraw(const BRegion &reg, Layer *startFrom, bool redraw=false);
ServerWindow* SearchForServerWindow() const;
protected: protected:
friend class RootLayer; friend class RootLayer;
friend class WinBorder; friend class WinBorder;
@@ -140,7 +101,7 @@ protected:
friend class ServerWindow; friend class ServerWindow;
friend class Desktop; friend class Desktop;
friend class Workspace; friend class Workspace;
BRect _frame; BRect _frame;
BPoint _boundsLeftTop; BPoint _boundsLeftTop;
Layer *_parent, Layer *_parent,
@@ -149,9 +110,12 @@ protected:
*_topchild, *_topchild,
*_bottomchild; *_bottomchild;
mutable Layer *fCurrent;
BRegion _visible, BRegion _visible,
_fullVisible, _fullVisible,
_full; _full,
fUpdateReg;
BRegion *clipToPicture; BRegion *clipToPicture;
bool clipToPictureInverse; bool clipToPictureInverse;
@@ -164,15 +128,13 @@ protected:
uint32 _resize_mode; uint32 _resize_mode;
bool _hidden; bool _hidden;
bool _is_updating; bool _is_updating;
// MyDriver *fDriver;
DisplayDriver *fDriver;
LayerData *_layerdata; LayerData *_layerdata;
ServerCursor *_cursor; RGBColor fBackColor;
DisplayDriver* fDriver;
RootLayer* fRootLayer; RootLayer* fRootLayer;
}; };
#endif #endif
/*
@log
* added a new member, BPoint _boundsLeftTop. Beside other uses, (DW don't forget!)it will be needed in redraw code.
* _flags is now declared as uint32
*/