Simplify a bit
[LibreOffice.git] / canvas / source / directx / dx_surfacebitmap.hxx
blobf39ebb5b97273a905484f11c545067a0b0096538
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #pragma once
22 #include <rendering/isurfaceproxy.hxx>
23 #include <rendering/isurfaceproxymanager.hxx>
24 #include "dx_ibitmap.hxx"
25 #include "dx_canvasfont.hxx"
26 #include "dx_gdiplususer.hxx"
27 #include "dx_rendermodule.hxx"
29 namespace dxcanvas
31 class DXSurfaceBitmap : public IBitmap
33 public:
34 DXSurfaceBitmap( const ::basegfx::B2ISize& rSize,
35 const std::shared_ptr<canvas::ISurfaceProxyManager>& rMgr,
36 const IDXRenderModuleSharedPtr& rRenderModule,
37 bool bWithAlpha );
39 bool resize(const ::basegfx::B2ISize& rSize);
40 void clear();
42 virtual GraphicsSharedPtr getGraphics() override;
44 virtual BitmapSharedPtr getBitmap() const override;
45 virtual ::basegfx::B2ISize getSize() const override;
46 virtual bool hasAlpha() const override;
48 sal::systools::COMReference<surface_type> getSurface() const { return mpSurface; }
50 bool draw( double fAlpha,
51 const ::basegfx::B2DPoint& rPos,
52 const ::basegfx::B2DHomMatrix& rTransform );
54 bool draw( const ::basegfx::B2IRange& rArea );
56 bool draw( double fAlpha,
57 const ::basegfx::B2DPoint& rPos,
58 const ::basegfx::B2DRange& rArea,
59 const ::basegfx::B2DHomMatrix& rTransform );
61 bool draw( double fAlpha,
62 const ::basegfx::B2DPoint& rPos,
63 const ::basegfx::B2DPolyPolygon& rClipPoly,
64 const ::basegfx::B2DHomMatrix& rTransform );
66 virtual css::uno::Sequence< sal_Int8 > getData(
67 css::rendering::IntegerBitmapLayout& bitmapLayout,
68 const css::geometry::IntegerRectangle2D& rect ) override;
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;
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;
80 virtual css::uno::Sequence< sal_Int8 > getPixel(
81 css::rendering::IntegerBitmapLayout& bitmapLayout,
82 const css::geometry::IntegerPoint2D& pos ) override;
84 private:
85 void init();
87 // Refcounted global GDI+ state container
88 GDIPlusUserSharedPtr mpGdiPlusUser;
90 // size of this image in pixels [integral unit]
91 ::basegfx::B2ISize maSize;
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...
98 IDXRenderModuleSharedPtr mpRenderModule;
100 // pointer to the surface manager, needed in case clients
101 // want to resize the bitmap.
102 std::shared_ptr<canvas::ISurfaceProxyManager> mpSurfaceManager;
104 // access point to the surface proxy which handles
105 // the hardware-dependent rendering stuff.
106 std::shared_ptr< canvas::ISurfaceProxy > mpSurfaceProxy;
108 // container for pixel data, we need to use a directx
109 // surface since GDI+ sucks...
110 sal::systools::COMReference<surface_type> mpSurface;
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.
115 BitmapSharedPtr mpGDIPlusBitmap;
116 // Graphics for the mpGDIPlusBitmap
117 GraphicsSharedPtr mpGraphics;
119 // internal implementation of the iColorBuffer interface
120 std::shared_ptr<canvas::IColorBuffer> mpColorBuffer;
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;
128 // true if the bitmap contains an alpha channel
129 bool mbAlpha;
132 typedef std::shared_ptr< DXSurfaceBitmap > DXSurfaceBitmapSharedPtr;
135 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */