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