abstract base class and implementation using BView and BWindow of an interface to a graphics card, UpdateQueue doesn't work yet, it was going to be used to decouple frame buffer transfers to the front buffer from the drawing in the back buffer
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12056 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
5cdd702901
commit
3294d07b15
13
src/servers/app/drawing/HWInterface.cpp
Normal file
13
src/servers/app/drawing/HWInterface.cpp
Normal file
@ -0,0 +1,13 @@
|
||||
// HWInterface.cpp
|
||||
|
||||
#include "HWInterface.h"
|
||||
|
||||
// constructor
|
||||
HWInterface::HWInterface()
|
||||
{
|
||||
}
|
||||
|
||||
// destructor
|
||||
HWInterface::~HWInterface()
|
||||
{
|
||||
}
|
51
src/servers/app/drawing/HWInterface.h
Normal file
51
src/servers/app/drawing/HWInterface.h
Normal file
@ -0,0 +1,51 @@
|
||||
//
|
||||
// Copyright 2005, Stephan Aßmus <superstippi@gmx.de>
|
||||
// Distributed under the terms of the MIT License.
|
||||
//
|
||||
// Contains an abstract base class HWInterface that provides the
|
||||
// basic functionality for frame buffer acces in the DisplayDriverPainter
|
||||
// implementation.
|
||||
|
||||
#ifndef HW_INTERFACE_H
|
||||
#define HW_INTERFACE_H
|
||||
|
||||
#include <Accelerant.h>
|
||||
#include <GraphicsCard.h>
|
||||
#include <OS.h>
|
||||
|
||||
class RenderingBuffer;
|
||||
class BRect;
|
||||
|
||||
class HWInterface {
|
||||
public:
|
||||
HWInterface();
|
||||
virtual ~HWInterface();
|
||||
|
||||
virtual status_t SetMode(const display_mode &mode) = 0;
|
||||
// virtual void GetMode(display_mode *mode) = 0;
|
||||
|
||||
|
||||
virtual status_t GetDeviceInfo(accelerant_device_info *info) = 0;
|
||||
virtual status_t GetModeList(display_mode **mode_list,
|
||||
uint32 *count) = 0;
|
||||
virtual status_t GetPixelClockLimits(display_mode *mode,
|
||||
uint32 *low,
|
||||
uint32 *high) = 0;
|
||||
virtual status_t GetTimingConstraints(display_timing_constraints *dtc) = 0;
|
||||
virtual status_t ProposeMode(display_mode *candidate,
|
||||
const display_mode *low,
|
||||
const display_mode *high) = 0;
|
||||
|
||||
virtual status_t WaitForRetrace(bigtime_t timeout = B_INFINITE_TIMEOUT) = 0;
|
||||
|
||||
// frame buffer access
|
||||
virtual RenderingBuffer* FrontBuffer() const = 0;
|
||||
virtual RenderingBuffer* BackBuffer() const = 0;
|
||||
|
||||
// Invalidate is planned to be used for scheduling an area for updating
|
||||
virtual status_t Invalidate(const BRect& frame) = 0;
|
||||
// while as CopyBackToFront() actually performs the operation
|
||||
virtual status_t CopyBackToFront(const BRect& frame) = 0;
|
||||
};
|
||||
|
||||
#endif // HW_INTERFACE_H
|
112
src/servers/app/drawing/UpdateQueue.cpp
Normal file
112
src/servers/app/drawing/UpdateQueue.cpp
Normal file
@ -0,0 +1,112 @@
|
||||
// UpdateQueue.cpp
|
||||
|
||||
#include <new>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "HWInterface.h"
|
||||
|
||||
#include "UpdateQueue.h"
|
||||
|
||||
// constructor
|
||||
UpdateQueue::UpdateQueue(HWInterface* interface)
|
||||
: fInterface(interface),
|
||||
fUpdateRegion(),
|
||||
fUpdateExecutor(-1),
|
||||
fThreadControl(-1),
|
||||
fStatus(B_ERROR)
|
||||
|
||||
{
|
||||
fThreadControl = create_sem(0, "update queue control");
|
||||
if (fThreadControl >= B_OK)
|
||||
fStatus = B_OK;
|
||||
else
|
||||
fStatus = fThreadControl;
|
||||
if (fStatus == B_OK) {
|
||||
fUpdateExecutor = spawn_thread(_execute_updates_, "update queue runner",
|
||||
B_NORMAL_PRIORITY, this);
|
||||
if (fUpdateExecutor >= B_OK) {
|
||||
fStatus = B_OK;
|
||||
resume_thread(fUpdateExecutor);
|
||||
} else
|
||||
fStatus = fUpdateExecutor;
|
||||
}
|
||||
}
|
||||
|
||||
// destructor
|
||||
UpdateQueue::~UpdateQueue()
|
||||
{
|
||||
if (delete_sem(fThreadControl) == B_OK)
|
||||
wait_for_thread(fUpdateExecutor, &fUpdateExecutor);
|
||||
}
|
||||
|
||||
// InitCheck
|
||||
status_t
|
||||
UpdateQueue::InitCheck()
|
||||
{
|
||||
return fStatus;
|
||||
}
|
||||
|
||||
// AddRect
|
||||
void
|
||||
UpdateQueue::AddRect(const BRect& rect)
|
||||
{
|
||||
Lock();
|
||||
fUpdateRegion.Include(rect);
|
||||
_Reschedule();
|
||||
Unlock();
|
||||
}
|
||||
|
||||
// _execute_updates_
|
||||
int32
|
||||
UpdateQueue::_execute_updates_(void* cookie)
|
||||
{
|
||||
UpdateQueue *gc = (UpdateQueue*)cookie;
|
||||
return gc->_ExecuteUpdates();
|
||||
}
|
||||
|
||||
// _ExecuteUpdates
|
||||
int32
|
||||
UpdateQueue::_ExecuteUpdates()
|
||||
{
|
||||
bool running = true;
|
||||
while (running) {
|
||||
status_t err = acquire_sem_etc(fThreadControl, 1, B_RELATIVE_TIMEOUT,
|
||||
40000);
|
||||
switch (err) {
|
||||
case B_OK:
|
||||
case B_TIMED_OUT:
|
||||
// execute updates
|
||||
if (Lock()) {
|
||||
// if (fInterface->Lock()) {
|
||||
int32 count = fUpdateRegion.CountRects();
|
||||
for (int32 i = 0; i < count; i++) {
|
||||
fInterface->CopyBackToFront(fUpdateRegion.RectAt(i));
|
||||
}
|
||||
// fInterface->Unlock();
|
||||
fUpdateRegion.MakeEmpty();
|
||||
// }
|
||||
Unlock();
|
||||
}
|
||||
break;
|
||||
case B_BAD_SEM_ID:
|
||||
running = false;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// _Reschedule
|
||||
//
|
||||
// PRE: The object must be locked.
|
||||
void
|
||||
UpdateQueue::_Reschedule()
|
||||
{
|
||||
if (fStatus == B_OK) {
|
||||
if (fUpdateRegion.Frame().IsValid())
|
||||
release_sem(fThreadControl);
|
||||
}
|
||||
}
|
||||
|
36
src/servers/app/drawing/UpdateQueue.h
Normal file
36
src/servers/app/drawing/UpdateQueue.h
Normal file
@ -0,0 +1,36 @@
|
||||
// UpdateQueue.h
|
||||
|
||||
#ifndef EVENT_QUEUE_H
|
||||
#define EVENT_QUEUE_H
|
||||
|
||||
#include <List.h>
|
||||
#include <Locker.h>
|
||||
#include <OS.h>
|
||||
#include <Region.h>
|
||||
|
||||
class HWInterface;
|
||||
|
||||
class UpdateQueue : public BLocker {
|
||||
public:
|
||||
UpdateQueue(HWInterface* interface);
|
||||
virtual ~UpdateQueue();
|
||||
|
||||
status_t InitCheck();
|
||||
|
||||
void AddRect(const BRect& rect);
|
||||
|
||||
private:
|
||||
static int32 _execute_updates_(void *cookie);
|
||||
int32 _ExecuteUpdates();
|
||||
|
||||
void _Reschedule();
|
||||
|
||||
HWInterface* fInterface;
|
||||
|
||||
BRegion fUpdateRegion;
|
||||
thread_id fUpdateExecutor;
|
||||
sem_id fThreadControl;
|
||||
status_t fStatus;
|
||||
};
|
||||
|
||||
#endif // EVENT_QUEUE_H
|
1116
src/servers/app/drawing/ViewHWInterface.cpp
Normal file
1116
src/servers/app/drawing/ViewHWInterface.cpp
Normal file
File diff suppressed because it is too large
Load Diff
63
src/servers/app/drawing/ViewHWInterface.h
Normal file
63
src/servers/app/drawing/ViewHWInterface.h
Normal file
@ -0,0 +1,63 @@
|
||||
//------------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright 2005, Haiku, Inc.
|
||||
// Distributed under the terms of the MIT License.
|
||||
//
|
||||
//
|
||||
// File Name: ViewHWInterface.h
|
||||
// Author: Stephan Aßmus <superstippi@gmx.de>
|
||||
// Description: BView/BWindow combination HWInterface implementation
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
#ifndef VIEW_GRAPHICS_CARD_H
|
||||
#define VIEW_GRAPHICS_CARD_H
|
||||
|
||||
#include "HWInterface.h"
|
||||
|
||||
class BBitmap;
|
||||
class BitmapBuffer;
|
||||
class CardWindow;
|
||||
class UpdateQueue;
|
||||
|
||||
|
||||
class ViewHWInterface : public HWInterface {
|
||||
public:
|
||||
ViewHWInterface();
|
||||
virtual ~ViewHWInterface();
|
||||
|
||||
virtual status_t SetMode(const display_mode &mode);
|
||||
// virtual void GetMode(display_mode *mode);
|
||||
|
||||
|
||||
virtual status_t GetDeviceInfo(accelerant_device_info *info);
|
||||
virtual status_t GetModeList(display_mode **mode_list,
|
||||
uint32 *count);
|
||||
virtual status_t GetPixelClockLimits(display_mode *mode,
|
||||
uint32 *low,
|
||||
uint32 *high);
|
||||
virtual status_t GetTimingConstraints(display_timing_constraints *dtc);
|
||||
virtual status_t ProposeMode(display_mode *candidate,
|
||||
const display_mode *low,
|
||||
const display_mode *high);
|
||||
|
||||
virtual status_t WaitForRetrace(bigtime_t timeout = B_INFINITE_TIMEOUT);
|
||||
|
||||
// frame buffer access
|
||||
virtual RenderingBuffer* FrontBuffer() const;
|
||||
virtual RenderingBuffer* BackBuffer() const;
|
||||
|
||||
virtual status_t Invalidate(const BRect& frame);
|
||||
virtual status_t CopyBackToFront(const BRect& area);
|
||||
|
||||
private:
|
||||
BitmapBuffer* fBackBuffer;
|
||||
BitmapBuffer* fFrontBuffer;
|
||||
|
||||
CardWindow* fWindow;
|
||||
|
||||
display_mode fDisplayMode;
|
||||
|
||||
UpdateQueue* fUpdateExecutor;
|
||||
};
|
||||
|
||||
#endif // VIEW_GRAPHICS_CARD_H
|
Loading…
Reference in New Issue
Block a user