1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_CANVAS_SOURCE_VCL_BITMAPBACKBUFFER_HXX
21 #define INCLUDED_CANVAS_SOURCE_VCL_BITMAPBACKBUFFER_HXX
23 #include <vcl/virdev.hxx>
24 #include <vcl/bitmapex.hxx>
26 #include <canvas/vclwrapper.hxx>
27 #include "outdevprovider.hxx"
29 #include <boost/shared_ptr.hpp>
34 /** Backbuffer implementation for canvas bitmap.
36 This class abstracts away the renderable bitmap for the bitmap
37 canvas. The actual VirtualDevice is only created when
38 necessary, which makes read-only bitmaps a lot smaller.
40 class BitmapBackBuffer
: public OutDevProvider
43 /** Create a backbuffer for given reference device
45 BitmapBackBuffer( const BitmapEx
& rBitmap
,
46 const OutputDevice
& rRefDevice
);
48 virtual ~BitmapBackBuffer();
50 virtual OutputDevice
& getOutDev() SAL_OVERRIDE
;
51 virtual const OutputDevice
& getOutDev() const SAL_OVERRIDE
;
53 /// Clear the underlying bitmap to white, all transparent
56 /** Exposing our internal bitmap. Only to be used from
61 BitmapEx
& getBitmapReference();
62 Size
getBitmapSizePixel() const;
65 void createVDev() const;
66 void updateVDev() const;
68 ::canvas::vcltools::VCLObject
<BitmapEx
> maBitmap
;
69 mutable VclPtr
<VirtualDevice
> mpVDev
; // created only on demand
71 const OutputDevice
& mrRefDevice
;
73 /** When true, the bitmap contains the last valid
74 content. When false, and mbVDevContentIsCurrent is true,
75 the VDev contains the last valid content (which must be
76 copied back to the bitmap, when getBitmapReference() is
77 called). When both are false, this object is just
80 mutable bool mbBitmapContentIsCurrent
;
82 /** When true, and mpVDev is non-NULL, the VDev contains the
83 last valid content. When false, and
84 mbBitmapContentIsCurrent is true, the bitmap contains the
85 last valid content. When both are false, this object is
88 mutable bool mbVDevContentIsCurrent
;
91 typedef ::boost::shared_ptr
< BitmapBackBuffer
> BitmapBackBufferSharedPtr
;
95 #endif // INCLUDED_CANVAS_SOURCE_VCL_BITMAPBACKBUFFER_HXX
97 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */