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