1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/2d/2D.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,1158 @@ 1.4 +/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- 1.5 + * This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef _MOZILLA_GFX_2D_H 1.10 +#define _MOZILLA_GFX_2D_H 1.11 + 1.12 +#include "Types.h" 1.13 +#include "Point.h" 1.14 +#include "Rect.h" 1.15 +#include "Matrix.h" 1.16 +#include "UserData.h" 1.17 + 1.18 +// GenericRefCountedBase allows us to hold on to refcounted objects of any type 1.19 +// (contrary to RefCounted<T> which requires knowing the type T) and, in particular, 1.20 +// without having a dependency on that type. This is used for DrawTargetSkia 1.21 +// to be able to hold on to a GLContext. 1.22 +#include "mozilla/GenericRefCounted.h" 1.23 + 1.24 +// This RefPtr class isn't ideal for usage in Azure, as it doesn't allow T** 1.25 +// outparams using the &-operator. But it will have to do as there's no easy 1.26 +// solution. 1.27 +#include "mozilla/RefPtr.h" 1.28 + 1.29 +#include "mozilla/DebugOnly.h" 1.30 + 1.31 +#ifdef MOZ_ENABLE_FREETYPE 1.32 +#include <string> 1.33 +#endif 1.34 + 1.35 +struct _cairo_surface; 1.36 +typedef _cairo_surface cairo_surface_t; 1.37 + 1.38 +struct _cairo_scaled_font; 1.39 +typedef _cairo_scaled_font cairo_scaled_font_t; 1.40 + 1.41 +struct ID3D10Device1; 1.42 +struct ID3D10Texture2D; 1.43 +struct ID3D11Device; 1.44 +struct ID2D1Device; 1.45 +struct IDWriteRenderingParams; 1.46 + 1.47 +class GrContext; 1.48 +struct GrGLInterface; 1.49 + 1.50 +struct CGContext; 1.51 +typedef struct CGContext *CGContextRef; 1.52 + 1.53 +namespace mozilla { 1.54 + 1.55 +namespace gfx { 1.56 + 1.57 +class SourceSurface; 1.58 +class DataSourceSurface; 1.59 +class DrawTarget; 1.60 +class DrawEventRecorder; 1.61 +class FilterNode; 1.62 + 1.63 +struct NativeSurface { 1.64 + NativeSurfaceType mType; 1.65 + SurfaceFormat mFormat; 1.66 + gfx::IntSize mSize; 1.67 + void *mSurface; 1.68 +}; 1.69 + 1.70 +struct NativeFont { 1.71 + NativeFontType mType; 1.72 + void *mFont; 1.73 +}; 1.74 + 1.75 +/* 1.76 + * This structure is used to send draw options that are universal to all drawing 1.77 + * operations. It consists of the following: 1.78 + * 1.79 + * mAlpha - Alpha value by which the mask generated by this operation is 1.80 + * multiplied. 1.81 + * mCompositionOp - The operator that indicates how the source and destination 1.82 + * patterns are blended. 1.83 + * mAntiAliasMode - The AntiAlias mode used for this drawing operation. 1.84 + */ 1.85 +struct DrawOptions { 1.86 + DrawOptions(Float aAlpha = 1.0f, 1.87 + CompositionOp aCompositionOp = CompositionOp::OP_OVER, 1.88 + AntialiasMode aAntialiasMode = AntialiasMode::DEFAULT) 1.89 + : mAlpha(aAlpha) 1.90 + , mCompositionOp(aCompositionOp) 1.91 + , mAntialiasMode(aAntialiasMode) 1.92 + {} 1.93 + 1.94 + Float mAlpha; 1.95 + CompositionOp mCompositionOp; 1.96 + AntialiasMode mAntialiasMode; 1.97 +}; 1.98 + 1.99 +/* 1.100 + * This structure is used to send stroke options that are used in stroking 1.101 + * operations. It consists of the following: 1.102 + * 1.103 + * mLineWidth - Width of the stroke in userspace. 1.104 + * mLineJoin - Join style used for joining lines. 1.105 + * mLineCap - Cap style used for capping lines. 1.106 + * mMiterLimit - Miter limit in units of linewidth 1.107 + * mDashPattern - Series of on/off userspace lengths defining dash. 1.108 + * Owned by the caller; must live at least as long as 1.109 + * this StrokeOptions. 1.110 + * mDashPattern != null <=> mDashLength > 0. 1.111 + * mDashLength - Number of on/off lengths in mDashPattern. 1.112 + * mDashOffset - Userspace offset within mDashPattern at which stroking 1.113 + * begins. 1.114 + */ 1.115 +struct StrokeOptions { 1.116 + StrokeOptions(Float aLineWidth = 1.0f, 1.117 + JoinStyle aLineJoin = JoinStyle::MITER_OR_BEVEL, 1.118 + CapStyle aLineCap = CapStyle::BUTT, 1.119 + Float aMiterLimit = 10.0f, 1.120 + size_t aDashLength = 0, 1.121 + const Float* aDashPattern = 0, 1.122 + Float aDashOffset = 0.f) 1.123 + : mLineWidth(aLineWidth) 1.124 + , mMiterLimit(aMiterLimit) 1.125 + , mDashPattern(aDashLength > 0 ? aDashPattern : 0) 1.126 + , mDashLength(aDashLength) 1.127 + , mDashOffset(aDashOffset) 1.128 + , mLineJoin(aLineJoin) 1.129 + , mLineCap(aLineCap) 1.130 + { 1.131 + MOZ_ASSERT(aDashLength == 0 || aDashPattern); 1.132 + } 1.133 + 1.134 + Float mLineWidth; 1.135 + Float mMiterLimit; 1.136 + const Float* mDashPattern; 1.137 + size_t mDashLength; 1.138 + Float mDashOffset; 1.139 + JoinStyle mLineJoin; 1.140 + CapStyle mLineCap; 1.141 +}; 1.142 + 1.143 +/* 1.144 + * This structure supplies additional options for calls to DrawSurface. 1.145 + * 1.146 + * mFilter - Filter used when resampling source surface region to the 1.147 + * destination region. 1.148 + * aSamplingBounds - This indicates whether the implementation is allowed 1.149 + * to sample pixels outside the source rectangle as 1.150 + * specified in DrawSurface on the surface. 1.151 + */ 1.152 +struct DrawSurfaceOptions { 1.153 + DrawSurfaceOptions(Filter aFilter = Filter::LINEAR, 1.154 + SamplingBounds aSamplingBounds = SamplingBounds::UNBOUNDED) 1.155 + : mFilter(aFilter) 1.156 + , mSamplingBounds(aSamplingBounds) 1.157 + { } 1.158 + 1.159 + Filter mFilter; 1.160 + SamplingBounds mSamplingBounds; 1.161 +}; 1.162 + 1.163 +/* 1.164 + * This class is used to store gradient stops, it can only be used with a 1.165 + * matching DrawTarget. Not adhering to this condition will make a draw call 1.166 + * fail. 1.167 + */ 1.168 +class GradientStops : public RefCounted<GradientStops> 1.169 +{ 1.170 +public: 1.171 + MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(GradientStops) 1.172 + virtual ~GradientStops() {} 1.173 + 1.174 + virtual BackendType GetBackendType() const = 0; 1.175 + 1.176 +protected: 1.177 + GradientStops() {} 1.178 +}; 1.179 + 1.180 +/* 1.181 + * This is the base class for 'patterns'. Patterns describe the pixels used as 1.182 + * the source for a masked composition operation that is done by the different 1.183 + * drawing commands. These objects are not backend specific, however for 1.184 + * example the gradient stops on a gradient pattern can be backend specific. 1.185 + */ 1.186 +class Pattern 1.187 +{ 1.188 +public: 1.189 + virtual ~Pattern() {} 1.190 + 1.191 + virtual PatternType GetType() const = 0; 1.192 + 1.193 +protected: 1.194 + Pattern() {} 1.195 +}; 1.196 + 1.197 +class ColorPattern : public Pattern 1.198 +{ 1.199 +public: 1.200 + ColorPattern(const Color &aColor) 1.201 + : mColor(aColor) 1.202 + {} 1.203 + 1.204 + virtual PatternType GetType() const { return PatternType::COLOR; } 1.205 + 1.206 + Color mColor; 1.207 +}; 1.208 + 1.209 +/* 1.210 + * This class is used for Linear Gradient Patterns, the gradient stops are 1.211 + * stored in a separate object and are backend dependent. This class itself 1.212 + * may be used on the stack. 1.213 + */ 1.214 +class LinearGradientPattern : public Pattern 1.215 +{ 1.216 +public: 1.217 + /* 1.218 + * aBegin Start of the linear gradient 1.219 + * aEnd End of the linear gradient - NOTE: In the case of a zero length 1.220 + * gradient it will act as the color of the last stop. 1.221 + * aStops GradientStops object for this gradient, this should match the 1.222 + * backend type of the draw target this pattern will be used with. 1.223 + * aMatrix A matrix that transforms the pattern into user space 1.224 + */ 1.225 + LinearGradientPattern(const Point &aBegin, 1.226 + const Point &aEnd, 1.227 + GradientStops *aStops, 1.228 + const Matrix &aMatrix = Matrix()) 1.229 + : mBegin(aBegin) 1.230 + , mEnd(aEnd) 1.231 + , mStops(aStops) 1.232 + , mMatrix(aMatrix) 1.233 + { 1.234 + } 1.235 + 1.236 + virtual PatternType GetType() const { return PatternType::LINEAR_GRADIENT; } 1.237 + 1.238 + Point mBegin; 1.239 + Point mEnd; 1.240 + RefPtr<GradientStops> mStops; 1.241 + Matrix mMatrix; 1.242 +}; 1.243 + 1.244 +/* 1.245 + * This class is used for Radial Gradient Patterns, the gradient stops are 1.246 + * stored in a separate object and are backend dependent. This class itself 1.247 + * may be used on the stack. 1.248 + */ 1.249 +class RadialGradientPattern : public Pattern 1.250 +{ 1.251 +public: 1.252 + /* 1.253 + * aCenter1 Center of the inner (focal) circle. 1.254 + * aCenter2 Center of the outer circle. 1.255 + * aRadius1 Radius of the inner (focal) circle. 1.256 + * aRadius2 Radius of the outer circle. 1.257 + * aStops GradientStops object for this gradient, this should match the 1.258 + * backend type of the draw target this pattern will be used with. 1.259 + * aMatrix A matrix that transforms the pattern into user space 1.260 + */ 1.261 + RadialGradientPattern(const Point &aCenter1, 1.262 + const Point &aCenter2, 1.263 + Float aRadius1, 1.264 + Float aRadius2, 1.265 + GradientStops *aStops, 1.266 + const Matrix &aMatrix = Matrix()) 1.267 + : mCenter1(aCenter1) 1.268 + , mCenter2(aCenter2) 1.269 + , mRadius1(aRadius1) 1.270 + , mRadius2(aRadius2) 1.271 + , mStops(aStops) 1.272 + , mMatrix(aMatrix) 1.273 + { 1.274 + } 1.275 + 1.276 + virtual PatternType GetType() const { return PatternType::RADIAL_GRADIENT; } 1.277 + 1.278 + Point mCenter1; 1.279 + Point mCenter2; 1.280 + Float mRadius1; 1.281 + Float mRadius2; 1.282 + RefPtr<GradientStops> mStops; 1.283 + Matrix mMatrix; 1.284 +}; 1.285 + 1.286 +/* 1.287 + * This class is used for Surface Patterns, they wrap a surface and a 1.288 + * repetition mode for the surface. This may be used on the stack. 1.289 + */ 1.290 +class SurfacePattern : public Pattern 1.291 +{ 1.292 +public: 1.293 + /* 1.294 + * aSourceSurface Surface to use for drawing 1.295 + * aExtendMode This determines how the image is extended outside the bounds 1.296 + * of the image. 1.297 + * aMatrix A matrix that transforms the pattern into user space 1.298 + * aFilter Resampling filter used for resampling the image. 1.299 + */ 1.300 + SurfacePattern(SourceSurface *aSourceSurface, ExtendMode aExtendMode, 1.301 + const Matrix &aMatrix = Matrix(), Filter aFilter = Filter::GOOD) 1.302 + : mSurface(aSourceSurface) 1.303 + , mExtendMode(aExtendMode) 1.304 + , mFilter(aFilter) 1.305 + , mMatrix(aMatrix) 1.306 + {} 1.307 + 1.308 + virtual PatternType GetType() const { return PatternType::SURFACE; } 1.309 + 1.310 + RefPtr<SourceSurface> mSurface; 1.311 + ExtendMode mExtendMode; 1.312 + Filter mFilter; 1.313 + Matrix mMatrix; 1.314 +}; 1.315 + 1.316 +/* 1.317 + * This is the base class for source surfaces. These objects are surfaces 1.318 + * which may be used as a source in a SurfacePattern or a DrawSurface call. 1.319 + * They cannot be drawn to directly. 1.320 + */ 1.321 +class SourceSurface : public RefCounted<SourceSurface> 1.322 +{ 1.323 +public: 1.324 + MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(SourceSurface) 1.325 + virtual ~SourceSurface() {} 1.326 + 1.327 + virtual SurfaceType GetType() const = 0; 1.328 + virtual IntSize GetSize() const = 0; 1.329 + virtual SurfaceFormat GetFormat() const = 0; 1.330 + 1.331 + /* This returns false if some event has made this source surface invalid for 1.332 + * usage with current DrawTargets. For example in the case of Direct2D this 1.333 + * could return false if we have switched devices since this surface was 1.334 + * created. 1.335 + */ 1.336 + virtual bool IsValid() const { return true; } 1.337 + 1.338 + /* 1.339 + * This function will get a DataSourceSurface for this surface, a 1.340 + * DataSourceSurface's data can be accessed directly. 1.341 + */ 1.342 + virtual TemporaryRef<DataSourceSurface> GetDataSurface() = 0; 1.343 + 1.344 + /* Tries to get this SourceSurface's native surface. This will fail if aType 1.345 + * is not the type of this SourceSurface's native surface. 1.346 + */ 1.347 + virtual void *GetNativeSurface(NativeSurfaceType aType) { 1.348 + return nullptr; 1.349 + } 1.350 + 1.351 + void AddUserData(UserDataKey *key, void *userData, void (*destroy)(void*)) { 1.352 + mUserData.Add(key, userData, destroy); 1.353 + } 1.354 + void *GetUserData(UserDataKey *key) { 1.355 + return mUserData.Get(key); 1.356 + } 1.357 + 1.358 +protected: 1.359 + UserData mUserData; 1.360 +}; 1.361 + 1.362 +class DataSourceSurface : public SourceSurface 1.363 +{ 1.364 +public: 1.365 + MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(DataSourceSurface) 1.366 + DataSourceSurface() 1.367 + : mIsMapped(false) 1.368 + { 1.369 + } 1.370 + 1.371 +#ifdef DEBUG 1.372 + virtual ~DataSourceSurface() 1.373 + { 1.374 + MOZ_ASSERT(!mIsMapped, "Someone forgot to call Unmap()"); 1.375 + } 1.376 +#endif 1.377 + 1.378 + struct MappedSurface { 1.379 + uint8_t *mData; 1.380 + int32_t mStride; 1.381 + }; 1.382 + 1.383 + enum MapType { 1.384 + READ, 1.385 + WRITE, 1.386 + READ_WRITE 1.387 + }; 1.388 + 1.389 + virtual SurfaceType GetType() const { return SurfaceType::DATA; } 1.390 + /* [DEPRECATED] 1.391 + * Get the raw bitmap data of the surface. 1.392 + * Can return null if there was OOM allocating surface data. 1.393 + */ 1.394 + virtual uint8_t *GetData() = 0; 1.395 + 1.396 + /* [DEPRECATED] 1.397 + * Stride of the surface, distance in bytes between the start of the image 1.398 + * data belonging to row y and row y+1. This may be negative. 1.399 + * Can return 0 if there was OOM allocating surface data. 1.400 + */ 1.401 + virtual int32_t Stride() = 0; 1.402 + 1.403 + virtual bool Map(MapType, MappedSurface *aMappedSurface) 1.404 + { 1.405 + aMappedSurface->mData = GetData(); 1.406 + aMappedSurface->mStride = Stride(); 1.407 + mIsMapped = true; 1.408 + return true; 1.409 + } 1.410 + 1.411 + virtual void Unmap() 1.412 + { 1.413 + MOZ_ASSERT(mIsMapped); 1.414 + mIsMapped = false; 1.415 + } 1.416 + 1.417 + /* 1.418 + * Returns a DataSourceSurface with the same data as this one, but 1.419 + * guaranteed to have surface->GetType() == SurfaceType::DATA. 1.420 + */ 1.421 + virtual TemporaryRef<DataSourceSurface> GetDataSurface(); 1.422 + 1.423 + bool mIsMapped; 1.424 +}; 1.425 + 1.426 +/* This is an abstract object that accepts path segments. */ 1.427 +class PathSink : public RefCounted<PathSink> 1.428 +{ 1.429 +public: 1.430 + MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(PathSink) 1.431 + virtual ~PathSink() {} 1.432 + 1.433 + /* Move the current point in the path, any figure currently being drawn will 1.434 + * be considered closed during fill operations, however when stroking the 1.435 + * closing line segment will not be drawn. 1.436 + */ 1.437 + virtual void MoveTo(const Point &aPoint) = 0; 1.438 + /* Add a linesegment to the current figure */ 1.439 + virtual void LineTo(const Point &aPoint) = 0; 1.440 + /* Add a cubic bezier curve to the current figure */ 1.441 + virtual void BezierTo(const Point &aCP1, 1.442 + const Point &aCP2, 1.443 + const Point &aCP3) = 0; 1.444 + /* Add a quadratic bezier curve to the current figure */ 1.445 + virtual void QuadraticBezierTo(const Point &aCP1, 1.446 + const Point &aCP2) = 0; 1.447 + /* Close the current figure, this will essentially generate a line segment 1.448 + * from the current point to the starting point for the current figure 1.449 + */ 1.450 + virtual void Close() = 0; 1.451 + /* Add an arc to the current figure */ 1.452 + virtual void Arc(const Point &aOrigin, float aRadius, float aStartAngle, 1.453 + float aEndAngle, bool aAntiClockwise = false) = 0; 1.454 + /* Point the current subpath is at - or where the next subpath will start 1.455 + * if there is no active subpath. 1.456 + */ 1.457 + virtual Point CurrentPoint() const = 0; 1.458 +}; 1.459 + 1.460 +class PathBuilder; 1.461 +class FlattenedPath; 1.462 + 1.463 +/* The path class is used to create (sets of) figures of any shape that can be 1.464 + * filled or stroked to a DrawTarget 1.465 + */ 1.466 +class Path : public RefCounted<Path> 1.467 +{ 1.468 +public: 1.469 + MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(Path) 1.470 + virtual ~Path(); 1.471 + 1.472 + virtual BackendType GetBackendType() const = 0; 1.473 + 1.474 + /* This returns a PathBuilder object that contains a copy of the contents of 1.475 + * this path and is still writable. 1.476 + */ 1.477 + virtual TemporaryRef<PathBuilder> CopyToBuilder(FillRule aFillRule = FillRule::FILL_WINDING) const = 0; 1.478 + virtual TemporaryRef<PathBuilder> TransformedCopyToBuilder(const Matrix &aTransform, 1.479 + FillRule aFillRule = FillRule::FILL_WINDING) const = 0; 1.480 + 1.481 + /* This function checks if a point lies within a path. It allows passing a 1.482 + * transform that will transform the path to the coordinate space in which 1.483 + * aPoint is given. 1.484 + */ 1.485 + virtual bool ContainsPoint(const Point &aPoint, const Matrix &aTransform) const = 0; 1.486 + 1.487 + 1.488 + /* This function checks if a point lies within the stroke of a path using the 1.489 + * specified strokeoptions. It allows passing a transform that will transform 1.490 + * the path to the coordinate space in which aPoint is given. 1.491 + */ 1.492 + virtual bool StrokeContainsPoint(const StrokeOptions &aStrokeOptions, 1.493 + const Point &aPoint, 1.494 + const Matrix &aTransform) const = 0; 1.495 + 1.496 + /* This functions gets the bounds of this path. These bounds are not 1.497 + * guaranteed to be tight. A transform may be specified that gives the bounds 1.498 + * after application of the transform. 1.499 + */ 1.500 + virtual Rect GetBounds(const Matrix &aTransform = Matrix()) const = 0; 1.501 + 1.502 + /* This function gets the bounds of the stroke of this path using the 1.503 + * specified strokeoptions. These bounds are not guaranteed to be tight. 1.504 + * A transform may be specified that gives the bounds after application of 1.505 + * the transform. 1.506 + */ 1.507 + virtual Rect GetStrokedBounds(const StrokeOptions &aStrokeOptions, 1.508 + const Matrix &aTransform = Matrix()) const = 0; 1.509 + 1.510 + /* Take the contents of this path and stream it to another sink, this works 1.511 + * regardless of the backend that might be used for the destination sink. 1.512 + */ 1.513 + virtual void StreamToSink(PathSink *aSink) const = 0; 1.514 + 1.515 + /* This gets the fillrule this path's builder was created with. This is not 1.516 + * mutable. 1.517 + */ 1.518 + virtual FillRule GetFillRule() const = 0; 1.519 + 1.520 + virtual Float ComputeLength(); 1.521 + 1.522 + virtual Point ComputePointAtLength(Float aLength, 1.523 + Point* aTangent = nullptr); 1.524 + 1.525 +protected: 1.526 + Path(); 1.527 + void EnsureFlattenedPath(); 1.528 + 1.529 + RefPtr<FlattenedPath> mFlattenedPath; 1.530 +}; 1.531 + 1.532 +/* The PathBuilder class allows path creation. Once finish is called on the 1.533 + * pathbuilder it may no longer be written to. 1.534 + */ 1.535 +class PathBuilder : public PathSink 1.536 +{ 1.537 +public: 1.538 + MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(PathBuilder) 1.539 + /* Finish writing to the path and return a Path object that can be used for 1.540 + * drawing. Future use of the builder results in a crash! 1.541 + */ 1.542 + virtual TemporaryRef<Path> Finish() = 0; 1.543 +}; 1.544 + 1.545 +struct Glyph 1.546 +{ 1.547 + uint32_t mIndex; 1.548 + Point mPosition; 1.549 +}; 1.550 + 1.551 +/* This class functions as a glyph buffer that can be drawn to a DrawTarget. 1.552 + * XXX - This should probably contain the guts of gfxTextRun in the future as 1.553 + * roc suggested. But for now it's a simple container for a glyph vector. 1.554 + */ 1.555 +struct GlyphBuffer 1.556 +{ 1.557 + // A pointer to a buffer of glyphs. Managed by the caller. 1.558 + const Glyph *mGlyphs; 1.559 + // Number of glyphs mGlyphs points to. 1.560 + uint32_t mNumGlyphs; 1.561 +}; 1.562 + 1.563 +/* This class is an abstraction of a backend/platform specific font object 1.564 + * at a particular size. It is passed into text drawing calls to describe 1.565 + * the font used for the drawing call. 1.566 + */ 1.567 +class ScaledFont : public RefCounted<ScaledFont> 1.568 +{ 1.569 +public: 1.570 + MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(ScaledFont) 1.571 + virtual ~ScaledFont() {} 1.572 + 1.573 + typedef void (*FontFileDataOutput)(const uint8_t *aData, uint32_t aLength, uint32_t aIndex, Float aGlyphSize, void *aBaton); 1.574 + 1.575 + virtual FontType GetType() const = 0; 1.576 + 1.577 + /* This allows getting a path that describes the outline of a set of glyphs. 1.578 + * A target is passed in so that the guarantee is made the returned path 1.579 + * can be used with any DrawTarget that has the same backend as the one 1.580 + * passed in. 1.581 + */ 1.582 + virtual TemporaryRef<Path> GetPathForGlyphs(const GlyphBuffer &aBuffer, const DrawTarget *aTarget) = 0; 1.583 + 1.584 + /* This copies the path describing the glyphs into a PathBuilder. We use this 1.585 + * API rather than a generic API to append paths because it allows easier 1.586 + * implementation in some backends, and more efficient implementation in 1.587 + * others. 1.588 + */ 1.589 + virtual void CopyGlyphsToBuilder(const GlyphBuffer &aBuffer, PathBuilder *aBuilder, BackendType aBackendType, const Matrix *aTransformHint = nullptr) = 0; 1.590 + 1.591 + virtual bool GetFontFileData(FontFileDataOutput, void *) { return false; } 1.592 + 1.593 + void AddUserData(UserDataKey *key, void *userData, void (*destroy)(void*)) { 1.594 + mUserData.Add(key, userData, destroy); 1.595 + } 1.596 + void *GetUserData(UserDataKey *key) { 1.597 + return mUserData.Get(key); 1.598 + } 1.599 + 1.600 +protected: 1.601 + ScaledFont() {} 1.602 + 1.603 + UserData mUserData; 1.604 +}; 1.605 + 1.606 +#ifdef MOZ_ENABLE_FREETYPE 1.607 +/** 1.608 + * Describes a font 1.609 + * Used to pass the key informatin from a gfxFont into Azure 1.610 + * XXX Should be replaced by a more long term solution, perhaps Bug 738014 1.611 + */ 1.612 +struct FontOptions 1.613 +{ 1.614 + std::string mName; 1.615 + FontStyle mStyle; 1.616 +}; 1.617 +#endif 1.618 + 1.619 + 1.620 +/* This class is designed to allow passing additional glyph rendering 1.621 + * parameters to the glyph drawing functions. This is an empty wrapper class 1.622 + * merely used to allow holding on to and passing around platform specific 1.623 + * parameters. This is because different platforms have unique rendering 1.624 + * parameters. 1.625 + */ 1.626 +class GlyphRenderingOptions : public RefCounted<GlyphRenderingOptions> 1.627 +{ 1.628 +public: 1.629 + MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(GlyphRenderingOptions) 1.630 + virtual ~GlyphRenderingOptions() {} 1.631 + 1.632 + virtual FontType GetType() const = 0; 1.633 + 1.634 +protected: 1.635 + GlyphRenderingOptions() {} 1.636 +}; 1.637 + 1.638 +/* This is the main class used for all the drawing. It is created through the 1.639 + * factory and accepts drawing commands. The results of drawing to a target 1.640 + * may be used either through a Snapshot or by flushing the target and directly 1.641 + * accessing the backing store a DrawTarget was created with. 1.642 + */ 1.643 +class DrawTarget : public RefCounted<DrawTarget> 1.644 +{ 1.645 +public: 1.646 + MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(DrawTarget) 1.647 + DrawTarget() : mTransformDirty(false), mPermitSubpixelAA(false) {} 1.648 + virtual ~DrawTarget() {} 1.649 + 1.650 + virtual BackendType GetType() const = 0; 1.651 + /** 1.652 + * Returns a SourceSurface which is a snapshot of the current contents of the DrawTarget. 1.653 + * Multiple calls to Snapshot() without any drawing operations in between will 1.654 + * normally return the same SourceSurface object. 1.655 + */ 1.656 + virtual TemporaryRef<SourceSurface> Snapshot() = 0; 1.657 + virtual IntSize GetSize() = 0; 1.658 + 1.659 + /** 1.660 + * If possible returns the bits to this DrawTarget for direct manipulation. While 1.661 + * the bits is locked any modifications to this DrawTarget is forbidden. 1.662 + * Release takes the original data pointer for safety. 1.663 + */ 1.664 + virtual bool LockBits(uint8_t** aData, IntSize* aSize, 1.665 + int32_t* aStride, SurfaceFormat* aFormat) { return false; } 1.666 + virtual void ReleaseBits(uint8_t* aData) {} 1.667 + 1.668 + /* Ensure that the DrawTarget backend has flushed all drawing operations to 1.669 + * this draw target. This must be called before using the backing surface of 1.670 + * this draw target outside of GFX 2D code. 1.671 + */ 1.672 + virtual void Flush() = 0; 1.673 + 1.674 + /* 1.675 + * Draw a surface to the draw target. Possibly doing partial drawing or 1.676 + * applying scaling. No sampling happens outside the source. 1.677 + * 1.678 + * aSurface Source surface to draw 1.679 + * aDest Destination rectangle that this drawing operation should draw to 1.680 + * aSource Source rectangle in aSurface coordinates, this area of aSurface 1.681 + * will be stretched to the size of aDest. 1.682 + * aOptions General draw options that are applied to the operation 1.683 + * aSurfOptions DrawSurface options that are applied 1.684 + */ 1.685 + virtual void DrawSurface(SourceSurface *aSurface, 1.686 + const Rect &aDest, 1.687 + const Rect &aSource, 1.688 + const DrawSurfaceOptions &aSurfOptions = DrawSurfaceOptions(), 1.689 + const DrawOptions &aOptions = DrawOptions()) = 0; 1.690 + 1.691 + /* 1.692 + * Draw the output of a FilterNode to the DrawTarget. 1.693 + * 1.694 + * aNode FilterNode to draw 1.695 + * aSourceRect Source rectangle in FilterNode space to draw 1.696 + * aDestPoint Destination point on the DrawTarget to draw the 1.697 + * SourceRectangle of the filter output to 1.698 + */ 1.699 + virtual void DrawFilter(FilterNode *aNode, 1.700 + const Rect &aSourceRect, 1.701 + const Point &aDestPoint, 1.702 + const DrawOptions &aOptions = DrawOptions()) = 0; 1.703 + 1.704 + /* 1.705 + * Blend a surface to the draw target with a shadow. The shadow is drawn as a 1.706 + * gaussian blur using a specified sigma. The shadow is clipped to the size 1.707 + * of the input surface, so the input surface should contain a transparent 1.708 + * border the size of the approximate coverage of the blur (3 * aSigma). 1.709 + * NOTE: This function works in device space! 1.710 + * 1.711 + * aSurface Source surface to draw. 1.712 + * aDest Destination point that this drawing operation should draw to. 1.713 + * aColor Color of the drawn shadow 1.714 + * aOffset Offset of the shadow 1.715 + * aSigma Sigma used for the guassian filter kernel 1.716 + * aOperator Composition operator used 1.717 + */ 1.718 + virtual void DrawSurfaceWithShadow(SourceSurface *aSurface, 1.719 + const Point &aDest, 1.720 + const Color &aColor, 1.721 + const Point &aOffset, 1.722 + Float aSigma, 1.723 + CompositionOp aOperator) = 0; 1.724 + 1.725 + /* 1.726 + * Clear a rectangle on the draw target to transparent black. This will 1.727 + * respect the clipping region and transform. 1.728 + * 1.729 + * aRect Rectangle to clear 1.730 + */ 1.731 + virtual void ClearRect(const Rect &aRect) = 0; 1.732 + 1.733 + /* 1.734 + * This is essentially a 'memcpy' between two surfaces. It moves a pixel 1.735 + * aligned area from the source surface unscaled directly onto the 1.736 + * drawtarget. This ignores both transform and clip. 1.737 + * 1.738 + * aSurface Surface to copy from 1.739 + * aSourceRect Source rectangle to be copied 1.740 + * aDest Destination point to copy the surface to 1.741 + */ 1.742 + virtual void CopySurface(SourceSurface *aSurface, 1.743 + const IntRect &aSourceRect, 1.744 + const IntPoint &aDestination) = 0; 1.745 + 1.746 + /* 1.747 + * Same as CopySurface, except uses itself as the source. 1.748 + * 1.749 + * Some backends may be able to optimize this better 1.750 + * than just taking a snapshot and using CopySurface. 1.751 + */ 1.752 + virtual void CopyRect(const IntRect &aSourceRect, 1.753 + const IntPoint &aDestination) 1.754 + { 1.755 + RefPtr<SourceSurface> source = Snapshot(); 1.756 + CopySurface(source, aSourceRect, aDestination); 1.757 + } 1.758 + 1.759 + /* 1.760 + * Fill a rectangle on the DrawTarget with a certain source pattern. 1.761 + * 1.762 + * aRect Rectangle that forms the mask of this filling operation 1.763 + * aPattern Pattern that forms the source of this filling operation 1.764 + * aOptions Options that are applied to this operation 1.765 + */ 1.766 + virtual void FillRect(const Rect &aRect, 1.767 + const Pattern &aPattern, 1.768 + const DrawOptions &aOptions = DrawOptions()) = 0; 1.769 + 1.770 + /* 1.771 + * Stroke a rectangle on the DrawTarget with a certain source pattern. 1.772 + * 1.773 + * aRect Rectangle that forms the mask of this stroking operation 1.774 + * aPattern Pattern that forms the source of this stroking operation 1.775 + * aOptions Options that are applied to this operation 1.776 + */ 1.777 + virtual void StrokeRect(const Rect &aRect, 1.778 + const Pattern &aPattern, 1.779 + const StrokeOptions &aStrokeOptions = StrokeOptions(), 1.780 + const DrawOptions &aOptions = DrawOptions()) = 0; 1.781 + 1.782 + /* 1.783 + * Stroke a line on the DrawTarget with a certain source pattern. 1.784 + * 1.785 + * aStart Starting point of the line 1.786 + * aEnd End point of the line 1.787 + * aPattern Pattern that forms the source of this stroking operation 1.788 + * aOptions Options that are applied to this operation 1.789 + */ 1.790 + virtual void StrokeLine(const Point &aStart, 1.791 + const Point &aEnd, 1.792 + const Pattern &aPattern, 1.793 + const StrokeOptions &aStrokeOptions = StrokeOptions(), 1.794 + const DrawOptions &aOptions = DrawOptions()) = 0; 1.795 + 1.796 + /* 1.797 + * Stroke a path on the draw target with a certain source pattern. 1.798 + * 1.799 + * aPath Path that is to be stroked 1.800 + * aPattern Pattern that should be used for the stroke 1.801 + * aStrokeOptions Stroke options used for this operation 1.802 + * aOptions Draw options used for this operation 1.803 + */ 1.804 + virtual void Stroke(const Path *aPath, 1.805 + const Pattern &aPattern, 1.806 + const StrokeOptions &aStrokeOptions = StrokeOptions(), 1.807 + const DrawOptions &aOptions = DrawOptions()) = 0; 1.808 + 1.809 + /* 1.810 + * Fill a path on the draw target with a certain source pattern. 1.811 + * 1.812 + * aPath Path that is to be filled 1.813 + * aPattern Pattern that should be used for the fill 1.814 + * aOptions Draw options used for this operation 1.815 + */ 1.816 + virtual void Fill(const Path *aPath, 1.817 + const Pattern &aPattern, 1.818 + const DrawOptions &aOptions = DrawOptions()) = 0; 1.819 + 1.820 + /* 1.821 + * Fill a series of clyphs on the draw target with a certain source pattern. 1.822 + */ 1.823 + virtual void FillGlyphs(ScaledFont *aFont, 1.824 + const GlyphBuffer &aBuffer, 1.825 + const Pattern &aPattern, 1.826 + const DrawOptions &aOptions = DrawOptions(), 1.827 + const GlyphRenderingOptions *aRenderingOptions = nullptr) = 0; 1.828 + 1.829 + /* 1.830 + * This takes a source pattern and a mask, and composites the source pattern 1.831 + * onto the destination surface using the alpha channel of the mask pattern 1.832 + * as a mask for the operation. 1.833 + * 1.834 + * aSource Source pattern 1.835 + * aMask Mask pattern 1.836 + * aOptions Drawing options 1.837 + */ 1.838 + virtual void Mask(const Pattern &aSource, 1.839 + const Pattern &aMask, 1.840 + const DrawOptions &aOptions = DrawOptions()) = 0; 1.841 + 1.842 + /* 1.843 + * This takes a source pattern and a mask, and composites the source pattern 1.844 + * onto the destination surface using the alpha channel of the mask source. 1.845 + * The operation is bound by the extents of the mask. 1.846 + * 1.847 + * aSource Source pattern 1.848 + * aMask Mask surface 1.849 + * aOffset a transformed offset that the surface is masked at 1.850 + * aOptions Drawing options 1.851 + */ 1.852 + virtual void MaskSurface(const Pattern &aSource, 1.853 + SourceSurface *aMask, 1.854 + Point aOffset, 1.855 + const DrawOptions &aOptions = DrawOptions()) = 0; 1.856 + 1.857 + /* 1.858 + * Push a clip to the DrawTarget. 1.859 + * 1.860 + * aPath The path to clip to 1.861 + */ 1.862 + virtual void PushClip(const Path *aPath) = 0; 1.863 + 1.864 + /* 1.865 + * Push an axis-aligned rectangular clip to the DrawTarget. This rectangle 1.866 + * is specified in user space. 1.867 + * 1.868 + * aRect The rect to clip to 1.869 + */ 1.870 + virtual void PushClipRect(const Rect &aRect) = 0; 1.871 + 1.872 + /* Pop a clip from the DrawTarget. A pop without a corresponding push will 1.873 + * be ignored. 1.874 + */ 1.875 + virtual void PopClip() = 0; 1.876 + 1.877 + /* 1.878 + * Create a SourceSurface optimized for use with this DrawTarget from 1.879 + * existing bitmap data in memory. 1.880 + * 1.881 + * The SourceSurface does not take ownership of aData, and may be freed at any time. 1.882 + */ 1.883 + virtual TemporaryRef<SourceSurface> CreateSourceSurfaceFromData(unsigned char *aData, 1.884 + const IntSize &aSize, 1.885 + int32_t aStride, 1.886 + SurfaceFormat aFormat) const = 0; 1.887 + 1.888 + /* 1.889 + * Create a SourceSurface optimized for use with this DrawTarget from an 1.890 + * arbitrary SourceSurface type supported by this backend. This may return 1.891 + * aSourceSurface or some other existing surface. 1.892 + */ 1.893 + virtual TemporaryRef<SourceSurface> OptimizeSourceSurface(SourceSurface *aSurface) const = 0; 1.894 + 1.895 + /* 1.896 + * Create a SourceSurface for a type of NativeSurface. This may fail if the 1.897 + * draw target does not know how to deal with the type of NativeSurface passed 1.898 + * in. 1.899 + */ 1.900 + virtual TemporaryRef<SourceSurface> 1.901 + CreateSourceSurfaceFromNativeSurface(const NativeSurface &aSurface) const = 0; 1.902 + 1.903 + /* 1.904 + * Create a DrawTarget whose snapshot is optimized for use with this DrawTarget. 1.905 + */ 1.906 + virtual TemporaryRef<DrawTarget> 1.907 + CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aFormat) const = 0; 1.908 + 1.909 + /* 1.910 + * Create a draw target optimized for drawing a shadow. 1.911 + * 1.912 + * Note that aSigma is the blur radius that must be used when we draw the 1.913 + * shadow. Also note that this doesn't affect the size of the allocated 1.914 + * surface, the caller is still responsible for including the shadow area in 1.915 + * its size. 1.916 + */ 1.917 + virtual TemporaryRef<DrawTarget> 1.918 + CreateShadowDrawTarget(const IntSize &aSize, SurfaceFormat aFormat, 1.919 + float aSigma) const 1.920 + { 1.921 + return CreateSimilarDrawTarget(aSize, aFormat); 1.922 + } 1.923 + 1.924 + /* 1.925 + * Create a path builder with the specified fillmode. 1.926 + * 1.927 + * We need the fill mode up front because of Direct2D. 1.928 + * ID2D1SimplifiedGeometrySink requires the fill mode 1.929 + * to be set before calling BeginFigure(). 1.930 + */ 1.931 + virtual TemporaryRef<PathBuilder> CreatePathBuilder(FillRule aFillRule = FillRule::FILL_WINDING) const = 0; 1.932 + 1.933 + /* 1.934 + * Create a GradientStops object that holds information about a set of 1.935 + * gradient stops, this object is required for linear or radial gradient 1.936 + * patterns to represent the color stops in the gradient. 1.937 + * 1.938 + * aStops An array of gradient stops 1.939 + * aNumStops Number of stops in the array aStops 1.940 + * aExtendNone This describes how to extend the stop color outside of the 1.941 + * gradient area. 1.942 + */ 1.943 + virtual TemporaryRef<GradientStops> 1.944 + CreateGradientStops(GradientStop *aStops, 1.945 + uint32_t aNumStops, 1.946 + ExtendMode aExtendMode = ExtendMode::CLAMP) const = 0; 1.947 + 1.948 + /* 1.949 + * Create a FilterNode object that can be used to apply a filter to various 1.950 + * inputs. 1.951 + * 1.952 + * aType Type of filter node to be created. 1.953 + */ 1.954 + virtual TemporaryRef<FilterNode> CreateFilter(FilterType aType) = 0; 1.955 + 1.956 + const Matrix &GetTransform() const { return mTransform; } 1.957 + 1.958 + /* 1.959 + * Set a transform on the surface, this transform is applied at drawing time 1.960 + * to both the mask and source of the operation. 1.961 + */ 1.962 + virtual void SetTransform(const Matrix &aTransform) 1.963 + { mTransform = aTransform; mTransformDirty = true; } 1.964 + 1.965 + SurfaceFormat GetFormat() { return mFormat; } 1.966 + 1.967 + /* Tries to get a native surface for a DrawTarget, this may fail if the 1.968 + * draw target cannot convert to this surface type. 1.969 + */ 1.970 + virtual void *GetNativeSurface(NativeSurfaceType aType) { return nullptr; } 1.971 + 1.972 + virtual bool IsDualDrawTarget() { return false; } 1.973 + 1.974 + void AddUserData(UserDataKey *key, void *userData, void (*destroy)(void*)) { 1.975 + mUserData.Add(key, userData, destroy); 1.976 + } 1.977 + void *GetUserData(UserDataKey *key) { 1.978 + return mUserData.Get(key); 1.979 + } 1.980 + 1.981 + /* Within this rectangle all pixels will be opaque by the time the result of 1.982 + * this DrawTarget is first used for drawing. Either by the underlying surface 1.983 + * being used as an input to external drawing, or Snapshot() being called. 1.984 + * This rectangle is specified in device space. 1.985 + */ 1.986 + void SetOpaqueRect(const IntRect &aRect) { 1.987 + mOpaqueRect = aRect; 1.988 + } 1.989 + 1.990 + const IntRect &GetOpaqueRect() const { 1.991 + return mOpaqueRect; 1.992 + } 1.993 + 1.994 + virtual void SetPermitSubpixelAA(bool aPermitSubpixelAA) { 1.995 + mPermitSubpixelAA = aPermitSubpixelAA; 1.996 + } 1.997 + 1.998 + bool GetPermitSubpixelAA() { 1.999 + return mPermitSubpixelAA; 1.1000 + } 1.1001 + 1.1002 +#ifdef USE_SKIA_GPU 1.1003 + virtual bool InitWithGrContext(GrContext* aGrContext, 1.1004 + const IntSize &aSize, 1.1005 + SurfaceFormat aFormat) 1.1006 + { 1.1007 + MOZ_CRASH(); 1.1008 + } 1.1009 +#endif 1.1010 + 1.1011 +protected: 1.1012 + UserData mUserData; 1.1013 + Matrix mTransform; 1.1014 + IntRect mOpaqueRect; 1.1015 + bool mTransformDirty : 1; 1.1016 + bool mPermitSubpixelAA : 1; 1.1017 + 1.1018 + SurfaceFormat mFormat; 1.1019 +}; 1.1020 + 1.1021 +class DrawEventRecorder : public RefCounted<DrawEventRecorder> 1.1022 +{ 1.1023 +public: 1.1024 + MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(DrawEventRecorder) 1.1025 + virtual ~DrawEventRecorder() { } 1.1026 +}; 1.1027 + 1.1028 +class GFX2D_API Factory 1.1029 +{ 1.1030 +public: 1.1031 + static bool HasSSE2(); 1.1032 + 1.1033 + /* Make sure that the given dimensions don't overflow a 32-bit signed int 1.1034 + * using 4 bytes per pixel; optionally, make sure that either dimension 1.1035 + * doesn't exceed the given limit. 1.1036 + */ 1.1037 + static bool CheckSurfaceSize(const IntSize &sz, int32_t limit = 0); 1.1038 + 1.1039 + static TemporaryRef<DrawTarget> CreateDrawTargetForCairoSurface(cairo_surface_t* aSurface, const IntSize& aSize, SurfaceFormat* aFormat = nullptr); 1.1040 + 1.1041 + static TemporaryRef<DrawTarget> 1.1042 + CreateDrawTarget(BackendType aBackend, const IntSize &aSize, SurfaceFormat aFormat); 1.1043 + 1.1044 + static TemporaryRef<DrawTarget> 1.1045 + CreateRecordingDrawTarget(DrawEventRecorder *aRecorder, DrawTarget *aDT); 1.1046 + 1.1047 + static TemporaryRef<DrawTarget> 1.1048 + CreateDrawTargetForData(BackendType aBackend, unsigned char* aData, const IntSize &aSize, int32_t aStride, SurfaceFormat aFormat); 1.1049 + 1.1050 + static TemporaryRef<ScaledFont> 1.1051 + CreateScaledFontForNativeFont(const NativeFont &aNativeFont, Float aSize); 1.1052 + 1.1053 + /** 1.1054 + * This creates a ScaledFont from TrueType data. 1.1055 + * 1.1056 + * aData - Pointer to the data 1.1057 + * aSize - Size of the TrueType data 1.1058 + * aFaceIndex - Index of the font face in the truetype data this ScaledFont needs to represent. 1.1059 + * aGlyphSize - Size of the glyphs in this ScaledFont 1.1060 + * aType - Type of ScaledFont that should be created. 1.1061 + */ 1.1062 + static TemporaryRef<ScaledFont> 1.1063 + CreateScaledFontForTrueTypeData(uint8_t *aData, uint32_t aSize, uint32_t aFaceIndex, Float aGlyphSize, FontType aType); 1.1064 + 1.1065 + /* 1.1066 + * This creates a scaled font with an associated cairo_scaled_font_t, and 1.1067 + * must be used when using the Cairo backend. The NativeFont and 1.1068 + * cairo_scaled_font_t* parameters must correspond to the same font. 1.1069 + */ 1.1070 + static TemporaryRef<ScaledFont> 1.1071 + CreateScaledFontWithCairo(const NativeFont &aNativeFont, Float aSize, cairo_scaled_font_t* aScaledFont); 1.1072 + 1.1073 + /* 1.1074 + * This creates a simple data source surface for a certain size. It allocates 1.1075 + * new memory for the surface. This memory is freed when the surface is 1.1076 + * destroyed. 1.1077 + */ 1.1078 + static TemporaryRef<DataSourceSurface> 1.1079 + CreateDataSourceSurface(const IntSize &aSize, SurfaceFormat aFormat); 1.1080 + 1.1081 + /* 1.1082 + * This creates a simple data source surface for a certain size with a 1.1083 + * specific stride, which must be large enough to fit all pixels. 1.1084 + * It allocates new memory for the surface. This memory is freed when 1.1085 + * the surface is destroyed. 1.1086 + */ 1.1087 + static TemporaryRef<DataSourceSurface> 1.1088 + CreateDataSourceSurfaceWithStride(const IntSize &aSize, SurfaceFormat aFormat, int32_t aStride); 1.1089 + 1.1090 + /* 1.1091 + * This creates a simple data source surface for some existing data. It will 1.1092 + * wrap this data and the data for this source surface. The caller is 1.1093 + * responsible for deallocating the memory only after destruction of the 1.1094 + * surface. 1.1095 + */ 1.1096 + static TemporaryRef<DataSourceSurface> 1.1097 + CreateWrappingDataSourceSurface(uint8_t *aData, int32_t aStride, 1.1098 + const IntSize &aSize, SurfaceFormat aFormat); 1.1099 + 1.1100 + static TemporaryRef<DrawEventRecorder> 1.1101 + CreateEventRecorderForFile(const char *aFilename); 1.1102 + 1.1103 + static void SetGlobalEventRecorder(DrawEventRecorder *aRecorder); 1.1104 + 1.1105 +#ifdef USE_SKIA_GPU 1.1106 + static TemporaryRef<DrawTarget> 1.1107 + CreateDrawTargetSkiaWithGrContext(GrContext* aGrContext, 1.1108 + const IntSize &aSize, 1.1109 + SurfaceFormat aFormat); 1.1110 +#endif 1.1111 + 1.1112 + static void PurgeAllCaches(); 1.1113 + 1.1114 +#if defined(USE_SKIA) && defined(MOZ_ENABLE_FREETYPE) 1.1115 + static TemporaryRef<GlyphRenderingOptions> 1.1116 + CreateCairoGlyphRenderingOptions(FontHinting aHinting, bool aAutoHinting); 1.1117 +#endif 1.1118 + static TemporaryRef<DrawTarget> 1.1119 + CreateDualDrawTarget(DrawTarget *targetA, DrawTarget *targetB); 1.1120 + 1.1121 +#ifdef XP_MACOSX 1.1122 + static TemporaryRef<DrawTarget> CreateDrawTargetForCairoCGContext(CGContextRef cg, const IntSize& aSize); 1.1123 +#endif 1.1124 + 1.1125 +#ifdef WIN32 1.1126 + static TemporaryRef<DrawTarget> CreateDrawTargetForD3D10Texture(ID3D10Texture2D *aTexture, SurfaceFormat aFormat); 1.1127 + static TemporaryRef<DrawTarget> 1.1128 + CreateDualDrawTargetForD3D10Textures(ID3D10Texture2D *aTextureA, 1.1129 + ID3D10Texture2D *aTextureB, 1.1130 + SurfaceFormat aFormat); 1.1131 + 1.1132 + static void SetDirect3D10Device(ID3D10Device1 *aDevice); 1.1133 + static ID3D10Device1 *GetDirect3D10Device(); 1.1134 +#ifdef USE_D2D1_1 1.1135 + static void SetDirect3D11Device(ID3D11Device *aDevice); 1.1136 + static ID3D11Device *GetDirect3D11Device(); 1.1137 + static ID2D1Device *GetD2D1Device(); 1.1138 +#endif 1.1139 + 1.1140 + static TemporaryRef<GlyphRenderingOptions> 1.1141 + CreateDWriteGlyphRenderingOptions(IDWriteRenderingParams *aParams); 1.1142 + 1.1143 + static uint64_t GetD2DVRAMUsageDrawTarget(); 1.1144 + static uint64_t GetD2DVRAMUsageSourceSurface(); 1.1145 + static void D2DCleanup(); 1.1146 + 1.1147 +private: 1.1148 + static ID3D10Device1 *mD3D10Device; 1.1149 +#ifdef USE_D2D1_1 1.1150 + static ID3D11Device *mD3D11Device; 1.1151 + static ID2D1Device *mD2D1Device; 1.1152 +#endif 1.1153 +#endif 1.1154 + 1.1155 + static DrawEventRecorder *mRecorder; 1.1156 +}; 1.1157 + 1.1158 +} 1.1159 +} 1.1160 + 1.1161 +#endif // _MOZILLA_GFX_2D_H