merge the formfield patch from ooo-build
[ooovba.git] / canvas / source / vcl / bitmapbackbuffer.hxx
bloba0f93b99ad8dd0c8cb274e3d4770bc834b5a3c82
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: bitmapbackbuffer.hxx,v $
10 * $Revision: 1.7 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _VCLCANVAS_BITMAPBACKBUFFER_HXX_
32 #define _VCLCANVAS_BITMAPBACKBUFFER_HXX_
34 #include <vcl/virdev.hxx>
35 #include <vcl/bitmapex.hxx>
37 #include <canvas/vclwrapper.hxx>
38 #include "outdevprovider.hxx"
40 #include <boost/shared_ptr.hpp>
43 namespace vclcanvas
45 /** Backbuffer implementation for canvas bitmap.
47 This class abstracts away the renderable bitmap for the bitmap
48 canvas. The actual VirtualDevice is only created when
49 necessary, which makes read-only bitmaps a lot smaller.
51 class BitmapBackBuffer : public OutDevProvider
53 public:
54 /** Create a backbuffer for given reference device
56 BitmapBackBuffer( const BitmapEx& rBitmap,
57 const OutputDevice& rRefDevice );
59 ~BitmapBackBuffer();
61 virtual OutputDevice& getOutDev();
62 virtual const OutputDevice& getOutDev() const;
64 /// Clear the underlying bitmap to white, all transparent
65 void clear();
67 /** Exposing our internal bitmap. Only to be used from
68 CanvasBitmapHelper
70 @internal
72 BitmapEx& getBitmapReference();
73 Size getBitmapSizePixel() const;
75 private:
76 void createVDev() const;
77 void updateVDev() const;
79 ::canvas::vcltools::VCLObject<BitmapEx> maBitmap;
80 mutable VirtualDevice* mpVDev; // created only on demand
82 const OutputDevice& mrRefDevice;
84 /** When true, the bitmap contains the last valid
85 content. When false, and mbVDevContentIsCurrent is true,
86 the VDev contains the last valid content (which must be
87 copied back to the bitmap, when getBitmapReference() is
88 called). When both are false, this object is just
89 initialized.
91 mutable bool mbBitmapContentIsCurrent;
93 /** When true, and mpVDev is non-NULL, the VDev contains the
94 last valid content. When false, and
95 mbBitmapContentIsCurrent is true, the bitmap contains the
96 last valid content. When both are false, this object is
97 just initialized.
99 mutable bool mbVDevContentIsCurrent;
102 typedef ::boost::shared_ptr< BitmapBackBuffer > BitmapBackBufferSharedPtr;
106 #endif /* #ifndef _VCLCANVAS_BITMAPBACKBUFFER_HXX_ */