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 INCLUDED_CANVAS_SURFACE_HXX 25cdf0e10cSrcweir #define INCLUDED_CANVAS_SURFACE_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <basegfx/point/b2ipoint.hxx> 28cdf0e10cSrcweir #include <basegfx/point/b2dpoint.hxx> 29cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygon.hxx> 30cdf0e10cSrcweir #include <basegfx/range/b2drectangle.hxx> 31cdf0e10cSrcweir #include <basegfx/vector/b2isize.hxx> 32cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrix.hxx> 33cdf0e10cSrcweir #include <canvas/rendering/irendermodule.hxx> 34cdf0e10cSrcweir #include <canvas/rendering/icolorbuffer.hxx> 35cdf0e10cSrcweir #include <canvas/rendering/isurface.hxx> 36cdf0e10cSrcweir 37cdf0e10cSrcweir #include "surfacerect.hxx" 38cdf0e10cSrcweir #include "pagemanager.hxx" 39cdf0e10cSrcweir 40cdf0e10cSrcweir namespace canvas 41cdf0e10cSrcweir { 42cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////// 43cdf0e10cSrcweir // Surface 44cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////// 45cdf0e10cSrcweir 46*07a3d7f1SPedro Giffuni /** surfaces denote occupied areas within pages. 47cdf0e10cSrcweir 48cdf0e10cSrcweir pages encapsulate the hardware buffers that 49cdf0e10cSrcweir contain image data which can be used for texturing. 50cdf0e10cSrcweir surfaces are areas within those pages. 51cdf0e10cSrcweir */ 52cdf0e10cSrcweir class Surface 53cdf0e10cSrcweir { 54cdf0e10cSrcweir public: 55cdf0e10cSrcweir 56cdf0e10cSrcweir Surface( const PageManagerSharedPtr& rPageManager, 57cdf0e10cSrcweir const IColorBufferSharedPtr& rColorBuffer, 58cdf0e10cSrcweir const ::basegfx::B2IPoint& rPos, 59cdf0e10cSrcweir const ::basegfx::B2ISize& rSize ); 60cdf0e10cSrcweir ~Surface(); 61cdf0e10cSrcweir 62cdf0e10cSrcweir void setColorBufferDirty(); 63cdf0e10cSrcweir 64cdf0e10cSrcweir /** Render the surface content to screen. 65cdf0e10cSrcweir 66cdf0e10cSrcweir @param fAlpha 67cdf0e10cSrcweir Overall alpha for content 68cdf0e10cSrcweir 69cdf0e10cSrcweir @param rPos 70cdf0e10cSrcweir Output position 71cdf0e10cSrcweir 72cdf0e10cSrcweir @param rTransform 73cdf0e10cSrcweir Output transformation (does not affect output position) 74cdf0e10cSrcweir */ 75cdf0e10cSrcweir bool draw( double fAlpha, 76cdf0e10cSrcweir const ::basegfx::B2DPoint& rPos, 77cdf0e10cSrcweir const ::basegfx::B2DHomMatrix& rTransform ); 78cdf0e10cSrcweir 79cdf0e10cSrcweir /** Render the surface content to screen. 80cdf0e10cSrcweir 81cdf0e10cSrcweir @param fAlpha 82cdf0e10cSrcweir Overall alpha for content 83cdf0e10cSrcweir 84cdf0e10cSrcweir @param rPos 85cdf0e10cSrcweir Output position 86cdf0e10cSrcweir 87cdf0e10cSrcweir @param rArea 88cdf0e10cSrcweir Subset of the surface to render. Coordinate system are 89cdf0e10cSrcweir surface area pixel, given area will be clipped to the 90cdf0e10cSrcweir surface bounds. 91cdf0e10cSrcweir 92cdf0e10cSrcweir @param rTransform 93cdf0e10cSrcweir Output transformation (does not affect output position) 94cdf0e10cSrcweir */ 95cdf0e10cSrcweir bool drawRectangularArea( 96cdf0e10cSrcweir double fAlpha, 97cdf0e10cSrcweir const ::basegfx::B2DPoint& rPos, 98cdf0e10cSrcweir const ::basegfx::B2DRange& rArea, 99cdf0e10cSrcweir const ::basegfx::B2DHomMatrix& rTransform ); 100cdf0e10cSrcweir 101cdf0e10cSrcweir /** Render the surface content to screen. 102cdf0e10cSrcweir 103cdf0e10cSrcweir @param fAlpha 104cdf0e10cSrcweir Overall alpha for content 105cdf0e10cSrcweir 106cdf0e10cSrcweir @param rPos 107cdf0e10cSrcweir Output position 108cdf0e10cSrcweir 109cdf0e10cSrcweir @param rClipPoly 110cdf0e10cSrcweir Clip polygon for the surface. The clip polygon is also 111cdf0e10cSrcweir subject to the output transformation. 112cdf0e10cSrcweir 113cdf0e10cSrcweir @param rTransform 114cdf0e10cSrcweir Output transformation (does not affect output position) 115cdf0e10cSrcweir */ 116cdf0e10cSrcweir bool drawWithClip( double fAlpha, 117cdf0e10cSrcweir const ::basegfx::B2DPoint& rPos, 118cdf0e10cSrcweir const ::basegfx::B2DPolygon& rClipPoly, 119cdf0e10cSrcweir const ::basegfx::B2DHomMatrix& rTransform ); 120cdf0e10cSrcweir 121cdf0e10cSrcweir // private attributes 122cdf0e10cSrcweir private: 123cdf0e10cSrcweir IColorBufferSharedPtr mpColorBuffer; 124cdf0e10cSrcweir 125cdf0e10cSrcweir // invoking any of the above defined 'draw' methods 126cdf0e10cSrcweir // will forward primitive commands to the rendermodule. 127cdf0e10cSrcweir PageManagerSharedPtr mpPageManager; 128cdf0e10cSrcweir 129cdf0e10cSrcweir FragmentSharedPtr mpFragment; 130cdf0e10cSrcweir 131cdf0e10cSrcweir // the offset of this surface with regard to the source 132cdf0e10cSrcweir // image. if the source image had to be tiled into multiple 133cdf0e10cSrcweir // surfaces, this offset denotes the relative pixel distance 134cdf0e10cSrcweir // from the source image's upper, left corner 135cdf0e10cSrcweir ::basegfx::B2IPoint maSourceOffset; 136cdf0e10cSrcweir 137cdf0e10cSrcweir // the size in pixels of this surface. please note that 138cdf0e10cSrcweir // this size is likely to be smaller than the size of 139cdf0e10cSrcweir // the colorbuffer we're associated with since we 140cdf0e10cSrcweir // maybe represent only a part of it. 141cdf0e10cSrcweir ::basegfx::B2ISize maSize; 142cdf0e10cSrcweir 143cdf0e10cSrcweir bool mbIsDirty; 144cdf0e10cSrcweir 145cdf0e10cSrcweir // private methods 146cdf0e10cSrcweir private: 147cdf0e10cSrcweir bool refresh( canvas::IColorBuffer& rBuffer ) const; 148cdf0e10cSrcweir void prepareRendering(); 149cdf0e10cSrcweir 150cdf0e10cSrcweir basegfx::B2DRectangle getUVCoords() const; 151cdf0e10cSrcweir basegfx::B2DRectangle getUVCoords( const ::basegfx::B2IPoint& rPos, 152cdf0e10cSrcweir const ::basegfx::B2ISize& rSize ) const; 153cdf0e10cSrcweir }; 154cdf0e10cSrcweir 155cdf0e10cSrcweir typedef ::boost::shared_ptr< Surface > SurfaceSharedPtr; 156cdf0e10cSrcweir } 157cdf0e10cSrcweir 158cdf0e10cSrcweir #endif 159