1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir #ifndef INCLUDED_CANVAS_SURFACE_HXX 29*cdf0e10cSrcweir #define INCLUDED_CANVAS_SURFACE_HXX 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <basegfx/point/b2ipoint.hxx> 32*cdf0e10cSrcweir #include <basegfx/point/b2dpoint.hxx> 33*cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygon.hxx> 34*cdf0e10cSrcweir #include <basegfx/range/b2drectangle.hxx> 35*cdf0e10cSrcweir #include <basegfx/vector/b2isize.hxx> 36*cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrix.hxx> 37*cdf0e10cSrcweir #include <canvas/rendering/irendermodule.hxx> 38*cdf0e10cSrcweir #include <canvas/rendering/icolorbuffer.hxx> 39*cdf0e10cSrcweir #include <canvas/rendering/isurface.hxx> 40*cdf0e10cSrcweir 41*cdf0e10cSrcweir #include "surfacerect.hxx" 42*cdf0e10cSrcweir #include "pagemanager.hxx" 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir namespace canvas 45*cdf0e10cSrcweir { 46*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////// 47*cdf0e10cSrcweir // Surface 48*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////// 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir /** surfaces denote occupied areas withing pages. 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir pages encapsulate the hardware buffers that 53*cdf0e10cSrcweir contain image data which can be used for texturing. 54*cdf0e10cSrcweir surfaces are areas within those pages. 55*cdf0e10cSrcweir */ 56*cdf0e10cSrcweir class Surface 57*cdf0e10cSrcweir { 58*cdf0e10cSrcweir public: 59*cdf0e10cSrcweir 60*cdf0e10cSrcweir Surface( const PageManagerSharedPtr& rPageManager, 61*cdf0e10cSrcweir const IColorBufferSharedPtr& rColorBuffer, 62*cdf0e10cSrcweir const ::basegfx::B2IPoint& rPos, 63*cdf0e10cSrcweir const ::basegfx::B2ISize& rSize ); 64*cdf0e10cSrcweir ~Surface(); 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir void setColorBufferDirty(); 67*cdf0e10cSrcweir 68*cdf0e10cSrcweir /** Render the surface content to screen. 69*cdf0e10cSrcweir 70*cdf0e10cSrcweir @param fAlpha 71*cdf0e10cSrcweir Overall alpha for content 72*cdf0e10cSrcweir 73*cdf0e10cSrcweir @param rPos 74*cdf0e10cSrcweir Output position 75*cdf0e10cSrcweir 76*cdf0e10cSrcweir @param rTransform 77*cdf0e10cSrcweir Output transformation (does not affect output position) 78*cdf0e10cSrcweir */ 79*cdf0e10cSrcweir bool draw( double fAlpha, 80*cdf0e10cSrcweir const ::basegfx::B2DPoint& rPos, 81*cdf0e10cSrcweir const ::basegfx::B2DHomMatrix& rTransform ); 82*cdf0e10cSrcweir 83*cdf0e10cSrcweir /** Render the surface content to screen. 84*cdf0e10cSrcweir 85*cdf0e10cSrcweir @param fAlpha 86*cdf0e10cSrcweir Overall alpha for content 87*cdf0e10cSrcweir 88*cdf0e10cSrcweir @param rPos 89*cdf0e10cSrcweir Output position 90*cdf0e10cSrcweir 91*cdf0e10cSrcweir @param rArea 92*cdf0e10cSrcweir Subset of the surface to render. Coordinate system are 93*cdf0e10cSrcweir surface area pixel, given area will be clipped to the 94*cdf0e10cSrcweir surface bounds. 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir @param rTransform 97*cdf0e10cSrcweir Output transformation (does not affect output position) 98*cdf0e10cSrcweir */ 99*cdf0e10cSrcweir bool drawRectangularArea( 100*cdf0e10cSrcweir double fAlpha, 101*cdf0e10cSrcweir const ::basegfx::B2DPoint& rPos, 102*cdf0e10cSrcweir const ::basegfx::B2DRange& rArea, 103*cdf0e10cSrcweir const ::basegfx::B2DHomMatrix& rTransform ); 104*cdf0e10cSrcweir 105*cdf0e10cSrcweir /** Render the surface content to screen. 106*cdf0e10cSrcweir 107*cdf0e10cSrcweir @param fAlpha 108*cdf0e10cSrcweir Overall alpha for content 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir @param rPos 111*cdf0e10cSrcweir Output position 112*cdf0e10cSrcweir 113*cdf0e10cSrcweir @param rClipPoly 114*cdf0e10cSrcweir Clip polygon for the surface. The clip polygon is also 115*cdf0e10cSrcweir subject to the output transformation. 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir @param rTransform 118*cdf0e10cSrcweir Output transformation (does not affect output position) 119*cdf0e10cSrcweir */ 120*cdf0e10cSrcweir bool drawWithClip( double fAlpha, 121*cdf0e10cSrcweir const ::basegfx::B2DPoint& rPos, 122*cdf0e10cSrcweir const ::basegfx::B2DPolygon& rClipPoly, 123*cdf0e10cSrcweir const ::basegfx::B2DHomMatrix& rTransform ); 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir // private attributes 126*cdf0e10cSrcweir private: 127*cdf0e10cSrcweir IColorBufferSharedPtr mpColorBuffer; 128*cdf0e10cSrcweir 129*cdf0e10cSrcweir // invoking any of the above defined 'draw' methods 130*cdf0e10cSrcweir // will forward primitive commands to the rendermodule. 131*cdf0e10cSrcweir PageManagerSharedPtr mpPageManager; 132*cdf0e10cSrcweir 133*cdf0e10cSrcweir FragmentSharedPtr mpFragment; 134*cdf0e10cSrcweir 135*cdf0e10cSrcweir // the offset of this surface with regard to the source 136*cdf0e10cSrcweir // image. if the source image had to be tiled into multiple 137*cdf0e10cSrcweir // surfaces, this offset denotes the relative pixel distance 138*cdf0e10cSrcweir // from the source image's upper, left corner 139*cdf0e10cSrcweir ::basegfx::B2IPoint maSourceOffset; 140*cdf0e10cSrcweir 141*cdf0e10cSrcweir // the size in pixels of this surface. please note that 142*cdf0e10cSrcweir // this size is likely to be smaller than the size of 143*cdf0e10cSrcweir // the colorbuffer we're associated with since we 144*cdf0e10cSrcweir // maybe represent only a part of it. 145*cdf0e10cSrcweir ::basegfx::B2ISize maSize; 146*cdf0e10cSrcweir 147*cdf0e10cSrcweir bool mbIsDirty; 148*cdf0e10cSrcweir 149*cdf0e10cSrcweir // private methods 150*cdf0e10cSrcweir private: 151*cdf0e10cSrcweir bool refresh( canvas::IColorBuffer& rBuffer ) const; 152*cdf0e10cSrcweir void prepareRendering(); 153*cdf0e10cSrcweir 154*cdf0e10cSrcweir basegfx::B2DRectangle getUVCoords() const; 155*cdf0e10cSrcweir basegfx::B2DRectangle getUVCoords( const ::basegfx::B2IPoint& rPos, 156*cdf0e10cSrcweir const ::basegfx::B2ISize& rSize ) const; 157*cdf0e10cSrcweir }; 158*cdf0e10cSrcweir 159*cdf0e10cSrcweir typedef ::boost::shared_ptr< Surface > SurfaceSharedPtr; 160*cdf0e10cSrcweir } 161*cdf0e10cSrcweir 162*cdf0e10cSrcweir #endif 163