diff --git a/src/servers/app/ServerWindow.cpp b/src/servers/app/ServerWindow.cpp index 8c29b14bbe..bb1c03f667 100644 --- a/src/servers/app/ServerWindow.cpp +++ b/src/servers/app/ServerWindow.cpp @@ -1453,34 +1453,60 @@ ServerWindow::_DispatchViewMessage(int32 code, break; } + case AS_LAYER_SET_VIEW_BITMAP: + { + int32 bitmapToken, resizingMode, options; + BRect srcRect, dstRect; + + link.Read(&bitmapToken); + link.Read(&srcRect); + link.Read(&dstRect); + link.Read(&resizingMode); + status_t status = link.Read(&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(&fontAliasing); - fCurrentLayer->CurrentState()->SetForceFontAliasing(fontAliasing); - + if (link.Read(&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(&pictureToken); link.Read(&where); link.Read(&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 (?) diff --git a/src/servers/app/ViewLayer.cpp b/src/servers/app/ViewLayer.cpp index fa9f928dad..f5bfc76e56 100644 --- a/src/servers/app/ViewLayer.cpp +++ b/src/servers/app/ViewLayer.cpp @@ -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); diff --git a/src/servers/app/ViewLayer.h b/src/servers/app/ViewLayer.h index 2a9e788caf..b1077a87bf 100644 --- a/src/servers/app/ViewLayer.h +++ b/src/servers/app/ViewLayer.h @@ -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;