* Changed the way the overlay_view|window is maintained - it's now in Overlay.

* The overlay options as part of BView::SetViewOverlay() are now passed over
  to the graphics driver - looks like the color key stuff cannot be turned
  off (at least not via the Be API).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17323 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2006-05-04 20:25:19 +00:00
parent f2274165dd
commit da09cca402
4 changed files with 92 additions and 66 deletions
+3 -1
View File
@@ -1532,8 +1532,10 @@ ServerWindow::_DispatchViewMessage(int32 code,
fWindowLayer->InvalidateView(fCurrentLayer, dirty);
}
if (bitmap != NULL && bitmap->Overlay() != NULL)
if (bitmap != NULL && bitmap->Overlay() != NULL) {
bitmap->Overlay()->SetFlags(options);
colorKey = bitmap->Overlay()->Color().GetColor32();
}
} else
status = B_BAD_VALUE;
}
@@ -374,6 +374,12 @@ AccelerantHWInterface::SetMode(const display_mode &mode)
return B_OK;
}
// some safety checks
// TODO: more of those!
if (fDisplayMode.virtual_width < 320
|| fDisplayMode.virtual_height < 200)
return B_BAD_VALUE;
// just try to set the mode - we let the graphics driver
// approve or deny the request, as it should know best
@@ -790,59 +796,11 @@ AccelerantHWInterface::HideOverlay(Overlay* overlay)
void
AccelerantHWInterface::UpdateOverlay(Overlay* overlay)
{
const overlay_buffer* buffer = overlay->OverlayBuffer();
// TODO: this only needs to be done on mode changes!
overlay->SetColorSpace(fDisplayMode.space);
overlay_view view;
view.h_start = (uint16)overlay->Source().left;
view.v_start = (uint16)overlay->Source().top;
view.width = (uint16)overlay->Source().IntegerWidth() + 1;
view.height = (uint16)overlay->Source().IntegerHeight() + 1;
overlay_window window;
window.h_start = (int16)overlay->Destination().left;
window.v_start = (int16)overlay->Destination().top;
window.width = (uint16)overlay->Destination().IntegerWidth() + 1;
window.height = (uint16)overlay->Destination().IntegerHeight() + 1;
window.offset_top = 0;
window.offset_left = 0;
window.offset_right = 0;
window.offset_bottom = 0;
// TODO: for now, this should be done somewhere else, ideally
rgb_color colorKey = overlay->Color().GetColor32();
uint8 colorShift = 0, greenShift = 0, alphaShift = 0;
switch (fDisplayMode.space) {
case B_CMAP8:
colorKey.red = 0xff;
colorKey.green = 0xff;
colorKey.blue = 0xff;
colorKey.alpha = 0xff;
break;
case B_RGB15:
greenShift = colorShift = 3;
alphaShift = 7;
break;
case B_RGB16:
colorShift = 3;
greenShift = 2;
alphaShift = 8;
break;
}
window.red.value = colorKey.red >> colorShift;
window.green.value = colorKey.green >> greenShift;
window.blue.value = colorKey.blue >> colorShift;
window.alpha.value = colorKey.alpha >> alphaShift;
window.red.mask = 0xff >> colorShift;
window.green.mask = 0xff >> greenShift;
window.blue.mask = 0xff >> colorShift;
window.alpha.mask = 0xff >> alphaShift;
// TODO: we need the 'uint32 options' from BView::SetViewOverlay() here
// for now using commonly used settings (should be 'safe')
window.flags =
B_OVERLAY_COLOR_KEY | B_OVERLAY_VERTICAL_FILTERING | B_OVERLAY_HORIZONTAL_FILTERING;
fAccConfigureOverlay(overlay->OverlayToken(), buffer, &window, &view);
fAccConfigureOverlay(overlay->OverlayToken(), overlay->OverlayBuffer(),
overlay->OverlayWindow(), overlay->OverlayView());
}
+69 -3
View File
@@ -12,6 +12,8 @@
#include <BitmapPrivate.h>
#include <InterfaceDefs.h>
Overlay::Overlay(HWInterface& interface)
:
@@ -23,6 +25,13 @@ Overlay::Overlay(HWInterface& interface)
fSemaphore = create_sem(1, "overlay lock");
fColor.SetColor(21, 16, 21, 16);
// TODO: whatever fine color we want to use here...
fWindow.offset_top = 0;
fWindow.offset_left = 0;
fWindow.offset_right = 0;
fWindow.offset_bottom = 0;
fWindow.flags = B_OVERLAY_COLOR_KEY;
}
@@ -55,6 +64,18 @@ Overlay::SetOverlayData(const overlay_buffer* overlayBuffer,
}
void
Overlay::SetFlags(uint32 flags)
{
if (flags & B_OVERLAY_FILTER_HORIZONTAL)
fWindow.flags |= B_OVERLAY_HORIZONTAL_FILTERING;
if (flags & B_OVERLAY_FILTER_VERTICAL)
fWindow.flags |= B_OVERLAY_VERTICAL_FILTERING;
if (flags & B_OVERLAY_MIRROR)
fWindow.flags |= B_OVERLAY_HORIZONTAL_MIRRORING;
}
void
Overlay::TakeOverToken(Overlay* other)
{
@@ -111,15 +132,60 @@ Overlay::Hide()
}
void
Overlay::SetColorSpace(uint32 colorSpace)
{
if ((fWindow.flags & B_OVERLAY_COLOR_KEY) == 0)
return;
uint8 colorShift = 0, greenShift = 0, alphaShift = 0;
rgb_color colorKey = fColor.GetColor32();
switch (colorSpace) {
case B_CMAP8:
colorKey.red = 0xff;
colorKey.green = 0xff;
colorKey.blue = 0xff;
colorKey.alpha = 0xff;
break;
case B_RGB15:
greenShift = colorShift = 3;
alphaShift = 7;
break;
case B_RGB16:
colorShift = 3;
greenShift = 2;
alphaShift = 8;
break;
}
fWindow.red.value = colorKey.red >> colorShift;
fWindow.green.value = colorKey.green >> greenShift;
fWindow.blue.value = colorKey.blue >> colorShift;
fWindow.alpha.value = colorKey.alpha >> alphaShift;
fWindow.red.mask = 0xff >> colorShift;
fWindow.green.mask = 0xff >> greenShift;
fWindow.blue.mask = 0xff >> colorShift;
fWindow.alpha.mask = 0xff >> alphaShift;
}
void
Overlay::SetView(const BRect& source, const BRect& destination)
{
fSource = source;
fDestination = destination;
if (fOverlayToken == NULL)
return;
fView.h_start = (uint16)source.left;
fView.v_start = (uint16)source.top;
fView.width = (uint16)source.IntegerWidth() + 1;
fView.height = (uint16)source.IntegerHeight() + 1;
fWindow.h_start = (int16)destination.left;
fWindow.v_start = (int16)destination.top;
fWindow.width = (uint16)destination.IntegerWidth() + 1;
fWindow.height = (uint16)destination.IntegerHeight() + 1;
fHWInterface.UpdateOverlay(this);
}
+10 -10
View File
@@ -13,10 +13,6 @@
#include <video_overlay.h>
//#include <GraphicsDefs.h>
//#include <Rect.h>
//#include <OS.h>
class HWInterface;
struct overlay_client_data;
@@ -31,12 +27,20 @@ class Overlay {
void SetOverlayData(const overlay_buffer* overlayBuffer,
overlay_token token, overlay_client_data* clientData);
void SetFlags(uint32 flags);
void TakeOverToken(Overlay* other);
const overlay_buffer* OverlayBuffer() const;
overlay_client_data* ClientData() const;
overlay_token OverlayToken() const;
void SetColorSpace(uint32 colorSpace);
const overlay_window* OverlayWindow() const
{ return &fWindow; }
const overlay_view* OverlayView() const
{ return &fView; }
sem_id Semaphore() const
{ return fSemaphore; }
@@ -49,10 +53,6 @@ class Overlay {
{ 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();
@@ -62,10 +62,10 @@ class Overlay {
const overlay_buffer* fOverlayBuffer;
overlay_client_data* fClientData;
overlay_token fOverlayToken;
overlay_view fView;
overlay_window fWindow;
sem_id fSemaphore;
RGBColor fColor;
BRect fSource;
BRect fDestination;
bool fVisible;
};