@@ -148,13 +148,19 @@ struct StrokeOptions {
148
148
*
149
149
* mFilter - Filter used when resampling source surface region to the
150
150
* destination region.
151
+ * aSamplingBounds - This indicates whether the implementation is allowed
152
+ * to sample pixels outside the source rectangle as
153
+ * specified in DrawSurface on the surface.
151
154
*/
152
155
struct DrawSurfaceOptions {
153
- DrawSurfaceOptions (Filter aFilter = FILTER_LINEAR)
156
+ DrawSurfaceOptions (Filter aFilter = FILTER_LINEAR,
157
+ SamplingBounds aSamplingBounds = SAMPLING_UNBOUNDED)
154
158
: mFilter (aFilter)
159
+ , mSamplingBounds (aSamplingBounds)
155
160
{ }
156
161
157
162
Filter mFilter : 3 ;
163
+ SamplingBounds mSamplingBounds : 1 ;
158
164
};
159
165
160
166
/*
@@ -212,16 +218,20 @@ class LinearGradientPattern : public Pattern
212
218
public:
213
219
/*
214
220
* aBegin Start of the linear gradient
215
- * aEnd End of the linear gradient
221
+ * aEnd End of the linear gradient - NOTE: In the case of a zero length
222
+ * gradient it will act as the color of the last stop.
216
223
* aStops GradientStops object for this gradient, this should match the
217
224
* backend type of the draw target this pattern will be used with.
225
+ * aMatrix A matrix that transforms the pattern into user space
218
226
*/
219
227
LinearGradientPattern (const Point &aBegin,
220
228
const Point &aEnd,
221
- GradientStops *aStops)
229
+ GradientStops *aStops,
230
+ const Matrix &aMatrix = Matrix())
222
231
: mBegin (aBegin)
223
232
, mEnd (aEnd)
224
233
, mStops (aStops)
234
+ , mMatrix (aMatrix)
225
235
{
226
236
}
227
237
@@ -230,6 +240,7 @@ class LinearGradientPattern : public Pattern
230
240
Point mBegin ;
231
241
Point mEnd ;
232
242
RefPtr<GradientStops> mStops ;
243
+ Matrix mMatrix ;
233
244
};
234
245
235
246
/*
@@ -245,17 +256,20 @@ class RadialGradientPattern : public Pattern
245
256
* aEnd End of the linear gradient
246
257
* aStops GradientStops object for this gradient, this should match the
247
258
* backend type of the draw target this pattern will be used with.
259
+ * aMatrix A matrix that transforms the pattern into user space
248
260
*/
249
261
RadialGradientPattern (const Point &aCenter1,
250
262
const Point &aCenter2,
251
263
Float aRadius1,
252
264
Float aRadius2,
253
- GradientStops *aStops)
265
+ GradientStops *aStops,
266
+ const Matrix &aMatrix = Matrix())
254
267
: mCenter1 (aCenter1)
255
268
, mCenter2 (aCenter2)
256
269
, mRadius1 (aRadius1)
257
270
, mRadius2 (aRadius2)
258
271
, mStops (aStops)
272
+ , mMatrix (aMatrix)
259
273
{
260
274
}
261
275
@@ -266,6 +280,7 @@ class RadialGradientPattern : public Pattern
266
280
Float mRadius1 ;
267
281
Float mRadius2 ;
268
282
RefPtr<GradientStops> mStops ;
283
+ Matrix mMatrix ;
269
284
};
270
285
271
286
/*
@@ -275,16 +290,27 @@ class RadialGradientPattern : public Pattern
275
290
class SurfacePattern : public Pattern
276
291
{
277
292
public:
278
- SurfacePattern (SourceSurface *aSourceSurface, ExtendMode aExtendMode)
293
+ /*
294
+ * aSourceSurface Surface to use for drawing
295
+ * aExtendMode This determines how the image is extended outside the bounds
296
+ * of the image.
297
+ * aMatrix A matrix that transforms the pattern into user space
298
+ * aFilter Resampling filter used for resampling the image.
299
+ */
300
+ SurfacePattern (SourceSurface *aSourceSurface, ExtendMode aExtendMode,
301
+ const Matrix &aMatrix = Matrix(), Filter aFilter = FILTER_LINEAR)
279
302
: mSurface (aSourceSurface)
280
303
, mExtendMode (aExtendMode)
304
+ , mFilter (aFilter)
305
+ , mMatrix (aMatrix)
281
306
{}
282
307
283
308
virtual PatternType GetType () const { return PATTERN_SURFACE; }
284
309
285
310
RefPtr<SourceSurface> mSurface ;
286
311
ExtendMode mExtendMode ;
287
312
Filter mFilter ;
313
+ Matrix mMatrix ;
288
314
};
289
315
290
316
/*
@@ -311,6 +337,7 @@ class SourceSurface : public RefCounted<SourceSurface>
311
337
class DataSourceSurface : public SourceSurface
312
338
{
313
339
public:
340
+ virtual SurfaceType GetType () const { return SURFACE_DATA; }
314
341
/* Get the raw bitmap data of the surface */
315
342
virtual unsigned char *GetData () = 0;
316
343
/*
@@ -319,6 +346,12 @@ class DataSourceSurface : public SourceSurface
319
346
*/
320
347
virtual int32_t Stride () = 0;
321
348
349
+ /*
350
+ * This function is called after modifying the data on the source surface
351
+ * directly through the data pointer.
352
+ */
353
+ virtual void MarkDirty () {}
354
+
322
355
virtual TemporaryRef<DataSourceSurface> GetDataSurface () { RefPtr<DataSourceSurface> temp = this ; return temp.forget (); }
323
356
};
324
357
@@ -606,13 +639,34 @@ class DrawTarget : public RefCounted<DrawTarget>
606
639
const Pattern &aPattern,
607
640
const DrawOptions &aOptions = DrawOptions()) = 0;
608
641
642
+ /*
643
+ * This takes a source pattern and a mask, and composites the source pattern
644
+ * onto the destination surface using the alpha channel of the mask pattern
645
+ * as a mask for the operation.
646
+ *
647
+ * aSource Source pattern
648
+ * aMask Mask pattern
649
+ * aOptions Drawing options
650
+ */
651
+ virtual void Mask (const Pattern &aSource,
652
+ const Pattern &aMask,
653
+ const DrawOptions &aOptions = DrawOptions()) = 0;
654
+
609
655
/*
610
656
* Push a clip to the DrawTarget.
611
657
*
612
658
* aPath The path to clip to
613
659
*/
614
660
virtual void PushClip (const Path *aPath) = 0;
615
661
662
+ /*
663
+ * Push an axis-aligned rectangular clip to the DrawTarget. This rectangle
664
+ * is specified in user space.
665
+ *
666
+ * aRect The rect to clip to
667
+ */
668
+ virtual void PushClipRect (const Rect &aRect) = 0;
669
+
616
670
/* Pop a clip from the DrawTarget. A pop without a corresponding push will
617
671
* be ignored.
618
672
*/
@@ -625,9 +679,9 @@ class DrawTarget : public RefCounted<DrawTarget>
625
679
* The SourceSurface does not take ownership of aData, and may be freed at any time.
626
680
*/
627
681
virtual TemporaryRef<SourceSurface> CreateSourceSurfaceFromData (unsigned char *aData,
628
- const IntSize &aSize,
629
- int32_t aStride,
630
- SurfaceFormat aFormat) const = 0;
682
+ const IntSize &aSize,
683
+ int32_t aStride,
684
+ SurfaceFormat aFormat) const = 0;
631
685
632
686
/*
633
687
* Create a SourceSurface optimized for use with this DrawTarget from
@@ -666,8 +720,13 @@ class DrawTarget : public RefCounted<DrawTarget>
666
720
*
667
721
* aStops An array of gradient stops
668
722
* aNumStops Number of stops in the array aStops
723
+ * aExtendNone This describes how to extend the stop color outside of the
724
+ * gradient area.
669
725
*/
670
- virtual TemporaryRef<GradientStops> CreateGradientStops (GradientStop *aStops, uint32_t aNumStops) const = 0;
726
+ virtual TemporaryRef<GradientStops>
727
+ CreateGradientStops (GradientStop *aStops,
728
+ uint32_t aNumStops,
729
+ ExtendMode aExtendMode = EXTEND_CLAMP) const = 0 ;
671
730
672
731
const Matrix &GetTransform () const { return mTransform ; }
673
732
@@ -695,12 +754,34 @@ class DrawTarget : public RefCounted<DrawTarget>
695
754
class Factory
696
755
{
697
756
public:
698
- #ifdef USE_CAIRO
699
757
static TemporaryRef<DrawTarget> CreateDrawTargetForCairoSurface (cairo_surface_t * aSurface);
700
- #endif
701
758
702
- static TemporaryRef<DrawTarget> CreateDrawTarget (BackendType aBackend, const IntSize &aSize, SurfaceFormat aFormat);
703
- static TemporaryRef<ScaledFont> CreateScaledFontForNativeFont (const NativeFont &aNativeFont, Float aSize);
759
+ static TemporaryRef<DrawTarget>
760
+ CreateDrawTarget (BackendType aBackend, const IntSize &aSize, SurfaceFormat aFormat);
761
+
762
+ static TemporaryRef<DrawTarget>
763
+ CreateDrawTargetForData (BackendType aBackend, unsigned char * aData, const IntSize &aSize, int32_t aStride, SurfaceFormat aFormat);
764
+
765
+ static TemporaryRef<ScaledFont>
766
+ CreateScaledFontForNativeFont (const NativeFont &aNativeFont, Float aSize);
767
+
768
+ /*
769
+ * This creates a simple data source surface for a certain size. It allocates
770
+ * new memory for the surface. This memory is freed when the surface is
771
+ * destroyed.
772
+ */
773
+ static TemporaryRef<DataSourceSurface>
774
+ CreateDataSourceSurface (const IntSize &aSize, SurfaceFormat aFormat);
775
+
776
+ /*
777
+ * This creates a simple data source surface for some existing data. It will
778
+ * wrap this data and the data for this source surface. The caller is
779
+ * responsible for deallocating the memory only after destruction of the
780
+ * surface.
781
+ */
782
+ static TemporaryRef<DataSourceSurface>
783
+ CreateDataSourceSurfaceFromData (unsigned char *aData, int32_t aStride,
784
+ const IntSize &aSize, SurfaceFormat aFormat);
704
785
705
786
#ifdef WIN32
706
787
static TemporaryRef<DrawTarget> CreateDrawTargetForD3D10Texture (ID3D10Texture2D *aTexture, SurfaceFormat aFormat);
0 commit comments