* Some refactoring: renamed OverlayCookie to Overlay and put it in its own
source file. * An overlay is now also hidden in case its is removed from the window. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17209 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
f7c7883b9f
commit
0ac013e66f
@ -18,6 +18,7 @@
|
||||
|
||||
#include "ClientMemoryAllocator.h"
|
||||
#include "HWInterface.h"
|
||||
#include "Overlay.h"
|
||||
#include "ServerBitmap.h"
|
||||
#include "ServerProtocol.h"
|
||||
#include "ServerTokenSpace.h"
|
||||
@ -111,13 +112,13 @@ BitmapManager::CreateBitmap(ClientMemoryAllocator* allocator, HWInterface& hwInt
|
||||
uint8* buffer = NULL;
|
||||
|
||||
if (flags & B_BITMAP_WILL_OVERLAY) {
|
||||
OverlayCookie* overlayCookie = new (std::nothrow) OverlayCookie(hwInterface);
|
||||
Overlay* overlay = new (std::nothrow) Overlay(hwInterface);
|
||||
|
||||
const overlay_buffer* overlayBuffer = NULL;
|
||||
overlay_client_data* clientData = NULL;
|
||||
bool newArea = false;
|
||||
|
||||
if (overlayCookie != NULL && overlayCookie->InitCheck() == B_OK) {
|
||||
if (overlay != NULL && overlay->InitCheck() == B_OK) {
|
||||
// allocate client memory to communicate the overlay semaphore
|
||||
// and buffer location to the BBitmap
|
||||
cookie = allocator->Allocate(sizeof(overlay_client_data),
|
||||
@ -129,11 +130,11 @@ BitmapManager::CreateBitmap(ClientMemoryAllocator* allocator, HWInterface& hwInt
|
||||
}
|
||||
|
||||
if (overlayBuffer != NULL) {
|
||||
overlayCookie->SetOverlayData(overlayBuffer, overlayToken, clientData);
|
||||
overlay->SetOverlayData(overlayBuffer, overlayToken, clientData);
|
||||
|
||||
bitmap->fAllocator = allocator;
|
||||
bitmap->fAllocationCookie = cookie;
|
||||
bitmap->SetOverlayCookie(overlayCookie);
|
||||
bitmap->SetOverlay(overlay);
|
||||
bitmap->fBytesPerRow = overlayBuffer->bytes_per_row;
|
||||
|
||||
buffer = (uint8*)overlayBuffer->buffer;
|
||||
@ -141,7 +142,7 @@ BitmapManager::CreateBitmap(ClientMemoryAllocator* allocator, HWInterface& hwInt
|
||||
*_allocationFlags = kFramebuffer | (newArea ? kNewAllocatorArea : 0);
|
||||
} else {
|
||||
hwInterface.ReleaseOverlayChannel(overlayToken);
|
||||
delete overlayCookie;
|
||||
delete overlay;
|
||||
allocator->Free(cookie);
|
||||
}
|
||||
} else if (allocator != NULL) {
|
||||
|
@ -12,8 +12,7 @@
|
||||
#include "ClientMemoryAllocator.h"
|
||||
#include "ColorConversion.h"
|
||||
#include "HWInterface.h"
|
||||
|
||||
#include <BitmapPrivate.h>
|
||||
#include "Overlay.h"
|
||||
|
||||
#include <new>
|
||||
#include <stdio.h>
|
||||
@ -56,7 +55,7 @@ ServerBitmap::ServerBitmap(BRect rect, color_space space,
|
||||
:
|
||||
fAllocator(NULL),
|
||||
fAllocationCookie(NULL),
|
||||
fOverlayCookie(NULL),
|
||||
fOverlay(NULL),
|
||||
fBuffer(NULL),
|
||||
fReferenceCount(1),
|
||||
// WARNING: '1' is added to the width and height.
|
||||
@ -80,7 +79,7 @@ ServerBitmap::ServerBitmap(const ServerBitmap* bmp)
|
||||
:
|
||||
fAllocator(NULL),
|
||||
fAllocationCookie(NULL),
|
||||
fOverlayCookie(NULL),
|
||||
fOverlay(NULL),
|
||||
fBuffer(NULL),
|
||||
fReferenceCount(1)
|
||||
{
|
||||
@ -109,8 +108,8 @@ ServerBitmap::~ServerBitmap()
|
||||
else
|
||||
free(fBuffer);
|
||||
|
||||
delete fOverlayCookie;
|
||||
// deleting the cookie will also free the overlay buffer
|
||||
delete fOverlay;
|
||||
// deleting the overlay will also free the overlay buffer
|
||||
}
|
||||
|
||||
|
||||
@ -305,16 +304,16 @@ ServerBitmap::AreaOffset() const
|
||||
|
||||
|
||||
void
|
||||
ServerBitmap::SetOverlayCookie(::OverlayCookie* cookie)
|
||||
ServerBitmap::SetOverlay(::Overlay* cookie)
|
||||
{
|
||||
fOverlayCookie = cookie;
|
||||
fOverlay = cookie;
|
||||
}
|
||||
|
||||
|
||||
::OverlayCookie*
|
||||
ServerBitmap::OverlayCookie() const
|
||||
::Overlay*
|
||||
ServerBitmap::Overlay() const
|
||||
{
|
||||
return fOverlayCookie;
|
||||
return fOverlay;
|
||||
}
|
||||
|
||||
|
||||
@ -362,123 +361,3 @@ UtilityBitmap::UtilityBitmap(const uint8* alreadyPaddedData,
|
||||
UtilityBitmap::~UtilityBitmap()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
OverlayCookie::OverlayCookie(HWInterface& interface)
|
||||
:
|
||||
fHWInterface(interface),
|
||||
fOverlayBuffer(NULL),
|
||||
fClientData(NULL),
|
||||
fOverlayToken(NULL)
|
||||
{
|
||||
fSemaphore = create_sem(1, "overlay lock");
|
||||
fColor.SetColor(21, 16, 21, 16);
|
||||
// TODO: whatever fine color we want to use here...
|
||||
}
|
||||
|
||||
|
||||
OverlayCookie::~OverlayCookie()
|
||||
{
|
||||
fHWInterface.ReleaseOverlayChannel(fOverlayToken);
|
||||
fHWInterface.FreeOverlayBuffer(fOverlayBuffer);
|
||||
|
||||
delete_sem(fSemaphore);
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
OverlayCookie::InitCheck() const
|
||||
{
|
||||
return fSemaphore >= B_OK ? B_OK : fSemaphore;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
OverlayCookie::SetOverlayData(const overlay_buffer* overlayBuffer,
|
||||
overlay_token token, overlay_client_data* clientData)
|
||||
{
|
||||
fOverlayBuffer = overlayBuffer;
|
||||
fOverlayToken = token;
|
||||
|
||||
fClientData = clientData;
|
||||
fClientData->lock = fSemaphore;
|
||||
fClientData->buffer = (uint8*)fOverlayBuffer->buffer;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
OverlayCookie::TakeOverToken(OverlayCookie* other)
|
||||
{
|
||||
overlay_token token = other->OverlayToken();
|
||||
if (token == NULL)
|
||||
return;
|
||||
|
||||
fOverlayToken = token;
|
||||
//other->fOverlayToken = NULL;
|
||||
}
|
||||
|
||||
|
||||
const overlay_buffer*
|
||||
OverlayCookie::OverlayBuffer() const
|
||||
{
|
||||
return fOverlayBuffer;
|
||||
}
|
||||
|
||||
|
||||
overlay_client_data*
|
||||
OverlayCookie::ClientData() const
|
||||
{
|
||||
return fClientData;
|
||||
}
|
||||
|
||||
|
||||
overlay_token
|
||||
OverlayCookie::OverlayToken() const
|
||||
{
|
||||
return fOverlayToken;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
OverlayCookie::Show()
|
||||
{
|
||||
// TODO: acquire token!
|
||||
if (fOverlayToken == NULL) {
|
||||
printf("%p: no overlay token\n", this);
|
||||
return;
|
||||
}
|
||||
|
||||
fHWInterface.ShowOverlay(this);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
OverlayCookie::Hide()
|
||||
{
|
||||
// TODO: acquire token!
|
||||
if (fOverlayToken == NULL) {
|
||||
printf("%p: no overlay token\n", this);
|
||||
return;
|
||||
}
|
||||
|
||||
fHWInterface.HideOverlay(this);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
OverlayCookie::SetView(const BRect& source, const BRect& destination)
|
||||
{
|
||||
fSource = source;
|
||||
fDestination = destination;
|
||||
|
||||
if (fOverlayToken == NULL) {
|
||||
printf("%p: no overlay token\n", this);
|
||||
return;
|
||||
}
|
||||
|
||||
fHWInterface.UpdateOverlay(this);
|
||||
}
|
||||
|
||||
|
@ -16,14 +16,11 @@
|
||||
#include <Rect.h>
|
||||
#include <OS.h>
|
||||
|
||||
#include <video_overlay.h>
|
||||
|
||||
|
||||
class BitmapManager;
|
||||
class ClientMemoryAllocator;
|
||||
class HWInterface;
|
||||
class OverlayCookie;
|
||||
struct overlay_client_data;
|
||||
class Overlay;
|
||||
|
||||
|
||||
/*!
|
||||
\class ServerBitmap ServerBitmap.h
|
||||
@ -69,8 +66,8 @@ class ServerBitmap {
|
||||
area_id Area() const;
|
||||
uint32 AreaOffset() const;
|
||||
|
||||
void SetOverlayCookie(::OverlayCookie* cookie);
|
||||
::OverlayCookie* OverlayCookie() const;
|
||||
void SetOverlay(::Overlay* cookie);
|
||||
::Overlay* Overlay() const;
|
||||
|
||||
//! Does a shallow copy of the bitmap passed to it
|
||||
inline void ShallowCopy(const ServerBitmap *from);
|
||||
@ -109,7 +106,7 @@ protected:
|
||||
|
||||
ClientMemoryAllocator* fAllocator;
|
||||
void* fAllocationCookie;
|
||||
::OverlayCookie* fOverlayCookie;
|
||||
::Overlay* fOverlay;
|
||||
uint8* fBuffer;
|
||||
int32 fReferenceCount;
|
||||
|
||||
@ -140,54 +137,6 @@ class UtilityBitmap : public ServerBitmap {
|
||||
virtual ~UtilityBitmap();
|
||||
};
|
||||
|
||||
//! An allocation cookie for overlays
|
||||
class OverlayCookie {
|
||||
public:
|
||||
OverlayCookie(HWInterface& interface);
|
||||
~OverlayCookie();
|
||||
|
||||
status_t InitCheck() const;
|
||||
|
||||
void SetOverlayData(const overlay_buffer* overlayBuffer,
|
||||
overlay_token token, overlay_client_data* clientData);
|
||||
void TakeOverToken(OverlayCookie* other);
|
||||
|
||||
const overlay_buffer* OverlayBuffer() const;
|
||||
overlay_client_data* ClientData() const;
|
||||
overlay_token OverlayToken() const;
|
||||
|
||||
sem_id Semaphore() const
|
||||
{ return fSemaphore; }
|
||||
|
||||
const RGBColor& Color() const
|
||||
{ return fColor; }
|
||||
|
||||
void SetVisible(bool visible)
|
||||
{ fVisible = visible; }
|
||||
bool IsVisible() const
|
||||
{ return fVisible; }
|
||||
|
||||
void SetView(const BRect& source, const BRect& destination);
|
||||
const BRect& Source() const
|
||||
{ return fSource; }
|
||||
const BRect& Destination() const
|
||||
{ return fDestination; }
|
||||
|
||||
void Show();
|
||||
void Hide();
|
||||
|
||||
private:
|
||||
HWInterface& fHWInterface;
|
||||
const overlay_buffer* fOverlayBuffer;
|
||||
overlay_client_data* fClientData;
|
||||
overlay_token fOverlayToken;
|
||||
sem_id fSemaphore;
|
||||
RGBColor fColor;
|
||||
BRect fSource;
|
||||
BRect fDestination;
|
||||
bool fVisible;
|
||||
};
|
||||
|
||||
// ShallowCopy (only for server bitmaps)
|
||||
void
|
||||
ServerBitmap::ShallowCopy(const ServerBitmap* from)
|
||||
|
@ -20,30 +20,15 @@
|
||||
mouse and key events from the server to its window, and other such things.
|
||||
*/
|
||||
|
||||
#include <new>
|
||||
|
||||
#include <AppDefs.h>
|
||||
#include <DirectWindow.h>
|
||||
#include <GraphicsDefs.h>
|
||||
#include <Message.h>
|
||||
#include <PortLink.h>
|
||||
#include <Rect.h>
|
||||
#include <View.h>
|
||||
#include <ViewAux.h>
|
||||
#include <Autolock.h>
|
||||
#include <TokenSpace.h>
|
||||
#include <WindowInfo.h>
|
||||
#include <WindowPrivate.h>
|
||||
|
||||
#include <DirectWindowPrivate.h>
|
||||
#include <MessagePrivate.h>
|
||||
#include <PictureProtocol.h>
|
||||
#include "ServerWindow.h"
|
||||
|
||||
#include "AppServer.h"
|
||||
#include "DebugInfoManager.h"
|
||||
#include "Desktop.h"
|
||||
#include "DrawingEngine.h"
|
||||
#include "HWInterface.h"
|
||||
#include "Overlay.h"
|
||||
#include "RAMLinkMsgReader.h"
|
||||
#include "RenderingBuffer.h"
|
||||
#include "ServerApp.h"
|
||||
@ -53,10 +38,24 @@
|
||||
#include "WindowLayer.h"
|
||||
#include "WorkspacesLayer.h"
|
||||
|
||||
#include "ServerWindow.h"
|
||||
|
||||
#include "clipping.h"
|
||||
|
||||
#include <DirectWindowPrivate.h>
|
||||
#include <MessagePrivate.h>
|
||||
#include <PictureProtocol.h>
|
||||
#include <PortLink.h>
|
||||
#include <ViewAux.h>
|
||||
#include <WindowInfo.h>
|
||||
#include <WindowPrivate.h>
|
||||
|
||||
#include <AppDefs.h>
|
||||
#include <Autolock.h>
|
||||
#include <DirectWindow.h>
|
||||
#include <TokenSpace.h>
|
||||
#include <View.h>
|
||||
|
||||
#include <new>
|
||||
|
||||
using std::nothrow;
|
||||
|
||||
//#define TRACE_SERVER_WINDOW
|
||||
@ -1514,8 +1513,8 @@ ServerWindow::_DispatchViewMessage(int32 code,
|
||||
BRegion dirty(fCurrentLayer->Bounds());
|
||||
fWindowLayer->InvalidateView(fCurrentLayer, dirty);
|
||||
|
||||
if (bitmap != NULL && bitmap->OverlayCookie() != NULL)
|
||||
colorKey = bitmap->OverlayCookie()->Color().GetColor32();
|
||||
if (bitmap != NULL && bitmap->Overlay() != NULL)
|
||||
colorKey = bitmap->Overlay()->Color().GetColor32();
|
||||
} else
|
||||
status = B_BAD_VALUE;
|
||||
}
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include <Message.h>
|
||||
#include <Messenger.h>
|
||||
#include <Rect.h>
|
||||
#include <Region.h>
|
||||
#include <String.h>
|
||||
#include <Window.h>
|
||||
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "BitmapManager.h"
|
||||
#include "Desktop.h"
|
||||
#include "DrawingEngine.h"
|
||||
#include "Overlay.h"
|
||||
#include "ServerApp.h"
|
||||
#include "ServerBitmap.h"
|
||||
#include "ServerCursor.h"
|
||||
@ -272,8 +273,13 @@ ViewLayer::RemoveChild(ViewLayer* layer)
|
||||
layer->fPreviousSibling = NULL;
|
||||
layer->fNextSibling = NULL;
|
||||
|
||||
if (layer->IsVisible())
|
||||
if (layer->IsVisible()) {
|
||||
Overlay* overlay = _Overlay();
|
||||
if (overlay != NULL)
|
||||
overlay->Hide();
|
||||
|
||||
RebuildClipping(false);
|
||||
}
|
||||
|
||||
if (fWindow) {
|
||||
layer->DetachedFromWindow();
|
||||
@ -452,8 +458,8 @@ ViewLayer::SetViewBitmap(ServerBitmap* bitmap, BRect sourceRect,
|
||||
if (fViewBitmap != NULL) {
|
||||
if (bitmap != NULL) {
|
||||
// take over overlay token from current overlay (if it has any)
|
||||
OverlayCookie* oldOverlay = _Overlay();
|
||||
OverlayCookie* newOverlay = bitmap->OverlayCookie();
|
||||
Overlay* oldOverlay = _Overlay();
|
||||
Overlay* newOverlay = bitmap->Overlay();
|
||||
|
||||
if (oldOverlay != NULL && newOverlay != NULL)
|
||||
newOverlay->TakeOverToken(oldOverlay);
|
||||
@ -483,20 +489,20 @@ ViewLayer::SetViewBitmap(ServerBitmap* bitmap, BRect sourceRect,
|
||||
}
|
||||
|
||||
|
||||
OverlayCookie*
|
||||
::Overlay*
|
||||
ViewLayer::_Overlay() const
|
||||
{
|
||||
if (fViewBitmap == NULL)
|
||||
return NULL;
|
||||
|
||||
return fViewBitmap->OverlayCookie();
|
||||
return fViewBitmap->Overlay();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ViewLayer::_UpdateOverlayView() const
|
||||
{
|
||||
OverlayCookie* overlay = _Overlay();
|
||||
Overlay* overlay = _Overlay();
|
||||
if (overlay == NULL)
|
||||
return;
|
||||
|
||||
@ -1032,7 +1038,7 @@ ViewLayer::Draw(DrawingEngine* drawingEngine, BRegion* effectiveClipping,
|
||||
// add the current clipping
|
||||
redraw->IntersectWith(effectiveClipping);
|
||||
|
||||
OverlayCookie* overlayCookie = _Overlay();
|
||||
Overlay* overlayCookie = _Overlay();
|
||||
|
||||
if (fViewBitmap != NULL && overlayCookie == NULL) {
|
||||
// draw view bitmap
|
||||
@ -1214,7 +1220,7 @@ ViewLayer::UpdateVisibleDeep(bool parentVisible)
|
||||
|
||||
// overlay handling
|
||||
|
||||
OverlayCookie* overlay = _Overlay();
|
||||
Overlay* overlay = _Overlay();
|
||||
if (overlay == NULL)
|
||||
return;
|
||||
|
||||
|
@ -26,7 +26,7 @@ namespace BPrivate {
|
||||
|
||||
class DrawState;
|
||||
class DrawingEngine;
|
||||
class OverlayCookie;
|
||||
class Overlay;
|
||||
class WindowLayer;
|
||||
class ServerBitmap;
|
||||
class ServerCursor;
|
||||
@ -209,7 +209,7 @@ class ViewLayer {
|
||||
protected:
|
||||
void _MoveScreenClipping(int32 x, int32 y,
|
||||
bool deep);
|
||||
OverlayCookie* _Overlay() const;
|
||||
Overlay* _Overlay() const;
|
||||
void _UpdateOverlayView() const;
|
||||
|
||||
BString fName;
|
||||
|
@ -10,28 +10,29 @@
|
||||
|
||||
/** Accelerant based HWInterface implementation */
|
||||
|
||||
#include <new>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <Cursor.h>
|
||||
|
||||
#include <Accelerant.h>
|
||||
#include <graphic_driver.h>
|
||||
#include <FindDirectory.h>
|
||||
#include <image.h>
|
||||
#include <dirent.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <unistd.h>
|
||||
#include "AccelerantHWInterface.h"
|
||||
|
||||
#include "AccelerantBuffer.h"
|
||||
#include "MallocBuffer.h"
|
||||
#include "Overlay.h"
|
||||
#include "RGBColor.h"
|
||||
#include "ServerConfig.h"
|
||||
#include "ServerCursor.h"
|
||||
#include "ServerProtocol.h"
|
||||
|
||||
#include "AccelerantHWInterface.h"
|
||||
#include "AccelerantBuffer.h"
|
||||
#include "MallocBuffer.h"
|
||||
#include <Accelerant.h>
|
||||
#include <Cursor.h>
|
||||
#include <FindDirectory.h>
|
||||
#include <graphic_driver.h>
|
||||
#include <image.h>
|
||||
|
||||
#include <dirent.h>
|
||||
#include <new>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
using std::nothrow;
|
||||
|
||||
@ -762,21 +763,21 @@ AccelerantHWInterface::FreeOverlayBuffer(const overlay_buffer* buffer)
|
||||
|
||||
|
||||
void
|
||||
AccelerantHWInterface::ShowOverlay(OverlayCookie* overlay)
|
||||
AccelerantHWInterface::ShowOverlay(Overlay* overlay)
|
||||
{
|
||||
UpdateOverlay(overlay);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AccelerantHWInterface::HideOverlay(OverlayCookie* overlay)
|
||||
AccelerantHWInterface::HideOverlay(Overlay* overlay)
|
||||
{
|
||||
fAccConfigureOverlay(overlay->OverlayToken(), overlay->OverlayBuffer(), NULL, NULL);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AccelerantHWInterface::UpdateOverlay(OverlayCookie* overlay)
|
||||
AccelerantHWInterface::UpdateOverlay(Overlay* overlay)
|
||||
{
|
||||
const overlay_buffer* buffer = overlay->OverlayBuffer();
|
||||
|
||||
|
@ -65,9 +65,9 @@ public:
|
||||
color_space space);
|
||||
virtual void FreeOverlayBuffer(const overlay_buffer* buffer);
|
||||
|
||||
virtual void ShowOverlay(OverlayCookie* overlay);
|
||||
virtual void HideOverlay(OverlayCookie* overlay);
|
||||
virtual void UpdateOverlay(OverlayCookie* overlay);
|
||||
virtual void ShowOverlay(Overlay* overlay);
|
||||
virtual void HideOverlay(Overlay* overlay);
|
||||
virtual void UpdateOverlay(Overlay* overlay);
|
||||
|
||||
// accelerated drawing
|
||||
virtual void CopyRegion(const clipping_rect* sortedRectList,
|
||||
|
@ -336,19 +336,19 @@ HWInterface::FreeOverlayBuffer(const overlay_buffer* buffer)
|
||||
|
||||
|
||||
void
|
||||
HWInterface::ShowOverlay(OverlayCookie* overlay)
|
||||
HWInterface::ShowOverlay(Overlay* overlay)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
HWInterface::HideOverlay(OverlayCookie* overlay)
|
||||
HWInterface::HideOverlay(Overlay* overlay)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
HWInterface::UpdateOverlay(OverlayCookie* overlay)
|
||||
HWInterface::UpdateOverlay(Overlay* overlay)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
#include <Region.h>
|
||||
|
||||
|
||||
class OverlayCookie;
|
||||
class Overlay;
|
||||
class RenderingBuffer;
|
||||
class RGBColor;
|
||||
class ServerBitmap;
|
||||
@ -107,9 +107,9 @@ class HWInterface : public MultiLocker {
|
||||
color_space space);
|
||||
virtual void FreeOverlayBuffer(const overlay_buffer* buffer);
|
||||
|
||||
virtual void ShowOverlay(OverlayCookie* overlay);
|
||||
virtual void HideOverlay(OverlayCookie* overlay);
|
||||
virtual void UpdateOverlay(OverlayCookie* overlay);
|
||||
virtual void ShowOverlay(Overlay* overlay);
|
||||
virtual void HideOverlay(Overlay* overlay);
|
||||
virtual void UpdateOverlay(Overlay* overlay);
|
||||
|
||||
// frame buffer access (you need to ReadLock!)
|
||||
RenderingBuffer* DrawingBuffer() const;
|
||||
|
@ -18,6 +18,7 @@ StaticLibrary libasdrawing.a :
|
||||
MallocBuffer.cpp
|
||||
UpdateQueue.cpp
|
||||
PatternHandler.cpp
|
||||
Overlay.cpp
|
||||
|
||||
BitmapHWInterface.cpp
|
||||
BBitmapBuffer.cpp
|
||||
|
125
src/servers/app/drawing/Overlay.cpp
Normal file
125
src/servers/app/drawing/Overlay.cpp
Normal file
@ -0,0 +1,125 @@
|
||||
/*
|
||||
* Copyright 2006, Haiku, Inc.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Axel Dörfler, axeld@pinc-software.de
|
||||
*/
|
||||
|
||||
|
||||
#include "HWInterface.h"
|
||||
#include "Overlay.h"
|
||||
|
||||
#include <BitmapPrivate.h>
|
||||
|
||||
|
||||
Overlay::Overlay(HWInterface& interface)
|
||||
:
|
||||
fHWInterface(interface),
|
||||
fOverlayBuffer(NULL),
|
||||
fClientData(NULL),
|
||||
fOverlayToken(NULL)
|
||||
{
|
||||
fSemaphore = create_sem(1, "overlay lock");
|
||||
fColor.SetColor(21, 16, 21, 16);
|
||||
// TODO: whatever fine color we want to use here...
|
||||
}
|
||||
|
||||
|
||||
Overlay::~Overlay()
|
||||
{
|
||||
fHWInterface.ReleaseOverlayChannel(fOverlayToken);
|
||||
fHWInterface.FreeOverlayBuffer(fOverlayBuffer);
|
||||
|
||||
delete_sem(fSemaphore);
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
Overlay::InitCheck() const
|
||||
{
|
||||
return fSemaphore >= B_OK ? B_OK : fSemaphore;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Overlay::SetOverlayData(const overlay_buffer* overlayBuffer,
|
||||
overlay_token token, overlay_client_data* clientData)
|
||||
{
|
||||
fOverlayBuffer = overlayBuffer;
|
||||
fOverlayToken = token;
|
||||
|
||||
fClientData = clientData;
|
||||
fClientData->lock = fSemaphore;
|
||||
fClientData->buffer = (uint8*)fOverlayBuffer->buffer;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Overlay::TakeOverToken(Overlay* other)
|
||||
{
|
||||
overlay_token token = other->OverlayToken();
|
||||
if (token == NULL)
|
||||
return;
|
||||
|
||||
fOverlayToken = token;
|
||||
//other->fOverlayToken = NULL;
|
||||
}
|
||||
|
||||
|
||||
const overlay_buffer*
|
||||
Overlay::OverlayBuffer() const
|
||||
{
|
||||
return fOverlayBuffer;
|
||||
}
|
||||
|
||||
|
||||
overlay_client_data*
|
||||
Overlay::ClientData() const
|
||||
{
|
||||
return fClientData;
|
||||
}
|
||||
|
||||
|
||||
overlay_token
|
||||
Overlay::OverlayToken() const
|
||||
{
|
||||
return fOverlayToken;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Overlay::Show()
|
||||
{
|
||||
if (fOverlayToken == NULL) {
|
||||
fOverlayToken = fHWInterface.AcquireOverlayChannel();
|
||||
if (fOverlayToken == NULL)
|
||||
return;
|
||||
}
|
||||
|
||||
fHWInterface.ShowOverlay(this);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Overlay::Hide()
|
||||
{
|
||||
if (fOverlayToken == NULL)
|
||||
return;
|
||||
|
||||
fHWInterface.HideOverlay(this);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Overlay::SetView(const BRect& source, const BRect& destination)
|
||||
{
|
||||
fSource = source;
|
||||
fDestination = destination;
|
||||
|
||||
if (fOverlayToken == NULL)
|
||||
return;
|
||||
|
||||
fHWInterface.UpdateOverlay(this);
|
||||
}
|
||||
|
72
src/servers/app/drawing/Overlay.h
Normal file
72
src/servers/app/drawing/Overlay.h
Normal file
@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright 2006, Haiku, Inc.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Axel Dörfler, axeld@pinc-software.de
|
||||
*/
|
||||
#ifndef OVERLAY_H
|
||||
#define OVERLAY_H
|
||||
|
||||
|
||||
#include "RGBColor.h"
|
||||
|
||||
#include <video_overlay.h>
|
||||
|
||||
//#include <GraphicsDefs.h>
|
||||
//#include <Rect.h>
|
||||
//#include <OS.h>
|
||||
|
||||
|
||||
class HWInterface;
|
||||
struct overlay_client_data;
|
||||
|
||||
|
||||
class Overlay {
|
||||
public:
|
||||
Overlay(HWInterface& interface);
|
||||
~Overlay();
|
||||
|
||||
status_t InitCheck() const;
|
||||
|
||||
void SetOverlayData(const overlay_buffer* overlayBuffer,
|
||||
overlay_token token, overlay_client_data* clientData);
|
||||
void TakeOverToken(Overlay* other);
|
||||
|
||||
const overlay_buffer* OverlayBuffer() const;
|
||||
overlay_client_data* ClientData() const;
|
||||
overlay_token OverlayToken() const;
|
||||
|
||||
sem_id Semaphore() const
|
||||
{ return fSemaphore; }
|
||||
|
||||
const RGBColor& Color() const
|
||||
{ return fColor; }
|
||||
|
||||
void SetVisible(bool visible)
|
||||
{ fVisible = visible; }
|
||||
bool IsVisible() const
|
||||
{ return fVisible; }
|
||||
|
||||
void SetView(const BRect& source, const BRect& destination);
|
||||
const BRect& Source() const
|
||||
{ return fSource; }
|
||||
const BRect& Destination() const
|
||||
{ return fDestination; }
|
||||
|
||||
void Show();
|
||||
void Hide();
|
||||
|
||||
private:
|
||||
HWInterface& fHWInterface;
|
||||
const overlay_buffer* fOverlayBuffer;
|
||||
overlay_client_data* fClientData;
|
||||
overlay_token fOverlayToken;
|
||||
sem_id fSemaphore;
|
||||
RGBColor fColor;
|
||||
BRect fSource;
|
||||
BRect fDestination;
|
||||
bool fVisible;
|
||||
};
|
||||
|
||||
#endif // OVERLAY_H
|
@ -62,6 +62,7 @@ SharedLibrary libhaikuappserver.so :
|
||||
FontManager.cpp
|
||||
HashTable.cpp
|
||||
MultiLocker.cpp
|
||||
Overlay.cpp
|
||||
RGBColor.cpp
|
||||
ServerBitmap.cpp
|
||||
ServerCursor.cpp
|
||||
|
Loading…
Reference in New Issue
Block a user