Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef INCLUDED_CANVAS_SOURCE_VCL_CANVASBITMAPHELPER_HXX
21 : #define INCLUDED_CANVAS_SOURCE_VCL_CANVASBITMAPHELPER_HXX
22 :
23 : #include <canvashelper.hxx>
24 : #include <canvas/vclwrapper.hxx>
25 :
26 : #include <vcl/bitmapex.hxx>
27 :
28 : #include "bitmapbackbuffer.hxx"
29 : #include "spritecanvas.hxx"
30 :
31 :
32 : namespace vclcanvas
33 : {
34 : /** Helper class for basic canvasbitmap functionality. Extends
35 : CanvasHelper with some CanvasBitmap specialities, such as alpha
36 : support.
37 :
38 : Note that a plain CanvasHelper, although it does support the
39 : XBitmap interface, has no provision for alpha channel on VCL
40 : (at least no efficient one. If the alpha VDev one day gets
41 : part of SAL, we might change that).
42 : */
43 0 : class CanvasBitmapHelper : public CanvasHelper
44 : {
45 : public:
46 : CanvasBitmapHelper();
47 :
48 : /** Set a new bitmap on this helper.
49 :
50 : This method late-initializes the bitmap canvas helper,
51 : providing it with the necessary device and output
52 : objects. The internally stored bitmap representation is
53 : updated from the given bitmap, including any size
54 : changes. Note that the CanvasHelper does <em>not</em> take
55 : ownership of the SpriteCanvas object, nor does it perform
56 : any reference counting. Thus, to prevent reference counted
57 : objects from deletion, the user of this class is
58 : responsible for holding ref-counted references to those
59 : objects!
60 :
61 : @param rBitmap
62 : Content of this bitmap is used as our new content (our
63 : internal size is adapted to the size of the bitmap given)
64 :
65 : @param rDevice
66 : Reference device for this canvas bitmap
67 :
68 : @param rOutDevProvider
69 : Reference output device. Used to create matching bitmap.
70 : */
71 : void init( const BitmapEx& rBitmap,
72 : ::com::sun::star::rendering::XGraphicDevice& rDevice,
73 : const OutDevProviderSharedPtr& rOutDevProvider );
74 :
75 :
76 : // Overridden CanvasHelper functionality
77 : // =====================================
78 :
79 : void disposing();
80 :
81 : void clear();
82 :
83 : ::com::sun::star::geometry::IntegerSize2D getSize();
84 :
85 : ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmapCanvas > queryBitmapCanvas();
86 :
87 : ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmap >
88 : getScaledBitmap( const ::com::sun::star::geometry::RealSize2D& newSize,
89 : bool beFast );
90 :
91 : ::com::sun::star::uno::Sequence< sal_Int8 >
92 : getData( ::com::sun::star::rendering::IntegerBitmapLayout& bitmapLayout,
93 : const ::com::sun::star::geometry::IntegerRectangle2D& rect );
94 :
95 : void setData( const ::com::sun::star::uno::Sequence< sal_Int8 >& data,
96 : const ::com::sun::star::rendering::IntegerBitmapLayout& bitmapLayout,
97 : const ::com::sun::star::geometry::IntegerRectangle2D& rect );
98 :
99 : void setPixel( const ::com::sun::star::uno::Sequence< sal_Int8 >& color,
100 : const ::com::sun::star::rendering::IntegerBitmapLayout& bitmapLayout,
101 : const ::com::sun::star::geometry::IntegerPoint2D& pos );
102 :
103 : ::com::sun::star::uno::Sequence< sal_Int8 >
104 : getPixel( ::com::sun::star::rendering::IntegerBitmapLayout& bitmapLayout,
105 : const ::com::sun::star::geometry::IntegerPoint2D& pos );
106 :
107 : ::com::sun::star::rendering::IntegerBitmapLayout getMemoryLayout();
108 :
109 : /// @internal
110 : BitmapEx getBitmap() const;
111 :
112 : private:
113 :
114 : void setBitmap( const BitmapEx& rBitmap );
115 :
116 : BitmapBackBufferSharedPtr mpBackBuffer;
117 : OutDevProviderSharedPtr mpOutDevReference;
118 : };
119 : }
120 :
121 : #endif // INCLUDED_CANVAS_SOURCE_VCL_CANVASBITMAPHELPER_HXX
122 :
123 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|