@@ -148,13 +148,19 @@ struct StrokeOptions {
148148 *
149149 * mFilter - Filter used when resampling source surface region to the
150150 * 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.
151154 */
152155struct DrawSurfaceOptions {
153- DrawSurfaceOptions (Filter aFilter = FILTER_LINEAR)
156+ DrawSurfaceOptions (Filter aFilter = FILTER_LINEAR,
157+ SamplingBounds aSamplingBounds = SAMPLING_UNBOUNDED)
154158 : mFilter (aFilter)
159+ , mSamplingBounds (aSamplingBounds)
155160 { }
156161
157162 Filter mFilter : 3 ;
163+ SamplingBounds mSamplingBounds : 1 ;
158164};
159165
160166/*
@@ -212,16 +218,20 @@ class LinearGradientPattern : public Pattern
212218public:
213219 /*
214220 * 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.
216223 * aStops GradientStops object for this gradient, this should match the
217224 * backend type of the draw target this pattern will be used with.
225+ * aMatrix A matrix that transforms the pattern into user space
218226 */
219227 LinearGradientPattern (const Point &aBegin,
220228 const Point &aEnd,
221- GradientStops *aStops)
229+ GradientStops *aStops,
230+ const Matrix &aMatrix = Matrix())
222231 : mBegin (aBegin)
223232 , mEnd (aEnd)
224233 , mStops (aStops)
234+ , mMatrix (aMatrix)
225235 {
226236 }
227237
@@ -230,6 +240,7 @@ class LinearGradientPattern : public Pattern
230240 Point mBegin ;
231241 Point mEnd ;
232242 RefPtr<GradientStops> mStops ;
243+ Matrix mMatrix ;
233244};
234245
235246/*
@@ -245,17 +256,20 @@ class RadialGradientPattern : public Pattern
245256 * aEnd End of the linear gradient
246257 * aStops GradientStops object for this gradient, this should match the
247258 * backend type of the draw target this pattern will be used with.
259+ * aMatrix A matrix that transforms the pattern into user space
248260 */
249261 RadialGradientPattern (const Point &aCenter1,
250262 const Point &aCenter2,
251263 Float aRadius1,
252264 Float aRadius2,
253- GradientStops *aStops)
265+ GradientStops *aStops,
266+ const Matrix &aMatrix = Matrix())
254267 : mCenter1 (aCenter1)
255268 , mCenter2 (aCenter2)
256269 , mRadius1 (aRadius1)
257270 , mRadius2 (aRadius2)
258271 , mStops (aStops)
272+ , mMatrix (aMatrix)
259273 {
260274 }
261275
@@ -266,6 +280,7 @@ class RadialGradientPattern : public Pattern
266280 Float mRadius1 ;
267281 Float mRadius2 ;
268282 RefPtr<GradientStops> mStops ;
283+ Matrix mMatrix ;
269284};
270285
271286/*
@@ -275,16 +290,27 @@ class RadialGradientPattern : public Pattern
275290class SurfacePattern : public Pattern
276291{
277292public:
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)
279302 : mSurface (aSourceSurface)
280303 , mExtendMode (aExtendMode)
304+ , mFilter (aFilter)
305+ , mMatrix (aMatrix)
281306 {}
282307
283308 virtual PatternType GetType () const { return PATTERN_SURFACE; }
284309
285310 RefPtr<SourceSurface> mSurface ;
286311 ExtendMode mExtendMode ;
287312 Filter mFilter ;
313+ Matrix mMatrix ;
288314};
289315
290316/*
@@ -311,6 +337,7 @@ class SourceSurface : public RefCounted<SourceSurface>
311337class DataSourceSurface : public SourceSurface
312338{
313339public:
340+ virtual SurfaceType GetType () const { return SURFACE_DATA; }
314341 /* Get the raw bitmap data of the surface */
315342 virtual unsigned char *GetData () = 0;
316343 /*
@@ -319,6 +346,12 @@ class DataSourceSurface : public SourceSurface
319346 */
320347 virtual int32_t Stride () = 0;
321348
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+
322355 virtual TemporaryRef<DataSourceSurface> GetDataSurface () { RefPtr<DataSourceSurface> temp = this ; return temp.forget (); }
323356};
324357
@@ -606,13 +639,34 @@ class DrawTarget : public RefCounted<DrawTarget>
606639 const Pattern &aPattern,
607640 const DrawOptions &aOptions = DrawOptions()) = 0;
608641
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+
609655 /*
610656 * Push a clip to the DrawTarget.
611657 *
612658 * aPath The path to clip to
613659 */
614660 virtual void PushClip (const Path *aPath) = 0;
615661
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+
616670 /* Pop a clip from the DrawTarget. A pop without a corresponding push will
617671 * be ignored.
618672 */
@@ -625,9 +679,9 @@ class DrawTarget : public RefCounted<DrawTarget>
625679 * The SourceSurface does not take ownership of aData, and may be freed at any time.
626680 */
627681 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;
631685
632686 /*
633687 * Create a SourceSurface optimized for use with this DrawTarget from
@@ -666,8 +720,13 @@ class DrawTarget : public RefCounted<DrawTarget>
666720 *
667721 * aStops An array of gradient stops
668722 * aNumStops Number of stops in the array aStops
723+ * aExtendNone This describes how to extend the stop color outside of the
724+ * gradient area.
669725 */
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 ;
671730
672731 const Matrix &GetTransform () const { return mTransform ; }
673732
@@ -695,12 +754,34 @@ class DrawTarget : public RefCounted<DrawTarget>
695754class Factory
696755{
697756public:
698- #ifdef USE_CAIRO
699757 static TemporaryRef<DrawTarget> CreateDrawTargetForCairoSurface (cairo_surface_t * aSurface);
700- #endif
701758
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);
704785
705786#ifdef WIN32
706787 static TemporaryRef<DrawTarget> CreateDrawTargetForD3D10Texture (ID3D10Texture2D *aTexture, SurfaceFormat aFormat);
0 commit comments