LibreOffice Module canvas (master) 1
dx_surfacebitmap.hxx
Go to the documentation of this file.
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#pragma once
21
24#include "dx_ibitmap.hxx"
25#include "dx_canvasfont.hxx"
26#include "dx_gdiplususer.hxx"
27#include "dx_rendermodule.hxx"
28
29namespace dxcanvas
30{
31 class DXSurfaceBitmap : public IBitmap
32 {
33 public:
34 DXSurfaceBitmap( const ::basegfx::B2ISize& rSize,
35 const std::shared_ptr<canvas::ISurfaceProxyManager>& rMgr,
36 const IDXRenderModuleSharedPtr& rRenderModule,
37 bool bWithAlpha );
38
39 bool resize(const ::basegfx::B2ISize& rSize);
40 void clear();
41
42 virtual GraphicsSharedPtr getGraphics() override;
43
44 virtual BitmapSharedPtr getBitmap() const override;
45 virtual ::basegfx::B2ISize getSize() const override;
46 virtual bool hasAlpha() const override;
47
48 sal::systools::COMReference<surface_type> getSurface() const { return mpSurface; }
49
50 bool draw( double fAlpha,
51 const ::basegfx::B2DPoint& rPos,
52 const ::basegfx::B2DHomMatrix& rTransform );
53
54 bool draw( const ::basegfx::B2IRange& rArea );
55
56 bool draw( double fAlpha,
57 const ::basegfx::B2DPoint& rPos,
58 const ::basegfx::B2DRange& rArea,
59 const ::basegfx::B2DHomMatrix& rTransform );
60
61 bool draw( double fAlpha,
62 const ::basegfx::B2DPoint& rPos,
63 const ::basegfx::B2DPolyPolygon& rClipPoly,
64 const ::basegfx::B2DHomMatrix& rTransform );
65
66 virtual css::uno::Sequence< sal_Int8 > getData(
67 css::rendering::IntegerBitmapLayout& bitmapLayout,
68 const css::geometry::IntegerRectangle2D& rect ) override;
69
70 virtual void setData(
71 const css::uno::Sequence< sal_Int8 >& data,
72 const css::rendering::IntegerBitmapLayout& bitmapLayout,
73 const css::geometry::IntegerRectangle2D& rect ) override;
74
75 virtual void setPixel(
76 const css::uno::Sequence< sal_Int8 >& color,
77 const css::rendering::IntegerBitmapLayout& bitmapLayout,
78 const css::geometry::IntegerPoint2D& pos ) override;
79
80 virtual css::uno::Sequence< sal_Int8 > getPixel(
81 css::rendering::IntegerBitmapLayout& bitmapLayout,
82 const css::geometry::IntegerPoint2D& pos ) override;
83
84 private:
85 void init();
86
87 // Refcounted global GDI+ state container
89
90 // size of this image in pixels [integral unit]
92
93 // pointer to the rendermodule, needed to create surfaces
94 // which are used as container for the actual pixel data.
95 // generally we could use any kind of storage, but GDI+
96 // is not willing to render antialiased fonts unless we
97 // use this special kind of container, don't ask me why...
99
100 // pointer to the surface manager, needed in case clients
101 // want to resize the bitmap.
102 std::shared_ptr<canvas::ISurfaceProxyManager> mpSurfaceManager;
103
104 // access point to the surface proxy which handles
105 // the hardware-dependent rendering stuff.
106 std::shared_ptr< canvas::ISurfaceProxy > mpSurfaceProxy;
107
108 // container for pixel data, we need to use a directx
109 // surface since GDI+ sucks...
110 sal::systools::COMReference<surface_type> mpSurface;
111
112 // since GDI+ does not work correctly in case we
113 // run on a 16bit display [don't ask me why] we need
114 // to occasionally render to a native GDI+ bitmap.
116 // Graphics for the mpGDIPlusBitmap
118
119 // internal implementation of the iColorBuffer interface
120 std::shared_ptr<canvas::IColorBuffer> mpColorBuffer;
121
122 // indicates whether the associated surface needs
123 // to refresh its contents or not. in other words,
124 // this flag is set iff both representations are
125 // out of sync.
126 mutable bool mbIsSurfaceDirty;
127
128 // true if the bitmap contains an alpha channel
130 };
131
132 typedef std::shared_ptr< DXSurfaceBitmap > DXSurfaceBitmapSharedPtr;
133}
134
135/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual bool hasAlpha() const override
virtual ::basegfx::B2ISize getSize() const override
std::shared_ptr< canvas::ISurfaceProxyManager > mpSurfaceManager
std::shared_ptr< canvas::ISurfaceProxy > mpSurfaceProxy
sal::systools::COMReference< surface_type > getSurface() const
IDXRenderModuleSharedPtr mpRenderModule
virtual void setPixel(const css::uno::Sequence< sal_Int8 > &color, const css::rendering::IntegerBitmapLayout &bitmapLayout, const css::geometry::IntegerPoint2D &pos) override
bool resize(const ::basegfx::B2ISize &rSize)
GDIPlusUserSharedPtr mpGdiPlusUser
sal::systools::COMReference< surface_type > mpSurface
bool draw(double fAlpha, const ::basegfx::B2DPoint &rPos, const ::basegfx::B2DHomMatrix &rTransform)
virtual css::uno::Sequence< sal_Int8 > getPixel(css::rendering::IntegerBitmapLayout &bitmapLayout, const css::geometry::IntegerPoint2D &pos) override
virtual GraphicsSharedPtr getGraphics() override
virtual void setData(const css::uno::Sequence< sal_Int8 > &data, const css::rendering::IntegerBitmapLayout &bitmapLayout, const css::geometry::IntegerRectangle2D &rect) override
virtual BitmapSharedPtr getBitmap() const override
DXSurfaceBitmap(const ::basegfx::B2ISize &rSize, const std::shared_ptr< canvas::ISurfaceProxyManager > &rMgr, const IDXRenderModuleSharedPtr &rRenderModule, bool bWithAlpha)
virtual css::uno::Sequence< sal_Int8 > getData(css::rendering::IntegerBitmapLayout &bitmapLayout, const css::geometry::IntegerRectangle2D &rect) override
std::shared_ptr< canvas::IColorBuffer > mpColorBuffer
std::shared_ptr< Gdiplus::Graphics > GraphicsSharedPtr
Definition: dx_winstuff.hxx:58
GDIPlusUser::GDIPlusUserSharedPtr GDIPlusUserSharedPtr
std::shared_ptr< DXSurfaceBitmap > DXSurfaceBitmapSharedPtr
std::shared_ptr< IDXRenderModule > IDXRenderModuleSharedPtr
std::shared_ptr< Gdiplus::Bitmap > BitmapSharedPtr
Definition: dx_winstuff.hxx:60
Interface for internal canvas bitmap objects.
Definition: dx_ibitmap.hxx:34