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 // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_drawinglayer.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <drawinglayer/primitive3d/textureprimitive3d.hxx> 32*cdf0e10cSrcweir #include <drawinglayer/primitive3d/drawinglayer_primitivetypes3d.hxx> 33*cdf0e10cSrcweir #include <basegfx/color/bcolor.hxx> 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir using namespace com::sun::star; 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 40*cdf0e10cSrcweir 41*cdf0e10cSrcweir namespace drawinglayer 42*cdf0e10cSrcweir { 43*cdf0e10cSrcweir namespace primitive3d 44*cdf0e10cSrcweir { 45*cdf0e10cSrcweir TexturePrimitive3D::TexturePrimitive3D( 46*cdf0e10cSrcweir const Primitive3DSequence& rChildren, 47*cdf0e10cSrcweir const basegfx::B2DVector& rTextureSize, 48*cdf0e10cSrcweir bool bModulate, bool bFilter) 49*cdf0e10cSrcweir : GroupPrimitive3D(rChildren), 50*cdf0e10cSrcweir maTextureSize(rTextureSize), 51*cdf0e10cSrcweir mbModulate(bModulate), 52*cdf0e10cSrcweir mbFilter(bFilter) 53*cdf0e10cSrcweir { 54*cdf0e10cSrcweir } 55*cdf0e10cSrcweir 56*cdf0e10cSrcweir bool TexturePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const 57*cdf0e10cSrcweir { 58*cdf0e10cSrcweir if(GroupPrimitive3D::operator==(rPrimitive)) 59*cdf0e10cSrcweir { 60*cdf0e10cSrcweir const TexturePrimitive3D& rCompare = (TexturePrimitive3D&)rPrimitive; 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir return (getModulate() == rCompare.getModulate() 63*cdf0e10cSrcweir && getFilter() == rCompare.getFilter()); 64*cdf0e10cSrcweir } 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir return false; 67*cdf0e10cSrcweir } 68*cdf0e10cSrcweir } // end of namespace primitive3d 69*cdf0e10cSrcweir } // end of namespace drawinglayer 70*cdf0e10cSrcweir 71*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 72*cdf0e10cSrcweir 73*cdf0e10cSrcweir namespace drawinglayer 74*cdf0e10cSrcweir { 75*cdf0e10cSrcweir namespace primitive3d 76*cdf0e10cSrcweir { 77*cdf0e10cSrcweir UnifiedTransparenceTexturePrimitive3D::UnifiedTransparenceTexturePrimitive3D( 78*cdf0e10cSrcweir double fTransparence, 79*cdf0e10cSrcweir const Primitive3DSequence& rChildren) 80*cdf0e10cSrcweir : TexturePrimitive3D(rChildren, basegfx::B2DVector(), false, false), 81*cdf0e10cSrcweir mfTransparence(fTransparence) 82*cdf0e10cSrcweir { 83*cdf0e10cSrcweir } 84*cdf0e10cSrcweir 85*cdf0e10cSrcweir bool UnifiedTransparenceTexturePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const 86*cdf0e10cSrcweir { 87*cdf0e10cSrcweir if(TexturePrimitive3D::operator==(rPrimitive)) 88*cdf0e10cSrcweir { 89*cdf0e10cSrcweir const UnifiedTransparenceTexturePrimitive3D& rCompare = (UnifiedTransparenceTexturePrimitive3D&)rPrimitive; 90*cdf0e10cSrcweir 91*cdf0e10cSrcweir return (getTransparence() == rCompare.getTransparence()); 92*cdf0e10cSrcweir } 93*cdf0e10cSrcweir 94*cdf0e10cSrcweir return false; 95*cdf0e10cSrcweir } 96*cdf0e10cSrcweir 97*cdf0e10cSrcweir basegfx::B3DRange UnifiedTransparenceTexturePrimitive3D::getB3DRange(const geometry::ViewInformation3D& rViewInformation) const 98*cdf0e10cSrcweir { 99*cdf0e10cSrcweir // do not use the fallback to decomposition here since for a correct BoundRect we also 100*cdf0e10cSrcweir // need invisible (1.0 == getTransparence()) geometry; these would be deleted in the decomposition 101*cdf0e10cSrcweir return getB3DRangeFromPrimitive3DSequence(getChildren(), rViewInformation); 102*cdf0e10cSrcweir } 103*cdf0e10cSrcweir 104*cdf0e10cSrcweir Primitive3DSequence UnifiedTransparenceTexturePrimitive3D::get3DDecomposition(const geometry::ViewInformation3D& /*rViewInformation*/) const 105*cdf0e10cSrcweir { 106*cdf0e10cSrcweir if(0.0 == getTransparence()) 107*cdf0e10cSrcweir { 108*cdf0e10cSrcweir // no transparence used, so just use content 109*cdf0e10cSrcweir return getChildren(); 110*cdf0e10cSrcweir } 111*cdf0e10cSrcweir else if(getTransparence() > 0.0 && getTransparence() < 1.0) 112*cdf0e10cSrcweir { 113*cdf0e10cSrcweir // create TransparenceTexturePrimitive3D with fixed transparence as replacement 114*cdf0e10cSrcweir const basegfx::BColor aGray(getTransparence(), getTransparence(), getTransparence()); 115*cdf0e10cSrcweir const attribute::FillGradientAttribute aFillGradient(attribute::GRADIENTSTYLE_LINEAR, 0.0, 0.0, 0.0, 0.0, aGray, aGray, 1); 116*cdf0e10cSrcweir const Primitive3DReference xRef(new TransparenceTexturePrimitive3D(aFillGradient, getChildren(), getTextureSize())); 117*cdf0e10cSrcweir return Primitive3DSequence(&xRef, 1L); 118*cdf0e10cSrcweir } 119*cdf0e10cSrcweir else 120*cdf0e10cSrcweir { 121*cdf0e10cSrcweir // completely transparent or invalid definition, add nothing 122*cdf0e10cSrcweir return Primitive3DSequence(); 123*cdf0e10cSrcweir } 124*cdf0e10cSrcweir } 125*cdf0e10cSrcweir 126*cdf0e10cSrcweir // provide unique ID 127*cdf0e10cSrcweir ImplPrimitrive3DIDBlock(UnifiedTransparenceTexturePrimitive3D, PRIMITIVE3D_ID_UNIFIEDTRANSPARENCETEXTUREPRIMITIVE3D) 128*cdf0e10cSrcweir 129*cdf0e10cSrcweir } // end of namespace primitive3d 130*cdf0e10cSrcweir } // end of namespace drawinglayer 131*cdf0e10cSrcweir 132*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 133*cdf0e10cSrcweir 134*cdf0e10cSrcweir namespace drawinglayer 135*cdf0e10cSrcweir { 136*cdf0e10cSrcweir namespace primitive3d 137*cdf0e10cSrcweir { 138*cdf0e10cSrcweir GradientTexturePrimitive3D::GradientTexturePrimitive3D( 139*cdf0e10cSrcweir const attribute::FillGradientAttribute& rGradient, 140*cdf0e10cSrcweir const Primitive3DSequence& rChildren, 141*cdf0e10cSrcweir const basegfx::B2DVector& rTextureSize, 142*cdf0e10cSrcweir bool bModulate, 143*cdf0e10cSrcweir bool bFilter) 144*cdf0e10cSrcweir : TexturePrimitive3D(rChildren, rTextureSize, bModulate, bFilter), 145*cdf0e10cSrcweir maGradient(rGradient) 146*cdf0e10cSrcweir { 147*cdf0e10cSrcweir } 148*cdf0e10cSrcweir 149*cdf0e10cSrcweir bool GradientTexturePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const 150*cdf0e10cSrcweir { 151*cdf0e10cSrcweir if(TexturePrimitive3D::operator==(rPrimitive)) 152*cdf0e10cSrcweir { 153*cdf0e10cSrcweir const GradientTexturePrimitive3D& rCompare = (GradientTexturePrimitive3D&)rPrimitive; 154*cdf0e10cSrcweir 155*cdf0e10cSrcweir return (getGradient() == rCompare.getGradient()); 156*cdf0e10cSrcweir } 157*cdf0e10cSrcweir 158*cdf0e10cSrcweir return false; 159*cdf0e10cSrcweir } 160*cdf0e10cSrcweir 161*cdf0e10cSrcweir // provide unique ID 162*cdf0e10cSrcweir ImplPrimitrive3DIDBlock(GradientTexturePrimitive3D, PRIMITIVE3D_ID_GRADIENTTEXTUREPRIMITIVE3D) 163*cdf0e10cSrcweir 164*cdf0e10cSrcweir } // end of namespace primitive3d 165*cdf0e10cSrcweir } // end of namespace drawinglayer 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 168*cdf0e10cSrcweir 169*cdf0e10cSrcweir namespace drawinglayer 170*cdf0e10cSrcweir { 171*cdf0e10cSrcweir namespace primitive3d 172*cdf0e10cSrcweir { 173*cdf0e10cSrcweir BitmapTexturePrimitive3D::BitmapTexturePrimitive3D( 174*cdf0e10cSrcweir const attribute::FillBitmapAttribute& rFillBitmapAttribute, 175*cdf0e10cSrcweir const Primitive3DSequence& rChildren, 176*cdf0e10cSrcweir const basegfx::B2DVector& rTextureSize, 177*cdf0e10cSrcweir bool bModulate, bool bFilter) 178*cdf0e10cSrcweir : TexturePrimitive3D(rChildren, rTextureSize, bModulate, bFilter), 179*cdf0e10cSrcweir maFillBitmapAttribute(rFillBitmapAttribute) 180*cdf0e10cSrcweir { 181*cdf0e10cSrcweir } 182*cdf0e10cSrcweir 183*cdf0e10cSrcweir bool BitmapTexturePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const 184*cdf0e10cSrcweir { 185*cdf0e10cSrcweir if(TexturePrimitive3D::operator==(rPrimitive)) 186*cdf0e10cSrcweir { 187*cdf0e10cSrcweir const BitmapTexturePrimitive3D& rCompare = (BitmapTexturePrimitive3D&)rPrimitive; 188*cdf0e10cSrcweir 189*cdf0e10cSrcweir return (getFillBitmapAttribute() == rCompare.getFillBitmapAttribute()); 190*cdf0e10cSrcweir } 191*cdf0e10cSrcweir 192*cdf0e10cSrcweir return false; 193*cdf0e10cSrcweir } 194*cdf0e10cSrcweir 195*cdf0e10cSrcweir // provide unique ID 196*cdf0e10cSrcweir ImplPrimitrive3DIDBlock(BitmapTexturePrimitive3D, PRIMITIVE3D_ID_BITMAPTEXTUREPRIMITIVE3D) 197*cdf0e10cSrcweir 198*cdf0e10cSrcweir } // end of namespace primitive3d 199*cdf0e10cSrcweir } // end of namespace drawinglayer 200*cdf0e10cSrcweir 201*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 202*cdf0e10cSrcweir 203*cdf0e10cSrcweir namespace drawinglayer 204*cdf0e10cSrcweir { 205*cdf0e10cSrcweir namespace primitive3d 206*cdf0e10cSrcweir { 207*cdf0e10cSrcweir TransparenceTexturePrimitive3D::TransparenceTexturePrimitive3D( 208*cdf0e10cSrcweir const attribute::FillGradientAttribute& rGradient, 209*cdf0e10cSrcweir const Primitive3DSequence& rChildren, 210*cdf0e10cSrcweir const basegfx::B2DVector& rTextureSize) 211*cdf0e10cSrcweir : GradientTexturePrimitive3D(rGradient, rChildren, rTextureSize, false, false) 212*cdf0e10cSrcweir { 213*cdf0e10cSrcweir } 214*cdf0e10cSrcweir 215*cdf0e10cSrcweir bool TransparenceTexturePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const 216*cdf0e10cSrcweir { 217*cdf0e10cSrcweir return (GradientTexturePrimitive3D::operator==(rPrimitive)); 218*cdf0e10cSrcweir } 219*cdf0e10cSrcweir 220*cdf0e10cSrcweir // provide unique ID 221*cdf0e10cSrcweir ImplPrimitrive3DIDBlock(TransparenceTexturePrimitive3D, PRIMITIVE3D_ID_TRANSPARENCETEXTUREPRIMITIVE3D) 222*cdf0e10cSrcweir 223*cdf0e10cSrcweir } // end of namespace primitive3d 224*cdf0e10cSrcweir } // end of namespace drawinglayer 225*cdf0e10cSrcweir 226*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 227*cdf0e10cSrcweir // eof 228