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