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_BASEBMP_BITMAPDEVICE_HXX
21 : #define INCLUDED_BASEBMP_BITMAPDEVICE_HXX
22 :
23 : #include <sal/types.h>
24 : #include <basebmp/drawmodes.hxx>
25 : #include <basebmp/scanlineformats.hxx>
26 : #include <basebmp/basebmpdllapi.h>
27 :
28 : #include <boost/shared_ptr.hpp>
29 : #include <boost/shared_array.hpp>
30 : #include <boost/enable_shared_from_this.hpp>
31 : #include <boost/noncopyable.hpp>
32 : #include <memory>
33 : #include <vector>
34 :
35 : namespace basegfx
36 : {
37 : class B2IPoint;
38 : class B2DPoint;
39 : class B2IVector;
40 : class B2IBox;
41 : class B2DPolygon;
42 : class B2DPolyPolygon;
43 : }
44 :
45 : namespace basebmp
46 : {
47 :
48 : // Temporary. Use like the tools color object
49 : class Color;
50 : typedef boost::shared_ptr< class BitmapDevice > BitmapDeviceSharedPtr;
51 : typedef boost::shared_ptr< struct IBitmapDeviceDamageTracker > IBitmapDeviceDamageTrackerSharedPtr;
52 : typedef boost::shared_array< sal_uInt8 > RawMemorySharedArray;
53 : typedef boost::shared_ptr< const std::vector<Color> > PaletteMemorySharedVector;
54 :
55 : struct ImplBitmapDevice;
56 :
57 : /// Interface for getting damage tracking events
58 0 : struct IBitmapDeviceDamageTracker
59 : {
60 : /// gets called when said region is clobbered
61 : virtual void damaged(const basegfx::B2IBox& rDamageRect) const = 0;
62 :
63 : protected:
64 0 : ~IBitmapDeviceDamageTracker() {}
65 : };
66 :
67 : /** Definition of BitmapDevice interface
68 :
69 : Use the createBitmapDevice() function to create instances.
70 :
71 : Implementation note: the clip mask and bitmap parameter instances
72 : of BitmapDevice that are passed to individual BitmapDevice
73 : instances work best with 1 bit grey masks for the clip and a
74 : format matching that of the target BitmapDevice for the other
75 : parameters. The alpha mask passed to the drawMaskedColor() methods
76 : works best when given as an eight bit grey bitmap. Everything else
77 : is accepted, but potentially slow.
78 : */
79 : class BASEBMP_DLLPUBLIC BitmapDevice : public boost::enable_shared_from_this<BitmapDevice>,
80 : private boost::noncopyable
81 : {
82 : public:
83 : /** Query size of device in pixel columns (X) and rows (Y, "scanlines")
84 : */
85 : basegfx::B2IVector getSize() const;
86 :
87 : /** Query whether buffer starts with 0th scanline
88 :
89 : @return true, if the buffer memory starts with the 0th
90 : scanline, and false if it starts with the last one. The latter
91 : is e.g. the typical scan line ordering for the Windows BMP
92 : format.
93 : */
94 : bool isTopDown() const;
95 :
96 : /** Query the size of the whole frame buffer
97 :
98 : @ return the size of the whole frame buffer, the same as
99 : getSize() unless this is a "subset" device.
100 : */
101 : basegfx::B2IVector getBufferSize() const;
102 :
103 : /** Query type of scanline memory format
104 : */
105 : Format getScanlineFormat() const;
106 :
107 : /** Query byte offset to get from scanline n to scanline n+1
108 :
109 : @return the scanline stride in bytes.
110 : */
111 : sal_Int32 getScanlineStride() const;
112 :
113 : /** Get pointer to frame buffer
114 :
115 : @return a shared ptr to the bitmap buffer memory. As this is a
116 : shared ptr, you can freely store and use the pointer, even
117 : after this object has been deleted.
118 : */
119 : RawMemorySharedArray getBuffer() const;
120 :
121 : /// Query current damage tracking object (if any)
122 : IBitmapDeviceDamageTrackerSharedPtr getDamageTracker() const;
123 :
124 : /** Set new damage tracking object
125 :
126 : @param rDamage
127 : Object implementing the IBitmapDeviceDamageTracker interface -
128 : every time some area of the surface gets clobbered, that object
129 : gets notified.
130 : */
131 : void setDamageTracker( const IBitmapDeviceDamageTrackerSharedPtr& rDamage );
132 :
133 : /** Get pointer to palette
134 :
135 : The returned pointer is const on purpose, since the
136 : BitmapDevice might internally cache lookup information. Don't
137 : modify the returned data, unless you want to enter the realm
138 : of completely undefined behaviour.
139 :
140 : @return shared pointer to vector of Color entries.
141 : */
142 : PaletteMemorySharedVector getPalette() const;
143 :
144 : /// Check if this and the other BitmapDevice share a buffer
145 : bool isSharedBuffer( const BitmapDeviceSharedPtr& rOther ) const;
146 :
147 : /** Clear whole device with given color
148 :
149 : This method works like a fill with the given color value,
150 : resulting in a bitmap uniformly colored in fillColor.
151 : */
152 : void clear( Color fillColor );
153 :
154 : /** Set given pixel to specified color
155 :
156 : @param rPt
157 : Pixel to set
158 :
159 : @param pixelColor
160 : Color value to set the pixel to
161 :
162 : @param drawMode
163 : Draw mode to use when changing the pixel value
164 : */
165 : void setPixel( const basegfx::B2IPoint& rPt,
166 : Color pixelColor,
167 : DrawMode drawMode );
168 :
169 : /** Set given pixel to specified color
170 :
171 : @param rPt
172 : Pixel to set
173 :
174 : @param pixelColor
175 : Color value to set the pixel to
176 :
177 : @param drawMode
178 : Draw mode to use when changing the pixel value
179 :
180 : @param rClip
181 : Clip mask to use. If the clip mask is 1 at the given pixel
182 : position, no change will take place.
183 : */
184 : void setPixel( const basegfx::B2IPoint& rPt,
185 : Color pixelColor,
186 : DrawMode drawMode,
187 : const BitmapDeviceSharedPtr& rClip );
188 :
189 : /** Get color value at given pixel
190 : */
191 : Color getPixel( const basegfx::B2IPoint& rPt );
192 :
193 : /** Get underlying pixel data value at given position
194 :
195 : This method returns the raw pixel data. In the case of
196 : paletted bitmaps, this is the palette index, not the final
197 : color value.
198 : */
199 : sal_uInt32 getPixelData( const basegfx::B2IPoint& rPt );
200 :
201 : /** Draw a line
202 :
203 : @param rPt1
204 : Start point of the line
205 :
206 : @param rPt2
207 : End point of the line. If the analytical line from rP1 to rPt2
208 : (with the actual pixel positions assumed to be the center of
209 : the pixel) is exactly in the middle between two pixel, this
210 : method always selects the pixel closer to rPt1.
211 :
212 : @param lineColor
213 : Color value to draw the line with
214 :
215 : @param drawMode
216 : Draw mode to use when changing the pixel value
217 : */
218 : void drawLine( const basegfx::B2IPoint& rPt1,
219 : const basegfx::B2IPoint& rPt2,
220 : Color lineColor,
221 : DrawMode drawMode );
222 :
223 : /** Draw a line
224 :
225 : @param rPt1
226 : Start point of the line
227 :
228 : @param rPt2
229 : End point of the line. If the analytical line from rP1 to rPt2
230 : (with the actual pixel positions assumed to be the center of
231 : the pixel) is exactly in the middle between two pixel, this
232 : method always selects the pixel closer to rPt1.
233 :
234 : @param lineColor
235 : Color value to draw the line with
236 :
237 : @param drawMode
238 : Draw mode to use when changing the pixel value
239 :
240 : @param rClip
241 : Clip mask to use. Pixel where the corresponding clip mask
242 : pixel is 1 will not be modified.
243 : */
244 : void drawLine( const basegfx::B2IPoint& rPt1,
245 : const basegfx::B2IPoint& rPt2,
246 : Color lineColor,
247 : DrawMode drawMode,
248 : const BitmapDeviceSharedPtr& rClip );
249 :
250 : /** Draw a polygon
251 :
252 : @param rPoly
253 : Polygon to draw. Depending on the value returned by rPoly's
254 : isClosed() method, the resulting line polygon will be drawn
255 : closed or not.
256 :
257 : @param lineColor
258 : Color value to draw the polygon with
259 :
260 : @param drawMode
261 : Draw mode to use when changing pixel values
262 : */
263 : void drawPolygon( const basegfx::B2DPolygon& rPoly,
264 : Color lineColor,
265 : DrawMode drawMode );
266 :
267 : /** Draw a polygon
268 :
269 : @param rPoly
270 : Polygon to draw. Depending on the value returned by rPoly's
271 : isClosed() method, the resulting line polygon will be drawn
272 : closed or not.
273 :
274 : @param lineColor
275 : Color value to draw the polygon with
276 :
277 : @param drawMode
278 : Draw mode to use when changing pixel values
279 :
280 : @param rClip
281 : Clip mask to use. Pixel where the corresponding clip mask
282 : pixel is 1 will not be modified.
283 : */
284 : void drawPolygon( const basegfx::B2DPolygon& rPoly,
285 : Color lineColor,
286 : DrawMode drawMode,
287 : const BitmapDeviceSharedPtr& rClip );
288 :
289 : /** Fill a poly-polygon
290 :
291 : @param rPoly
292 : Poly-polygon to fill. Regardless of the value returned by
293 : rPoly's isClosed() method, the resulting filled poly-polygon
294 : is always considered closed. As usual, when filling a shape,
295 : the rightmost and bottommost pixel are not filled, compared to
296 : the drawPolygon() method. For example, the rectangle
297 : (0,0),(1,1) will have four pixel set, when drawn via
298 : drawPolygon(), and only one pixel, when filled via
299 : fillPolyPolygon().
300 :
301 : @param fillColor
302 : Color value to fill the poly-polygon with
303 :
304 : @param drawMode
305 : Draw mode to use when changing pixel values
306 : */
307 : void fillPolyPolygon( const basegfx::B2DPolyPolygon& rPoly,
308 : Color fillColor,
309 : DrawMode drawMode );
310 :
311 : /** Fill a poly-polygon
312 :
313 : @param rPoly
314 : Poly-polygon to fill. Regardless of the value returned by
315 : rPoly's isClosed() method, the resulting filled poly-polygon
316 : is always considered closed. As usual, when filling a shape,
317 : the rightmost and bottommost pixel are not filled, compared to
318 : the drawPolygon() method. For example, the rectangle
319 : (0,0),(1,1) will have four pixel set, when drawn via
320 : drawPolygon(), and only one pixel, when filled via
321 : fillPolyPolygon().
322 :
323 : @param fillColor
324 : Color value to fill the poly-polygon with
325 :
326 : @param drawMode
327 : Draw mode to use when changing pixel values
328 :
329 : @param rClip
330 : Clip mask to use. Pixel where the corresponding clip mask
331 : pixel is 1 will not be modified.
332 : */
333 : void fillPolyPolygon( const basegfx::B2DPolyPolygon& rPoly,
334 : Color fillColor,
335 : DrawMode drawMode,
336 : const BitmapDeviceSharedPtr& rClip );
337 :
338 : /** Draw another bitmap into this device
339 :
340 : @param rSrcBitmap
341 : Bitmap to render into this one. It is permitted that source
342 : and destination bitmap are the same.
343 :
344 : @param rSrcRect
345 : Rectangle within the source bitmap to take the pixel from.
346 :
347 : @param rDstRect
348 : Rectangle in the destination bitmap to put the pixel
349 : into. Source and destination rectangle are permitted to have
350 : differing sizes; this method will scale the source pixel
351 : accordingly. Please note that both source and destination
352 : rectangle are interpreted excluding the rightmost pixel column
353 : and the bottommost pixel row, this is much like polygon
354 : filling. As a result, filling a given rectangle with
355 : fillPolyPolygon(), and using the same rectangle as the
356 : destination rectangle of this method, will affect exactly the
357 : same set of pixel.
358 :
359 : @param drawMode
360 : Draw mode to use when changing pixel values
361 : */
362 : void drawBitmap( const BitmapDeviceSharedPtr& rSrcBitmap,
363 : const basegfx::B2IBox& rSrcRect,
364 : const basegfx::B2IBox& rDstRect,
365 : DrawMode drawMode );
366 :
367 : /** Draw another bitmap into this device
368 :
369 : @param rSrcBitmap
370 : Bitmap to render into this one. It is permitted that source
371 : and destination bitmap are the same.
372 :
373 : @param rSrcRect
374 : Rectangle within the source bitmap to take the pixel from.
375 :
376 : @param rDstRect
377 : Rectangle in the destination bitmap to put the pixel
378 : into. Source and destination rectangle are permitted to have
379 : differing sizes; this method will scale the source pixel
380 : accordingly. Please note that both source and destination
381 : rectangle are interpreted excluding the rightmost pixel column
382 : and the bottommost pixel row, this is much like polygon
383 : filling. As a result, filling a given rectangle with
384 : fillPolyPolygon(), and using the same rectangle as the
385 : destination rectangle of this method, will affect exactly the
386 : same set of pixel.
387 :
388 : @param drawMode
389 : Draw mode to use when changing pixel values
390 :
391 : @param rClip
392 : Clip mask to use. Pixel where the corresponding clip mask
393 : pixel is 1 will not be modified.
394 : */
395 : void drawBitmap( const BitmapDeviceSharedPtr& rSrcBitmap,
396 : const basegfx::B2IBox& rSrcRect,
397 : const basegfx::B2IBox& rDstRect,
398 : DrawMode drawMode,
399 : const BitmapDeviceSharedPtr& rClip );
400 :
401 : /** Draw a color with an alpha-modulation bitmap into this device
402 :
403 : This method takes a fixed color value, and an alpha mask. For
404 : each pixel in the alpha mask, the given color value is blended
405 : with the corresponding alpha value against the content of this
406 : object.
407 :
408 : @param aSrcColor
409 : Color value to use for blending
410 :
411 : @param rAlphaMask
412 : Alpha mask to use for blending. It is permitted that alpha
413 : mask and this bitmap are the same object.
414 :
415 : @param rSrcRect
416 : Rectangle within the alpha mask to take the pixel from.
417 : Please note that the destination rectangle is interpreted
418 : excluding the rightmost pixel column and the bottommost pixel
419 : row, this is much like polygon filling. As a result, filling a
420 : given rectangle with fillPolyPolygon(), and using the same
421 : rectangle as the source rectangle of this method, will affect
422 : exactly the same set of pixel.
423 :
424 : @param rDstPoint
425 : Destination point, where to start placing the pixel from the
426 : source rectangle
427 : */
428 : void drawMaskedColor( Color aSrcColor,
429 : const BitmapDeviceSharedPtr& rAlphaMask,
430 : const basegfx::B2IBox& rSrcRect,
431 : const basegfx::B2IPoint& rDstPoint );
432 :
433 : /** Draw a color with an alpha-modulation bitmap into this device
434 :
435 : This method takes a fixed color value, and an alpha mask. For
436 : each pixel in the alpha mask, the given color value is blended
437 : with the corresponding alpha value against the content of this
438 : object.
439 :
440 : @param aSrcColor
441 : Color value to use for blending
442 :
443 : @param rAlphaMask
444 : Alpha mask to use for blending. It is permitted that alpha
445 : mask and this bitmap are the same object.
446 :
447 : @param rSrcRect
448 : Rectangle within the alpha mask to take the pixel from.
449 : Please note that the destination rectangle is interpreted
450 : excluding the rightmost pixel column and the bottommost pixel
451 : row, this is much like polygon filling. As a result, filling a
452 : given rectangle with fillPolyPolygon(), and using the same
453 : rectangle as the source rectangle of this method, will affect
454 : exactly the same set of pixel.
455 :
456 : @param rDstPoint
457 : Destination point, where to start placing the pixel from the
458 : source rectangle
459 :
460 : @param rClip
461 : Clip mask to use. Pixel where the corresponding clip mask
462 : pixel is 1 will not be modified.
463 : */
464 : void drawMaskedColor( Color aSrcColor,
465 : const BitmapDeviceSharedPtr& rAlphaMask,
466 : const basegfx::B2IBox& rSrcRect,
467 : const basegfx::B2IPoint& rDstPoint,
468 : const BitmapDeviceSharedPtr& rClip );
469 :
470 : /** Draw another bitmap through a mask into this device
471 :
472 : This method renders a source bitmap into this device, much
473 : like the drawBitmap() method. The only difference is the
474 : additional mask parameter, which operates much like an
475 : additional clip mask: pixel with value zero in this mask
476 : result in destination pixel not being modified.
477 :
478 : @param rSrcBitmap
479 : Bitmap to render into this one. It is permitted that source
480 : and destination bitmap are the same.
481 :
482 : @param rMask
483 : Bitmap to use as a mask. Pixel with value != zero in this mask
484 : will result in destination pixel not being affected by the
485 : blit operation.
486 :
487 : @param rSrcRect
488 : Rectangle within the source bitmap to take the pixel from.
489 :
490 : @param rDstRect
491 : Rectangle in the destination bitmap to put the pixel
492 : into. Source and destination rectangle are permitted to have
493 : differing sizes; this method will scale the source pixel
494 : accordingly. Please note that both source and destination
495 : rectangle are interpreted excluding the rightmost pixel column
496 : and the bottommost pixel row, this is much like polygon
497 : filling. As a result, filling a given rectangle with
498 : fillPolyPolygon(), and using the same rectangle as the
499 : destination rectangle of this method, will affect exactly the
500 : same set of pixel.
501 :
502 : @param drawMode
503 : Draw mode to use when changing pixel values
504 : */
505 : void drawMaskedBitmap( const BitmapDeviceSharedPtr& rSrcBitmap,
506 : const BitmapDeviceSharedPtr& rMask,
507 : const basegfx::B2IBox& rSrcRect,
508 : const basegfx::B2IBox& rDstRect,
509 : DrawMode drawMode );
510 :
511 : /** Draw another bitmap through a mask into this device
512 :
513 : This method renders a source bitmap into this device, much
514 : like the drawBitmap() method. The only difference is the
515 : additional mask parameter, which operates much like an
516 : additional clip mask: pixel with value != zero in this mask
517 : result in destination pixel not being modified.
518 :
519 : @param rSrcBitmap
520 : Bitmap to render into this one. It is permitted that source
521 : and destination bitmap are the same.
522 :
523 : @param rMask
524 : Bitmap to use as a mask. Pixel with value != zero in this mask
525 : will result in destination pixel not being affected by the
526 : blit operation.
527 :
528 : @param rSrcRect
529 : Rectangle within the source bitmap to take the pixel from.
530 :
531 : @param rDstRect
532 : Rectangle in the destination bitmap to put the pixel
533 : into. Source and destination rectangle are permitted to have
534 : differing sizes; this method will scale the source pixel
535 : accordingly. Please note that both source and destination
536 : rectangle are interpreted excluding the rightmost pixel column
537 : and the bottommost pixel row, this is much like polygon
538 : filling. As a result, filling a given rectangle with
539 : fillPolyPolygon(), and using the same rectangle as the
540 : destination rectangle of this method, will affect exactly the
541 : same set of pixel.
542 :
543 : @param drawMode
544 : Draw mode to use when changing pixel values
545 :
546 : @param rClip
547 : Clip mask to use. Pixel where the corresponding clip mask
548 : pixel is 1 will not be modified.
549 : */
550 : void drawMaskedBitmap( const BitmapDeviceSharedPtr& rSrcBitmap,
551 : const BitmapDeviceSharedPtr& rMask,
552 : const basegfx::B2IBox& rSrcRect,
553 : const basegfx::B2IBox& rDstRect,
554 : DrawMode drawMode,
555 : const BitmapDeviceSharedPtr& rClip );
556 :
557 : protected:
558 : BASEBMP_DLLPRIVATE BitmapDevice( const basegfx::B2IBox& rBounds,
559 : const basegfx::B2IVector& rBufferSize,
560 : Format nScanlineFormat,
561 : sal_Int32 nScanlineStride,
562 : sal_uInt8* pFirstScanline,
563 : const RawMemorySharedArray& rMem,
564 : const PaletteMemorySharedVector& rPalette );
565 : BASEBMP_DLLPRIVATE virtual ~BitmapDevice();
566 :
567 : private:
568 : BASEBMP_DLLPRIVATE virtual bool isCompatibleBitmap( const BitmapDeviceSharedPtr& bmp ) const = 0;
569 : BASEBMP_DLLPRIVATE virtual bool isCompatibleClipMask( const BitmapDeviceSharedPtr& bmp ) const = 0;
570 : BASEBMP_DLLPRIVATE virtual bool isCompatibleAlphaMask( const BitmapDeviceSharedPtr& bmp ) const = 0;
571 :
572 : BASEBMP_DLLPRIVATE virtual void clear_i( Color fillColor,
573 : const basegfx::B2IBox& rBounds ) = 0;
574 :
575 : BASEBMP_DLLPRIVATE virtual void setPixel_i( const basegfx::B2IPoint& rPt,
576 : Color lineColor,
577 : DrawMode drawMode ) = 0;
578 : BASEBMP_DLLPRIVATE virtual void setPixel_i( const basegfx::B2IPoint& rPt,
579 : Color lineColor,
580 : DrawMode drawMode,
581 : const BitmapDeviceSharedPtr& rClip ) = 0;
582 :
583 : BASEBMP_DLLPRIVATE virtual Color getPixel_i( const basegfx::B2IPoint& rPt ) = 0;
584 :
585 : BASEBMP_DLLPRIVATE virtual sal_uInt32 getPixelData_i( const basegfx::B2IPoint& rPt ) = 0;
586 :
587 : BASEBMP_DLLPRIVATE virtual void drawLine_i( const basegfx::B2IPoint& rPt1,
588 : const basegfx::B2IPoint& rPt2,
589 : const basegfx::B2IBox& rBounds,
590 : Color lineColor,
591 : DrawMode drawMode ) = 0;
592 : BASEBMP_DLLPRIVATE virtual void drawLine_i( const basegfx::B2IPoint& rPt1,
593 : const basegfx::B2IPoint& rPt2,
594 : const basegfx::B2IBox& rBounds,
595 : Color lineColor,
596 : DrawMode drawMode,
597 : const BitmapDeviceSharedPtr& rClip ) = 0;
598 :
599 : BASEBMP_DLLPRIVATE virtual void drawPolygon_i( const basegfx::B2DPolygon& rPoly,
600 : const basegfx::B2IBox& rBounds,
601 : Color lineColor,
602 : DrawMode drawMode ) = 0;
603 : BASEBMP_DLLPRIVATE virtual void drawPolygon_i( const basegfx::B2DPolygon& rPoly,
604 : const basegfx::B2IBox& rBounds,
605 : Color lineColor,
606 : DrawMode drawMode,
607 : const BitmapDeviceSharedPtr& rClip ) = 0;
608 :
609 : BASEBMP_DLLPRIVATE virtual void fillPolyPolygon_i( const basegfx::B2DPolyPolygon& rPoly,
610 : Color fillColor,
611 : DrawMode drawMode,
612 : const basegfx::B2IBox& rBounds ) = 0;
613 : BASEBMP_DLLPRIVATE virtual void fillPolyPolygon_i( const basegfx::B2DPolyPolygon& rPoly,
614 : Color fillColor,
615 : DrawMode drawMode,
616 : const basegfx::B2IBox& rBounds,
617 : const BitmapDeviceSharedPtr& rClip ) = 0;
618 :
619 : // must work with *this == rSrcBitmap!
620 : BASEBMP_DLLPRIVATE virtual void drawBitmap_i( const BitmapDeviceSharedPtr& rSrcBitmap,
621 : const basegfx::B2IBox& rSrcRect,
622 : const basegfx::B2IBox& rDstRect,
623 : DrawMode drawMode ) = 0;
624 : BASEBMP_DLLPRIVATE virtual void drawBitmap_i( const BitmapDeviceSharedPtr& rSrcBitmap,
625 : const basegfx::B2IBox& rSrcRect,
626 : const basegfx::B2IBox& rDstRect,
627 : DrawMode drawMode,
628 : const BitmapDeviceSharedPtr& rClip ) = 0;
629 :
630 : // must work with *this == rSrcBitmap!
631 : BASEBMP_DLLPRIVATE virtual void drawMaskedColor_i( Color rSrcColor,
632 : const BitmapDeviceSharedPtr& rAlphaMask,
633 : const basegfx::B2IBox& rSrcRect,
634 : const basegfx::B2IPoint& rDstPoint ) = 0;
635 : BASEBMP_DLLPRIVATE virtual void drawMaskedColor_i( Color rSrcColor,
636 : const BitmapDeviceSharedPtr& rAlphaMask,
637 : const basegfx::B2IBox& rSrcRect,
638 : const basegfx::B2IPoint& rDstPoint,
639 : const BitmapDeviceSharedPtr& rClip ) = 0;
640 :
641 : // must work with *this == rSrcBitmap!
642 : BASEBMP_DLLPRIVATE virtual void drawMaskedBitmap_i( const BitmapDeviceSharedPtr& rSrcBitmap,
643 : const BitmapDeviceSharedPtr& rMask,
644 : const basegfx::B2IBox& rSrcRect,
645 : const basegfx::B2IBox& rDstRect,
646 : DrawMode drawMode ) = 0;
647 : BASEBMP_DLLPRIVATE virtual void drawMaskedBitmap_i( const BitmapDeviceSharedPtr& rSrcBitmap,
648 : const BitmapDeviceSharedPtr& rMask,
649 : const basegfx::B2IBox& rSrcRect,
650 : const basegfx::B2IBox& rDstRect,
651 : DrawMode drawMode,
652 : const BitmapDeviceSharedPtr& rClip ) = 0;
653 :
654 : BASEBMP_DLLPRIVATE virtual IBitmapDeviceDamageTrackerSharedPtr getDamageTracker_i() const = 0;
655 : BASEBMP_DLLPRIVATE virtual void setDamageTracker_i( const IBitmapDeviceDamageTrackerSharedPtr& rDamage ) = 0;
656 :
657 : BitmapDeviceSharedPtr getGenericRenderer() const;
658 :
659 : std::unique_ptr< ImplBitmapDevice > mpImpl;
660 : };
661 :
662 : /** Function to calculate a suitable BitmapDevice Scanline Stride for a given scanline format and width
663 : * you can provide this value or any larger value.
664 : */
665 : sal_Int32 BASEBMP_DLLPUBLIC getBitmapDeviceStrideForWidth(Format nScanlineFormat, sal_Int32 nWidth);
666 :
667 : /** Function to create a BitmapDevice for given scanline format
668 : */
669 : BitmapDeviceSharedPtr BASEBMP_DLLPUBLIC createBitmapDevice( const basegfx::B2IVector& rSize,
670 : bool bTopDown,
671 : Format nScanlineFormat,
672 : sal_Int32 nScanlineStride );
673 :
674 : /** Function to create a BitmapDevice for given scanline format
675 : with the given palette
676 :
677 : Note: the provided palette must have sufficient size, to satisfy
678 : lookups for the whole range of pixel values from the specified
679 : format.
680 : */
681 : BitmapDeviceSharedPtr BASEBMP_DLLPUBLIC createBitmapDevice( const basegfx::B2IVector& rSize,
682 : bool bTopDown,
683 : Format nScanlineFormat,
684 : sal_Int32 nScanlineStride,
685 : const PaletteMemorySharedVector& rPalette );
686 :
687 : /** Function to create a BitmapDevice for given scanline format
688 : from the given piece of raw memory and palette
689 :
690 : Note: the provided memory must have sufficient size, to store the
691 : image of the specified area and format.
692 : */
693 : BitmapDeviceSharedPtr BASEBMP_DLLPUBLIC createBitmapDevice( const basegfx::B2IVector& rSize,
694 : bool bTopDown,
695 : Format nScanlineFormat,
696 : sal_Int32 nScanlineStride,
697 : const RawMemorySharedArray& rMem,
698 : const PaletteMemorySharedVector& rPalette );
699 :
700 :
701 : /** Function to create a 1 bit grey clipping mask initialized to white.
702 : */
703 : BitmapDeviceSharedPtr BASEBMP_DLLPUBLIC createClipDevice( const basegfx::B2IVector& rSize );
704 :
705 : /** Function to retrieve a subsetted BitmapDevice to the same
706 : memory.
707 :
708 : Note that there is no coordinate system translation or offsetting
709 : involved.
710 :
711 : This method creates a second bitmap device instance, which renders
712 : to the same memory as the original, with the same pixel coordinate
713 : pairs referring to the same pixels in the memory buffer, but with
714 : rendering clipped to a rectangular area. Useful to implement
715 : rectangular clips (usually faster than setting up a 1bpp clip
716 : mask).
717 :
718 : */
719 : BitmapDeviceSharedPtr BASEBMP_DLLPUBLIC subsetBitmapDevice( const BitmapDeviceSharedPtr& rProto,
720 : const basegfx::B2IBox& rSubset );
721 :
722 : /** Function to clone a BitmapDevice from a given prototype.
723 :
724 : All attributes (like scanline format and top-down state) are
725 : copied, only the size can be varied. Note that the prototype's
726 : bitmap content is <em>not</em> copied, only a palette (if any).
727 : */
728 : BitmapDeviceSharedPtr BASEBMP_DLLPUBLIC cloneBitmapDevice( const basegfx::B2IVector& rSize,
729 : const BitmapDeviceSharedPtr& rProto );
730 :
731 : }
732 :
733 : #endif /* INCLUDED_BASEBMP_BITMAPDEVICE_HXX */
734 :
735 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|