LibreOffice Module canvas (master)  1
dx_canvashelper_texturefill.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <sal/config.h>
21 
22 #include <memory>
23 #include <tuple>
24 
33 #include <basegfx/utils/lerp.hxx>
34 #include <basegfx/utils/tools.hxx>
35 #include <com/sun/star/rendering/TexturingMode.hpp>
36 #include <rtl/math.hxx>
37 #include <tools/diagnose_ex.h>
38 
39 #include <parametricpolypolygon.hxx>
40 
41 #include "dx_canvashelper.hxx"
42 #include "dx_impltools.hxx"
43 #include "dx_spritecanvas.hxx"
44 
45 
46 using namespace ::com::sun::star;
47 
48 namespace dxcanvas
49 {
50  namespace
51  {
52  typedef std::shared_ptr< Gdiplus::PathGradientBrush > PathGradientBrushSharedPtr;
53 
54  bool fillLinearGradient( GraphicsSharedPtr const & rGraphics,
55  const ::canvas::ParametricPolyPolygon::Values& /*rValues*/,
56  const std::vector< Gdiplus::Color >& rColors,
57  const std::vector< Gdiplus::REAL >& rStops,
58  const GraphicsPathSharedPtr& rFillPath,
59  const rendering::Texture& texture )
60  {
61  // setup a linear gradient with given colors
62 
63 
64  Gdiplus::LinearGradientBrush aBrush(
65  Gdiplus::PointF(0.0f,
66  0.5f),
67  Gdiplus::PointF(1.0f,
68  0.5f),
69  rColors[0],
70  rColors[1] );
71 
72  aBrush.SetInterpolationColors(rColors.data(),
73  rStops.data(),
74  rColors.size());
75 
76  // render background color, as LinearGradientBrush does not
77  // properly support the WrapModeClamp repeat mode
78  Gdiplus::SolidBrush aBackgroundBrush( rColors[0] );
79  rGraphics->FillPath( &aBackgroundBrush, rFillPath.get() );
80 
81  // TODO(F2): This does not yet support other repeat modes
82  // except clamp, and probably also no multi-texturing
83 
84  // calculate parallelogram of gradient in object space, extend
85  // top and bottom of it such that they cover the whole fill
86  // path bound area
87  ::basegfx::B2DHomMatrix aTextureTransform;
88  ::basegfx::unotools::homMatrixFromAffineMatrix( aTextureTransform,
89  texture.AffineTransform );
90 
91  ::basegfx::B2DPoint aLeftTop( 0.0, 0.0 );
92  ::basegfx::B2DPoint aLeftBottom( 0.0, 1.0 );
93  ::basegfx::B2DPoint aRightTop( 1.0, 0.0 );
94  ::basegfx::B2DPoint aRightBottom( 1.0, 1.0 );
95 
96  aLeftTop *= aTextureTransform;
97  aLeftBottom *= aTextureTransform;
98  aRightTop *= aTextureTransform;
99  aRightBottom*= aTextureTransform;
100 
101  Gdiplus::RectF aBounds;
102  rFillPath->GetBounds( &aBounds );
103 
104  // now, we potentially have to enlarge our gradient area
105  // atop and below the transformed [0,1]x[0,1] unit rect,
106  // for the gradient to fill the complete bound rect.
107  ::basegfx::utils::infiniteLineFromParallelogram( aLeftTop,
108  aLeftBottom,
109  aRightTop,
110  aRightBottom,
111  tools::b2dRangeFromGdiPlusRectF( aBounds ) );
112 
113  // calc length of bound rect diagonal
114  const double nDiagonalLength(
115  hypot( aBounds.Width,
116  aBounds.Height ) );
117 
118  // generate a path which covers the 'right' side of the
119  // gradient, extending two times the bound rect diagonal to
120  // the right (and thus covering the whole half plane 'right'
121  // of the gradient). Take the middle of the gradient as the
122  // 'left' side of the polygon, to not fall victim to rounding
123  // errors at the edge.
124  ::basegfx::B2DVector aDirection( aLeftTop - aLeftBottom );
125  aDirection = ::basegfx::getNormalizedPerpendicular( aDirection );
126  aDirection *= nDiagonalLength;
127 
128  const ::basegfx::B2DPoint aHalfPlaneLeftTop( (aLeftTop + aRightTop) * 0.5 );
129  const ::basegfx::B2DPoint aHalfPlaneLeftBottom( (aLeftBottom + aRightBottom) * 0.5 );
130  const ::basegfx::B2DPoint aHalfPlaneRightTop( aRightTop + aDirection );
131  const ::basegfx::B2DPoint aHalfPlaneRightBottom( aRightBottom + aDirection );
132 
133  Gdiplus::GraphicsPath aSolidFillPath;
134  aSolidFillPath.AddLine( static_cast<Gdiplus::REAL>(aHalfPlaneLeftTop.getX()),
135  static_cast<Gdiplus::REAL>(aHalfPlaneLeftTop.getY()),
136  static_cast<Gdiplus::REAL>(aHalfPlaneRightTop.getX()),
137  static_cast<Gdiplus::REAL>(aHalfPlaneRightTop.getY()) );
138  aSolidFillPath.AddLine( static_cast<Gdiplus::REAL>(aHalfPlaneRightBottom.getX()),
139  static_cast<Gdiplus::REAL>(aHalfPlaneRightBottom.getY()),
140  static_cast<Gdiplus::REAL>(aHalfPlaneLeftBottom.getX()),
141  static_cast<Gdiplus::REAL>(aHalfPlaneLeftBottom.getY()) );
142  aSolidFillPath.CloseFigure();
143 
144  // limit output to fill path, we've just generated a path that
145  // might be substantially larger
146  if( Gdiplus::Ok != rGraphics->SetClip( rFillPath.get(),
147  Gdiplus::CombineModeIntersect ) )
148  {
149  return false;
150  }
151 
152  Gdiplus::SolidBrush aBackgroundBrush2( rColors.back() );
153  rGraphics->FillPath( &aBackgroundBrush2, &aSolidFillPath );
154 
155  // generate clip polygon from the extended parallelogram
156  // (exploit the feature that distinct lines in a figure are
157  // automatically closed by a straight line)
158  Gdiplus::GraphicsPath aClipPath;
159  aClipPath.AddLine( static_cast<Gdiplus::REAL>(aLeftTop.getX()),
160  static_cast<Gdiplus::REAL>(aLeftTop.getY()),
161  static_cast<Gdiplus::REAL>(aRightTop.getX()),
162  static_cast<Gdiplus::REAL>(aRightTop.getY()) );
163  aClipPath.AddLine( static_cast<Gdiplus::REAL>(aRightBottom.getX()),
164  static_cast<Gdiplus::REAL>(aRightBottom.getY()),
165  static_cast<Gdiplus::REAL>(aLeftBottom.getX()),
166  static_cast<Gdiplus::REAL>(aLeftBottom.getY()) );
167  aClipPath.CloseFigure();
168 
169  // limit output to a _single_ strip of the gradient (have to
170  // clip here, since GDI+ wrapmode clamp does not work here)
171  if( Gdiplus::Ok != rGraphics->SetClip( &aClipPath,
172  Gdiplus::CombineModeIntersect ) )
173  {
174  return false;
175  }
176 
177  // now, finally, output the gradient
178  Gdiplus::Matrix aMatrix;
180  texture.AffineTransform );
181  aBrush.SetTransform( &aMatrix );
182 
183  rGraphics->FillRectangle( &aBrush, aBounds );
184 
185  return true;
186  }
187 
188  int numColorSteps( const Gdiplus::Color& rColor1, const Gdiplus::Color& rColor2 )
189  {
190  return std::max(
191  labs( rColor1.GetRed() - rColor2.GetRed() ),
192  std::max(
193  labs( rColor1.GetGreen() - rColor2.GetGreen() ),
194  labs( rColor1.GetBlue() - rColor2.GetBlue() ) ) );
195  }
196 
197  bool fillPolygonalGradient( const ::canvas::ParametricPolyPolygon::Values& rValues,
198  const std::vector< Gdiplus::Color >& rColors,
199  const std::vector< Gdiplus::REAL >& rStops,
200  GraphicsSharedPtr const & rGraphics,
201  const GraphicsPathSharedPtr& rPath,
202  const rendering::ViewState& viewState,
203  const rendering::RenderState& renderState,
204  const rendering::Texture& texture )
205  {
206  // copy original fill path object, might have to change it
207  // below
208  GraphicsPathSharedPtr pFillPath( rPath );
209  const ::basegfx::B2DPolygon& rGradientPoly( rValues.maGradientPoly );
210 
211  PathGradientBrushSharedPtr pGradientBrush;
212 
213  // fill background uniformly with end color
214  Gdiplus::SolidBrush aBackgroundBrush( rColors[0] );
215  rGraphics->FillPath( &aBackgroundBrush, pFillPath.get() );
216 
217  Gdiplus::Matrix aMatrix;
218  // scale focus according to aspect ratio: for wider-than-tall
219  // bounds (nAspectRatio > 1.0), the focus must have non-zero
220  // width. Specifically, a bound rect twice as wide as tall has
221  // a focus of half its width.
222  if( !::rtl::math::approxEqual(rValues.mnAspectRatio,
223  1.0) )
224  {
225  // KLUDGE 1:
226 
227  // And here comes the greatest shortcoming of the GDI+
228  // gradients ever: SetFocusScales completely ignores
229  // transformations, both when set at the PathGradientBrush
230  // and for the world coordinate system. Thus, to correctly
231  // display anisotrophic path gradients, we have to render
232  // them by hand. WTF.
233 
234  // TODO(F2): This does not yet support other repeat modes
235  // except clamp, and probably also no multi-texturing
236 
237  // limit output to to-be-filled polygon
238  if( Gdiplus::Ok != rGraphics->SetClip( pFillPath.get(),
239  Gdiplus::CombineModeIntersect ) )
240  {
241  return false;
242  }
243 
244  // disable anti-aliasing, if any
245  const Gdiplus::SmoothingMode eOldAAMode( rGraphics->GetSmoothingMode() );
246  rGraphics->SetSmoothingMode( Gdiplus::SmoothingModeHighSpeed );
247 
248 
249  // determine number of steps to use
250 
251 
252  // TODO(Q2): Unify step calculations with VCL canvas
253  int nColorSteps = 0;
254  for( size_t i=0; i<rColors.size()-1; ++i )
255  nColorSteps += numColorSteps(rColors[i],rColors[i+1]);
256  ::basegfx::B2DHomMatrix aTotalTransform;
257  const int nStepCount=
259  viewState,
260  renderState,
261  texture,
262  nColorSteps);
263 
264  ::basegfx::B2DHomMatrix aTextureTransform;
265  ::basegfx::unotools::homMatrixFromAffineMatrix( aTextureTransform,
266  texture.AffineTransform );
267  // determine overall transformation for inner polygon (might
268  // have to be prefixed by anisotrophic scaling)
269  ::basegfx::B2DHomMatrix aInnerPolygonTransformMatrix;
270 
271  // For performance reasons, we create a temporary VCL polygon
272  // here, keep it all the way and only change the vertex values
273  // in the loop below (as ::Polygon is a pimpl class, creating
274  // one every loop turn would really stress the mem allocator)
275  ::basegfx::B2DPolygon aOuterPoly( rGradientPoly );
276  ::basegfx::B2DPolygon aInnerPoly;
277 
278  // subdivide polygon _before_ rendering, would otherwise have
279  // to be performed on every loop turn.
280  if( aOuterPoly.areControlPointsUsed() )
281  aOuterPoly = ::basegfx::utils::adaptiveSubdivideByAngle(aOuterPoly);
282 
283  aInnerPoly = aOuterPoly;
284  aOuterPoly.transform(aTextureTransform);
285 
286 
287  // apply scaling (possibly anisotrophic) to inner polygon
288 
289 
290  // scale inner polygon according to aspect ratio: for
291  // wider-than-tall bounds (nAspectRatio > 1.0), the inner
292  // polygon, representing the gradient focus, must have
293  // non-zero width. Specifically, a bound rect twice as wide as
294  // tall has a focus polygon of half its width.
295  const double nAspectRatio( rValues.mnAspectRatio );
296  if( nAspectRatio > 1.0 )
297  {
298  // width > height case
299  aInnerPolygonTransformMatrix.scale( 1.0 - 1.0/nAspectRatio,
300  0.0 );
301  }
302  else if( nAspectRatio < 1.0 )
303  {
304  // width < height case
305  aInnerPolygonTransformMatrix.scale( 0.0,
306  1.0 - nAspectRatio );
307  }
308  else
309  {
310  // isotrophic case
311  aInnerPolygonTransformMatrix.scale( 0.0, 0.0 );
312  }
313 
314  // and finally, add texture transform to it.
315  aInnerPolygonTransformMatrix *= aTextureTransform;
316 
317  // apply final matrix to polygon
318  aInnerPoly.transform( aInnerPolygonTransformMatrix );
319 
320  Gdiplus::GraphicsPath aCurrPath;
321  Gdiplus::SolidBrush aFillBrush( rColors[0] );
322  const sal_uInt32 nNumPoints( aOuterPoly.count() );
323  basegfx::utils::KeyStopLerp aLerper(rValues.maStops);
324  for( int i=1; i<nStepCount; ++i )
325  {
326  std::ptrdiff_t nIndex;
327  double fAlpha;
328  const double fT( i/double(nStepCount) );
329  std::tie(nIndex,fAlpha)=aLerper.lerp(fT);
330 
331  const Gdiplus::Color aFillColor(
332  static_cast<BYTE>( basegfx::utils::lerp(rColors[nIndex].GetRed(),rColors[nIndex+1].GetRed(),fAlpha) ),
333  static_cast<BYTE>( basegfx::utils::lerp(rColors[nIndex].GetGreen(),rColors[nIndex+1].GetGreen(),fAlpha) ),
334  static_cast<BYTE>( basegfx::utils::lerp(rColors[nIndex].GetBlue(),rColors[nIndex+1].GetBlue(),fAlpha) ) );
335 
336  aFillBrush.SetColor( aFillColor );
337  aCurrPath.Reset(); aCurrPath.StartFigure();
338  for( unsigned int p=1; p<nNumPoints; ++p )
339  {
340  const ::basegfx::B2DPoint& rOuterPoint1( aOuterPoly.getB2DPoint(p-1) );
341  const ::basegfx::B2DPoint& rInnerPoint1( aInnerPoly.getB2DPoint(p-1) );
342  const ::basegfx::B2DPoint& rOuterPoint2( aOuterPoly.getB2DPoint(p) );
343  const ::basegfx::B2DPoint& rInnerPoint2( aInnerPoly.getB2DPoint(p) );
344 
345  aCurrPath.AddLine(
346  Gdiplus::REAL(fT*rInnerPoint1.getX() + (1-fT)*rOuterPoint1.getX()),
347  Gdiplus::REAL(fT*rInnerPoint1.getY() + (1-fT)*rOuterPoint1.getY()),
348  Gdiplus::REAL(fT*rInnerPoint2.getX() + (1-fT)*rOuterPoint2.getX()),
349  Gdiplus::REAL(fT*rInnerPoint2.getY() + (1-fT)*rOuterPoint2.getY()));
350  }
351  aCurrPath.CloseFigure();
352 
353  rGraphics->FillPath( &aFillBrush, &aCurrPath );
354  }
355 
356  // reset to old anti-alias mode
357  rGraphics->SetSmoothingMode( eOldAAMode );
358  }
359  else
360  {
361  // KLUDGE 2:
362 
363  // We're generating a PathGradientBrush from scratch here,
364  // and put in a transformed GraphicsPath (transformed with
365  // the texture transform). This is because the
366  // straight-forward approach to store a Brush pointer at
367  // this class and set a texture transform via
368  // PathGradientBrush::SetTransform() is spoiled by MS: it
369  // seems that _either_ the texture transform, _or_ the
370  // transform at the Graphics can be set, but not both. If
371  // one sets both, only the translational components of the
372  // texture is respected.
373 
375  texture.AffineTransform );
376  GraphicsPathSharedPtr pGradientPath(
377  tools::graphicsPathFromB2DPolygon( rValues.maGradientPoly ));
378  pGradientPath->Transform( &aMatrix );
379 
380  pGradientBrush
381  = std::make_shared<Gdiplus::PathGradientBrush>( pGradientPath.get() );
382  pGradientBrush->SetInterpolationColors( rColors.data(),
383  rStops.data(),
384  rStops.size() );
385 
386  // explicitly setup center point. Since the center of GDI+
387  // gradients are by default the _centroid_ of the path
388  // (i.e. the weighted sum of edge points), it will not
389  // necessarily coincide with our notion of center.
390  Gdiplus::PointF aCenterPoint(0, 0);
391  aMatrix.TransformPoints( &aCenterPoint );
392  pGradientBrush->SetCenterPoint( aCenterPoint );
393 
394  const bool bTileX( texture.RepeatModeX != rendering::TexturingMode::CLAMP );
395  const bool bTileY( texture.RepeatModeY != rendering::TexturingMode::CLAMP );
396 
397  if( bTileX && bTileY )
398  pGradientBrush->SetWrapMode( Gdiplus::WrapModeTile );
399  else
400  {
401  OSL_ENSURE( bTileY == bTileX,
402  "ParametricPolyPolygon::fillPolygonalGradient(): Cannot have repeat x and repeat y differ!" );
403 
404  pGradientBrush->SetWrapMode( Gdiplus::WrapModeClamp );
405  }
406 
407  // render actual gradient
408  rGraphics->FillPath( pGradientBrush.get(), pFillPath.get() );
409  }
410 
411 #if OSL_DEBUG_LEVEL > 0
412  Gdiplus::Pen aPen( Gdiplus::Color( 255, 255, 0, 0 ),
413  0.0001f );
414 
415  rGraphics->DrawRectangle( &aPen,
416  Gdiplus::RectF( 0.0f, 0.0f,
417  1.0f, 1.0f ) );
418 #endif
419 
420  return true;
421  }
422 
423  bool fillGradient( const ::canvas::ParametricPolyPolygon::Values& rValues,
424  const std::vector< Gdiplus::Color >& rColors,
425  const std::vector< Gdiplus::REAL >& rStops,
426  GraphicsSharedPtr const & rGraphics,
427  const GraphicsPathSharedPtr& rPath,
428  const rendering::ViewState& viewState,
429  const rendering::RenderState& renderState,
430  const rendering::Texture& texture )
431  {
432  switch( rValues.meType )
433  {
434  case ::canvas::ParametricPolyPolygon::GradientType::Linear:
435  fillLinearGradient( rGraphics,
436  rValues,
437  rColors,
438  rStops,
439  rPath,
440  texture );
441  break;
442 
443  case ::canvas::ParametricPolyPolygon::GradientType::Elliptical:
444  case ::canvas::ParametricPolyPolygon::GradientType::Rectangular:
445  fillPolygonalGradient( rValues,
446  rColors,
447  rStops,
448  rGraphics,
449  rPath,
450  viewState,
451  renderState,
452  texture );
453  break;
454 
455  default:
456  ENSURE_OR_THROW( false,
457  "CanvasHelper::fillGradient(): Unexpected case" );
458  }
459 
460  return true;
461  }
462 
463  void fillBitmap( const uno::Reference< rendering::XBitmap >& xBitmap,
464  GraphicsSharedPtr const & rGraphics,
465  const GraphicsPathSharedPtr& rPath,
466  const rendering::Texture& rTexture )
467  {
468  OSL_ENSURE( rTexture.RepeatModeX ==
469  rTexture.RepeatModeY,
470  "CanvasHelper::fillBitmap(): GDI+ cannot handle differing X/Y repeat mode." );
471 
472  const bool bClamp( rTexture.RepeatModeX == rendering::TexturingMode::NONE &&
473  rTexture.RepeatModeY == rendering::TexturingMode::NONE );
474 
475  const geometry::IntegerSize2D aBmpSize( xBitmap->getSize() );
476  ENSURE_ARG_OR_THROW( aBmpSize.Width != 0 &&
477  aBmpSize.Height != 0,
478  "CanvasHelper::fillBitmap(): zero-sized texture bitmap" );
479 
480  // TODO(P3): Detect case that path is rectangle and
481  // bitmap is just scaled into that. Then, we can
482  // render directly, without generating a temporary
483  // GDI+ bitmap (this is significant, because drawing
484  // layer presents background object bitmap in that
485  // way!)
486  BitmapSharedPtr pBitmap(
487  tools::bitmapFromXBitmap( xBitmap ) );
488 
489  TextureBrushSharedPtr pBrush;
490  if( ::rtl::math::approxEqual( rTexture.Alpha,
491  1.0 ) )
492  {
493  pBrush = std::make_shared<Gdiplus::TextureBrush>(
494  pBitmap.get(),
495  bClamp ? Gdiplus::WrapModeClamp : Gdiplus::WrapModeTile );
496  }
497  else
498  {
499  Gdiplus::ImageAttributes aImgAttr;
500 
502  1.0,
503  1.0,
504  1.0,
505  rTexture.Alpha );
506 
507  Gdiplus::Rect aRect(0,0,
508  aBmpSize.Width,
509  aBmpSize.Height);
510  pBrush = std::make_shared<Gdiplus::TextureBrush>(
511  pBitmap.get(),
512  aRect,
513  &aImgAttr );
514 
515  pBrush->SetWrapMode(
516  bClamp ? Gdiplus::WrapModeClamp : Gdiplus::WrapModeTile );
517  }
518 
519  Gdiplus::Matrix aTextureTransform;
520  tools::gdiPlusMatrixFromAffineMatrix2D( aTextureTransform,
521  rTexture.AffineTransform );
522 
523  // scale down bitmap to [0,1]x[0,1] rect, as required
524  // from the XCanvas interface.
525  pBrush->MultiplyTransform( &aTextureTransform );
526  pBrush->ScaleTransform( static_cast< Gdiplus::REAL >(1.0/aBmpSize.Width),
527  static_cast< Gdiplus::REAL >(1.0/aBmpSize.Height) );
528 
529  // TODO(F1): FillRule
531  Gdiplus::Ok == rGraphics->FillPath( pBrush.get(),
532  rPath.get() ),
533  "CanvasHelper::fillTexturedPolyPolygon(): GDI+ call failed" );
534  }
535  }
536 
537 
538  uno::Reference< rendering::XCachedPrimitive > CanvasHelper::fillTexturedPolyPolygon( const rendering::XCanvas* /*pCanvas*/,
539  const uno::Reference< rendering::XPolyPolygon2D >& xPolyPolygon,
540  const rendering::ViewState& viewState,
541  const rendering::RenderState& renderState,
542  const uno::Sequence< rendering::Texture >& textures )
543  {
544  ENSURE_OR_THROW( xPolyPolygon.is(),
545  "CanvasHelper::fillTexturedPolyPolygon: polygon is NULL");
546  ENSURE_OR_THROW( textures.getLength(),
547  "CanvasHelper::fillTexturedPolyPolygon: empty texture sequence");
548 
549  if( needOutput() )
550  {
551  GraphicsSharedPtr pGraphics( mpGraphicsProvider->getGraphics() );
552 
553  setupGraphicsState( pGraphics, viewState, renderState );
554 
555  // TODO(F1): Multi-texturing
556  if( textures[0].Gradient.is() )
557  {
558  // try to cast XParametricPolyPolygon2D reference to
559  // our implementation class.
561  dynamic_cast< ::canvas::ParametricPolyPolygon* >( textures[0].Gradient.get() );
562 
563  if( pGradient )
564  {
565  const ::canvas::ParametricPolyPolygon::Values& rValues(
566  pGradient->getValues() );
567 
568  OSL_ASSERT(rValues.maColors.getLength() == rValues.maStops.getLength()
569  && rValues.maColors.getLength() > 1);
570 
571  std::vector< Gdiplus::Color > aColors(rValues.maColors.getLength());
572  std::transform(&rValues.maColors[0],
573  &rValues.maColors[0]+rValues.maColors.getLength(),
574  aColors.begin(),
575  [](const uno::Sequence< double >& aDoubleSequence) { return tools::sequenceToArgb(aDoubleSequence); } );
576  std::vector< Gdiplus::REAL > aStops;
577  comphelper::sequenceToContainer(aStops,rValues.maStops);
578 
579  // TODO(E1): Return value
580  // TODO(F1): FillRule
581  fillGradient( rValues,
582  aColors,
583  aStops,
584  pGraphics,
586  viewState,
587  renderState,
588  textures[0] );
589  }
590  }
591  else if( textures[0].Bitmap.is() )
592  {
593  // TODO(E1): Return value
594  // TODO(F1): FillRule
595  fillBitmap( textures[0].Bitmap,
596  pGraphics,
598  textures[0] );
599  }
600  }
601 
602  // TODO(P1): Provide caching here.
603  return uno::Reference< rendering::XCachedPrimitive >(nullptr);
604  }
605 }
606 
607 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_Int32 nIndex
GraphicsPathSharedPtr graphicsPathFromXPolyPolygon2D(const uno::Reference< rendering::XPolyPolygon2D > &xPoly, bool bNoLineJoin)
GraphicsPathSharedPtr graphicsPathFromB2DPolygon(const ::basegfx::B2DPolygon &rPoly, bool bNoLineJoin)
std::shared_ptr< Gdiplus::TextureBrush > TextureBrushSharedPtr
Definition: dx_winstuff.hxx:65
void setModulateImageAttributes(Gdiplus::ImageAttributes &o_rAttr, double nRedModulation, double nGreenModulation, double nBlueModulation, double nAlphaModulation)
#define max(a, b)
Definition: dx_winstuff.hxx:46
Gdiplus::ARGB sequenceToArgb(const uno::Sequence< sal_Int8 > &rColor)
DstType sequenceToContainer(const css::uno::Sequence< SrcType > &i_Sequence)
css::uno::Reference< css::rendering::XCachedPrimitive > fillTexturedPolyPolygon(const css::rendering::XCanvas *pCanvas, const css::uno::Reference< css::rendering::XPolyPolygon2D > &xPolyPolygon, const css::rendering::ViewState &viewState, const css::rendering::RenderState &renderState, const css::uno::Sequence< css::rendering::Texture > &textures)
int i
std::shared_ptr< ::cppcanvas::Bitmap > BitmapSharedPtr
css::drawing::Direction3D aDirection
void scale(double fX, double fY)
int calcGradientStepCount(::basegfx::B2DHomMatrix &rTotalTransform, const rendering::ViewState &viewState, const rendering::RenderState &renderState, const rendering::Texture &texture, int nColorSteps)
void setupGraphicsState(GraphicsSharedPtr const &rGraphics, const css::rendering::ViewState &viewState, const css::rendering::RenderState &renderState)
#define ENSURE_ARG_OR_THROW(c, m)
void transform(const basegfx::B2DHomMatrix &rMatrix)
#define ENSURE_OR_THROW(c, m)
B2DPolygon adaptiveSubdivideByAngle(const B2DPolygon &rCandidate, double fAngleBound)
std::shared_ptr< Gdiplus::GraphicsPath > GraphicsPathSharedPtr
Definition: dx_winstuff.hxx:62
ValueType lerp(const ValueType &rFrom, const ValueType &rTo, double t)
void * p
::basegfx::B2DRange b2dRangeFromGdiPlusRectF(const Gdiplus::RectF &rRect)
GraphicsProviderSharedPtr mpGraphicsProvider
Provides the Gdiplus::Graphics to render into.
Values getValues() const
Query all defining values of this object atomically.
BitmapSharedPtr bitmapFromXBitmap(const uno::Reference< rendering::XBitmap > &xBitmap)
std::shared_ptr< Gdiplus::Graphics > GraphicsSharedPtr
Definition: dx_winstuff.hxx:61
basegfx::B2DPoint const & getB2DPoint(sal_uInt32 nIndex) const
void gdiPlusMatrixFromAffineMatrix2D(Gdiplus::Matrix &rGdiplusMatrix, const geometry::AffineMatrix2D &rMatrix)