1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _DXCANVAS_DXSURFACEBITMAP_HXX 25 #define _DXCANVAS_DXSURFACEBITMAP_HXX 26 27 #include <canvas/rendering/isurfaceproxy.hxx> 28 #include <canvas/rendering/isurfaceproxymanager.hxx> 29 #include "dx_ibitmap.hxx" 30 #include "dx_canvasfont.hxx" //winstuff 31 #include "dx_gdiplususer.hxx" 32 #include "dx_rendermodule.hxx" 33 34 namespace dxcanvas 35 { 36 class DXSurfaceBitmap : public IBitmap 37 { 38 public: 39 DXSurfaceBitmap( const ::basegfx::B2IVector& rSize, 40 const canvas::ISurfaceProxyManagerSharedPtr& rMgr, 41 const IDXRenderModuleSharedPtr& rRenderModule, 42 bool bWithAlpha ); 43 44 bool resize( const ::basegfx::B2IVector& rSize ); 45 void clear(); 46 47 virtual GraphicsSharedPtr getGraphics(); 48 49 virtual BitmapSharedPtr getBitmap() const; 50 virtual ::basegfx::B2IVector getSize() const; 51 virtual bool hasAlpha() const; 52 getSurface() const53 COMReference<surface_type> getSurface() const { return mpSurface; } 54 55 bool draw( double fAlpha, 56 const ::basegfx::B2DPoint& rPos, 57 const ::basegfx::B2DHomMatrix& rTransform ); 58 59 bool draw( const ::basegfx::B2IRange& rArea ); 60 61 bool draw( double fAlpha, 62 const ::basegfx::B2DPoint& rPos, 63 const ::basegfx::B2DRange& rArea, 64 const ::basegfx::B2DHomMatrix& rTransform ); 65 66 bool draw( double fAlpha, 67 const ::basegfx::B2DPoint& rPos, 68 const ::basegfx::B2DPolyPolygon& rClipPoly, 69 const ::basegfx::B2DHomMatrix& rTransform ); 70 71 virtual ::com::sun::star::uno::Sequence< sal_Int8 > getData( 72 ::com::sun::star::rendering::IntegerBitmapLayout& bitmapLayout, 73 const ::com::sun::star::geometry::IntegerRectangle2D& rect ); 74 75 virtual void setData( 76 const ::com::sun::star::uno::Sequence< sal_Int8 >& data, 77 const ::com::sun::star::rendering::IntegerBitmapLayout& bitmapLayout, 78 const ::com::sun::star::geometry::IntegerRectangle2D& rect ); 79 80 virtual void setPixel( 81 const ::com::sun::star::uno::Sequence< sal_Int8 >& color, 82 const ::com::sun::star::rendering::IntegerBitmapLayout& bitmapLayout, 83 const ::com::sun::star::geometry::IntegerPoint2D& pos ); 84 85 virtual ::com::sun::star::uno::Sequence< sal_Int8 > getPixel( 86 ::com::sun::star::rendering::IntegerBitmapLayout& bitmapLayout, 87 const ::com::sun::star::geometry::IntegerPoint2D& pos ); 88 89 #ifdef DX_DEBUG_IMAGES 90 void imageDebugger(); 91 #endif 92 private: 93 void init(); 94 95 // Refcounted global GDI+ state container 96 GDIPlusUserSharedPtr mpGdiPlusUser; 97 98 // size of this image in pixels [integral unit] 99 ::basegfx::B2IVector maSize; 100 101 // pointer to the rendermodule, needed to create surfaces 102 // which are used as container for the actual pixel data. 103 // generally we could use any kind of storage, but GDI+ 104 // is not willing to render antialiased fonts unless we 105 // use this special kind of container, don't ask me why... 106 IDXRenderModuleSharedPtr mpRenderModule; 107 108 // pointer to the surface manager, needed in case clients 109 // want to resize the bitmap. 110 canvas::ISurfaceProxyManagerSharedPtr mpSurfaceManager; 111 112 // access point to the surface proxy which handles 113 // the hardware-dependent rendering stuff. 114 canvas::ISurfaceProxySharedPtr mpSurfaceProxy; 115 116 // container for pixel data, we need to use a directx 117 // surface since GDI+ sucks... 118 COMReference<surface_type> mpSurface; 119 120 // since GDI+ does not work correctly in case we 121 // run on a 16bit display [don't ask me why] we need 122 // to occasionally render to a native GDI+ bitmap. 123 BitmapSharedPtr mpGDIPlusBitmap; 124 // Graphics for the mpGDIPlusBitmap 125 GraphicsSharedPtr mpGraphics; 126 127 // internal implementation of the iColorBuffer interface 128 canvas::IColorBufferSharedPtr mpColorBuffer; 129 130 // indicates wether the associated surface needs 131 // to refresh its contents or not. in other words, 132 // this flag is set iff both representations are 133 // out of sync. 134 mutable bool mbIsSurfaceDirty; 135 136 // true if the bitmap contains an alpha channel 137 bool mbAlpha; 138 }; 139 140 typedef ::boost::shared_ptr< DXSurfaceBitmap > DXSurfaceBitmapSharedPtr; 141 } 142 143 #endif 144