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:
Axel Dörfler 2005-12-29 16:46:02 +00:00
parent 7cc0dec4a2
commit 4c66abd6f2
3 changed files with 80 additions and 8 deletions

View File

@ -1453,34 +1453,60 @@ ServerWindow::_DispatchViewMessage(int32 code,
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:
{
DTRACE(("ServerWindow %s: Message AS_LAYER_PRINT_ALIASING: ViewLayer: %s\n", Title(), fCurrentLayer->Name()));
bool fontAliasing;
link.Read<bool>(&fontAliasing);
fCurrentLayer->CurrentState()->SetForceFontAliasing(fontAliasing);
if (link.Read<bool>(&fontAliasing) == B_OK)
fCurrentLayer->CurrentState()->SetForceFontAliasing(fontAliasing);
break;
}
case AS_LAYER_CLIP_TO_PICTURE:
{
DTRACE(("ServerWindow %s: Message AS_LAYER_CLIP_TO_PICTURE: ViewLayer: %s\n", Title(), fCurrentLayer->Name()));
// TODO: you are not allowed to use ViewLayer regions here!!!
// TODO: you are not allowed to use ViewLayer regions here!!!
int32 pictureToken;
BPoint where;
bool inverse = false;
link.Read<int32>(&pictureToken);
link.Read<BPoint>(&where);
link.Read<bool>(&inverse);
// search for a picture with the specified token.
ServerPicture *picture = fServerApp->FindPicture(pictureToken);
// TODO: Increase that picture's reference count.(~ allocate a picture)
if (picture == NULL)
break;
BRegion region;
// TODO: I think we also need the BView's token
// I think PictureToRegion would fit better into the ViewLayer class (?)

View File

@ -11,9 +11,11 @@
#include "ViewLayer.h"
#include "BitmapManager.h"
#include "Desktop.h"
#include "DrawingEngine.h"
#include "ServerApp.h"
#include "ServerBitmap.h"
#include "ServerWindow.h"
#include "WindowLayer.h"
@ -37,6 +39,7 @@ ViewLayer::ViewLayer(BRect frame, const char* name,
fViewColor(RGBColor(255, 255, 255)),
fDrawState(new (nothrow) DrawState),
fViewBitmap(NULL),
fResizeMode(resizeMode),
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
ViewLayer::ConvertToParent(BPoint* point) const
{
@ -844,6 +866,22 @@ ViewLayer::Draw(DrawingEngine* drawingEngine, BRegion* effectiveClipping,
// add the current clipping
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()) {
// fill visible region with view color
drawingEngine->FillRegion(redraw, fViewColor);

View File

@ -22,6 +22,7 @@ class BList;
class DrawState;
class DrawingEngine;
class WindowLayer;
class ServerBitmap;
class ViewLayer {
@ -133,6 +134,8 @@ class ViewLayer {
{ return fViewColor; }
void SetViewColor(const RGBColor& color)
{ fViewColor = color; }
void SetViewBitmap(ServerBitmap* bitmap, BRect sourceRect,
BRect destRect, int32 resizingMode, int32 options);
void PushState();
void PopState();
@ -188,6 +191,11 @@ class ViewLayer {
RGBColor fViewColor;
DrawState* fDrawState;
ServerBitmap* fViewBitmap;
BRect fBitmapSource;
BRect fBitmapDestination;
int32 fBitmapResizingMode;
int32 fBitmapOptions;
uint32 fResizeMode;
uint32 fFlags;