Implemented basic server side BView::SetViewBitmap() support. Things like B_TILE_BITMAP
or even the resizing mode isn't done yet, though. See TODOs. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15720 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1453,13 +1453,39 @@ ServerWindow::_DispatchViewMessage(int32 code,
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case AS_LAYER_SET_VIEW_BITMAP:
|
||||||
|
{
|
||||||
|
int32 bitmapToken, resizingMode, options;
|
||||||
|
BRect srcRect, dstRect;
|
||||||
|
|
||||||
|
link.Read<int32>(&bitmapToken);
|
||||||
|
link.Read<BRect>(&srcRect);
|
||||||
|
link.Read<BRect>(&dstRect);
|
||||||
|
link.Read<int32>(&resizingMode);
|
||||||
|
status_t status = link.Read<int32>(&options);
|
||||||
|
|
||||||
|
if (status == B_OK) {
|
||||||
|
ServerBitmap* bitmap = fServerApp->FindBitmap(bitmapToken);
|
||||||
|
if (bitmapToken == -1 || bitmap != NULL) {
|
||||||
|
fCurrentLayer->SetViewBitmap(bitmap, srcRect, dstRect,
|
||||||
|
resizingMode, options);
|
||||||
|
|
||||||
|
BRegion dirty(fCurrentLayer->Bounds());
|
||||||
|
fWindowLayer->InvalidateView(fCurrentLayer, dirty);
|
||||||
|
} else
|
||||||
|
status = B_BAD_VALUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
fLink.StartMessage(status);
|
||||||
|
fLink.Flush();
|
||||||
|
break;
|
||||||
|
}
|
||||||
case AS_LAYER_PRINT_ALIASING:
|
case AS_LAYER_PRINT_ALIASING:
|
||||||
{
|
{
|
||||||
DTRACE(("ServerWindow %s: Message AS_LAYER_PRINT_ALIASING: ViewLayer: %s\n", Title(), fCurrentLayer->Name()));
|
DTRACE(("ServerWindow %s: Message AS_LAYER_PRINT_ALIASING: ViewLayer: %s\n", Title(), fCurrentLayer->Name()));
|
||||||
bool fontAliasing;
|
bool fontAliasing;
|
||||||
link.Read<bool>(&fontAliasing);
|
if (link.Read<bool>(&fontAliasing) == B_OK)
|
||||||
fCurrentLayer->CurrentState()->SetForceFontAliasing(fontAliasing);
|
fCurrentLayer->CurrentState()->SetForceFontAliasing(fontAliasing);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case AS_LAYER_CLIP_TO_PICTURE:
|
case AS_LAYER_CLIP_TO_PICTURE:
|
||||||
|
|||||||
@@ -11,9 +11,11 @@
|
|||||||
|
|
||||||
#include "ViewLayer.h"
|
#include "ViewLayer.h"
|
||||||
|
|
||||||
|
#include "BitmapManager.h"
|
||||||
#include "Desktop.h"
|
#include "Desktop.h"
|
||||||
#include "DrawingEngine.h"
|
#include "DrawingEngine.h"
|
||||||
#include "ServerApp.h"
|
#include "ServerApp.h"
|
||||||
|
#include "ServerBitmap.h"
|
||||||
#include "ServerWindow.h"
|
#include "ServerWindow.h"
|
||||||
#include "WindowLayer.h"
|
#include "WindowLayer.h"
|
||||||
|
|
||||||
@@ -37,6 +39,7 @@ ViewLayer::ViewLayer(BRect frame, const char* name,
|
|||||||
|
|
||||||
fViewColor(RGBColor(255, 255, 255)),
|
fViewColor(RGBColor(255, 255, 255)),
|
||||||
fDrawState(new (nothrow) DrawState),
|
fDrawState(new (nothrow) DrawState),
|
||||||
|
fViewBitmap(NULL),
|
||||||
|
|
||||||
fResizeMode(resizeMode),
|
fResizeMode(resizeMode),
|
||||||
fFlags(flags),
|
fFlags(flags),
|
||||||
@@ -372,6 +375,25 @@ ViewLayer::SetUserClipping(const BRegion& region)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
ViewLayer::SetViewBitmap(ServerBitmap* bitmap, BRect sourceRect,
|
||||||
|
BRect destRect, int32 resizingMode, int32 options)
|
||||||
|
{
|
||||||
|
if (fViewBitmap != NULL)
|
||||||
|
gBitmapManager->DeleteBitmap(fViewBitmap);
|
||||||
|
|
||||||
|
// the caller is allowed to delete the bitmap after setting the background
|
||||||
|
if (bitmap != NULL)
|
||||||
|
bitmap->Acquire();
|
||||||
|
|
||||||
|
fViewBitmap = bitmap;
|
||||||
|
fBitmapSource = sourceRect;
|
||||||
|
fBitmapDestination = destRect;
|
||||||
|
fBitmapResizingMode = resizingMode;
|
||||||
|
fBitmapOptions = options;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ViewLayer::ConvertToParent(BPoint* point) const
|
ViewLayer::ConvertToParent(BPoint* point) const
|
||||||
{
|
{
|
||||||
@@ -844,6 +866,22 @@ ViewLayer::Draw(DrawingEngine* drawingEngine, BRegion* effectiveClipping,
|
|||||||
// add the current clipping
|
// add the current clipping
|
||||||
redraw.IntersectWith(effectiveClipping);
|
redraw.IntersectWith(effectiveClipping);
|
||||||
|
|
||||||
|
if (fViewBitmap != NULL) {
|
||||||
|
// draw view bitmap
|
||||||
|
// TODO: support other options!
|
||||||
|
BRect rect = fBitmapDestination;
|
||||||
|
ConvertToScreenForDrawing(&rect);
|
||||||
|
|
||||||
|
// TODO: this messes with the screen clipping, but might not be supposed to do so.
|
||||||
|
drawingEngine->ConstrainClippingRegion(&redraw);
|
||||||
|
// TODO: fDrawState is probably not what we want to use here...
|
||||||
|
drawingEngine->DrawBitmap(fViewBitmap, fBitmapSource,
|
||||||
|
rect, fDrawState);
|
||||||
|
drawingEngine->ConstrainClippingRegion(NULL);
|
||||||
|
|
||||||
|
redraw.Exclude(rect);
|
||||||
|
}
|
||||||
|
|
||||||
if (!fViewColor.IsTransparentMagic()) {
|
if (!fViewColor.IsTransparentMagic()) {
|
||||||
// fill visible region with view color
|
// fill visible region with view color
|
||||||
drawingEngine->FillRegion(redraw, fViewColor);
|
drawingEngine->FillRegion(redraw, fViewColor);
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ class BList;
|
|||||||
class DrawState;
|
class DrawState;
|
||||||
class DrawingEngine;
|
class DrawingEngine;
|
||||||
class WindowLayer;
|
class WindowLayer;
|
||||||
|
class ServerBitmap;
|
||||||
|
|
||||||
|
|
||||||
class ViewLayer {
|
class ViewLayer {
|
||||||
@@ -133,6 +134,8 @@ class ViewLayer {
|
|||||||
{ return fViewColor; }
|
{ return fViewColor; }
|
||||||
void SetViewColor(const RGBColor& color)
|
void SetViewColor(const RGBColor& color)
|
||||||
{ fViewColor = color; }
|
{ fViewColor = color; }
|
||||||
|
void SetViewBitmap(ServerBitmap* bitmap, BRect sourceRect,
|
||||||
|
BRect destRect, int32 resizingMode, int32 options);
|
||||||
|
|
||||||
void PushState();
|
void PushState();
|
||||||
void PopState();
|
void PopState();
|
||||||
@@ -188,6 +191,11 @@ class ViewLayer {
|
|||||||
|
|
||||||
RGBColor fViewColor;
|
RGBColor fViewColor;
|
||||||
DrawState* fDrawState;
|
DrawState* fDrawState;
|
||||||
|
ServerBitmap* fViewBitmap;
|
||||||
|
BRect fBitmapSource;
|
||||||
|
BRect fBitmapDestination;
|
||||||
|
int32 fBitmapResizingMode;
|
||||||
|
int32 fBitmapOptions;
|
||||||
|
|
||||||
uint32 fResizeMode;
|
uint32 fResizeMode;
|
||||||
uint32 fFlags;
|
uint32 fFlags;
|
||||||
|
|||||||
Reference in New Issue
Block a user