Bug 1381172 - Implement DrawTargetCapture::StrokeGlyphs. r=dvander
authorMason Chang <mchang@mozilla.com>
Fri, 14 Jul 2017 17:48:00 -0700
changeset 418695 6b6fb9ee1cfb4c5aa7059879db194fbf49051758
parent 418694 cfccd9657b3d154eca17abeafe440eb2c47f3a09
child 418696 7dadc8f00628dfdc63b0e9d830e609b1f6b98147
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdvander
bugs1381172
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1381172 - Implement DrawTargetCapture::StrokeGlyphs. r=dvander
gfx/2d/DrawCommand.h
gfx/2d/DrawTargetCapture.cpp
gfx/2d/DrawTargetCapture.h
--- a/gfx/2d/DrawCommand.h
+++ b/gfx/2d/DrawCommand.h
@@ -23,16 +23,17 @@ enum class CommandType : int8_t {
   COPYSURFACE,
   COPYRECT,
   FILLRECT,
   STROKERECT,
   STROKELINE,
   STROKE,
   FILL,
   FILLGLYPHS,
+  STROKEGLYPHS,
   MASK,
   MASKSURFACE,
   PUSHCLIP,
   PUSHCLIPRECT,
   PUSHLAYER,
   POPCLIP,
   POPLAYER,
   SETTRANSFORM,
@@ -462,16 +463,61 @@ public:
 private:
   RefPtr<ScaledFont> mFont;
   std::vector<Glyph> mGlyphs;
   StoredPattern mPattern;
   DrawOptions mOptions;
   RefPtr<GlyphRenderingOptions> mRenderingOptions;
 };
 
+class StrokeGlyphsCommand : public DrawingCommand
+{
+  friend class DrawTargetCaptureImpl;
+public:
+  StrokeGlyphsCommand(ScaledFont* aFont,
+                      const GlyphBuffer& aBuffer,
+                      const Pattern& aPattern,
+                      const StrokeOptions& aStrokeOptions,
+                      const DrawOptions& aOptions,
+                      const GlyphRenderingOptions* aRenderingOptions)
+    : DrawingCommand(CommandType::STROKEGLYPHS)
+    , mFont(aFont)
+    , mPattern(aPattern)
+    , mStrokeOptions(aStrokeOptions)
+    , mOptions(aOptions)
+    , mRenderingOptions(const_cast<GlyphRenderingOptions*>(aRenderingOptions))
+  {
+    mGlyphs.resize(aBuffer.mNumGlyphs);
+    memcpy(&mGlyphs.front(), aBuffer.mGlyphs, sizeof(Glyph) * aBuffer.mNumGlyphs);
+
+    if (aStrokeOptions.mDashLength) {
+      mDashes.resize(aStrokeOptions.mDashLength);
+      mStrokeOptions.mDashPattern = &mDashes.front();
+      PodCopy(&mDashes.front(), aStrokeOptions.mDashPattern, mStrokeOptions.mDashLength);
+    }
+  }
+
+  virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix*) const
+  {
+    GlyphBuffer buf;
+    buf.mNumGlyphs = mGlyphs.size();
+    buf.mGlyphs = &mGlyphs.front();
+    aDT->StrokeGlyphs(mFont, buf, mPattern, mStrokeOptions, mOptions, mRenderingOptions);
+  }
+
+private:
+  RefPtr<ScaledFont> mFont;
+  std::vector<Glyph> mGlyphs;
+  StoredPattern mPattern;
+  StrokeOptions mStrokeOptions;
+  DrawOptions mOptions;
+  RefPtr<GlyphRenderingOptions> mRenderingOptions;
+  std::vector<Float> mDashes;
+};
+
 class MaskCommand : public DrawingCommand
 {
 public:
   MaskCommand(const Pattern& aSource,
               const Pattern& aMask,
               const DrawOptions& aOptions)
     : DrawingCommand(CommandType::MASK)
     , mSource(aSource)
--- a/gfx/2d/DrawTargetCapture.cpp
+++ b/gfx/2d/DrawTargetCapture.cpp
@@ -148,16 +148,26 @@ DrawTargetCaptureImpl::FillGlyphs(Scaled
                                   const GlyphBuffer& aBuffer,
                                   const Pattern& aPattern,
                                   const DrawOptions& aOptions,
                                   const GlyphRenderingOptions* aRenderingOptions)
 {
   AppendCommand(FillGlyphsCommand)(aFont, aBuffer, aPattern, aOptions, aRenderingOptions);
 }
 
+void DrawTargetCaptureImpl::StrokeGlyphs(ScaledFont* aFont,
+                                         const GlyphBuffer& aBuffer,
+                                         const Pattern& aPattern,
+                                         const StrokeOptions& aStrokeOptions,
+                                         const DrawOptions& aOptions,
+                                         const GlyphRenderingOptions* aRenderingOptions)
+{
+  AppendCommand(StrokeGlyphsCommand)(aFont, aBuffer, aPattern, aStrokeOptions, aOptions, aRenderingOptions);
+}
+
 void
 DrawTargetCaptureImpl::Mask(const Pattern &aSource,
                             const Pattern &aMask,
                             const DrawOptions &aOptions)
 {
   AppendCommand(MaskCommand)(aSource, aMask, aOptions);
 }
 
--- a/gfx/2d/DrawTargetCapture.h
+++ b/gfx/2d/DrawTargetCapture.h
@@ -75,16 +75,22 @@ public:
   virtual void Fill(const Path *aPath,
                     const Pattern &aPattern,
                     const DrawOptions &aOptions = DrawOptions()) override;
   virtual void FillGlyphs(ScaledFont *aFont,
                           const GlyphBuffer &aBuffer,
                           const Pattern &aPattern,
                           const DrawOptions &aOptions = DrawOptions(),
                           const GlyphRenderingOptions *aRenderingOptions = nullptr) override;
+  virtual void StrokeGlyphs(ScaledFont* aFont,
+                            const GlyphBuffer& aBuffer,
+                            const Pattern& aPattern,
+                            const StrokeOptions& aStrokeOptions = StrokeOptions(),
+                            const DrawOptions& aOptions = DrawOptions(),
+                            const GlyphRenderingOptions* aRenderingOptions = nullptr) override;
   virtual void Mask(const Pattern &aSource,
                     const Pattern &aMask,
                     const DrawOptions &aOptions = DrawOptions()) override;
   virtual void PushClip(const Path *aPath) override;
   virtual void PushClipRect(const Rect &aRect) override;
   virtual void PopClip() override;
   virtual void PushLayer(bool aOpaque,
                          Float aOpacity,