Bug 1399178: Record SetPermitSubpixelAA. r=dvander draft
authorBas Schouten <bschouten@mozilla.com>
Wed, 13 Sep 2017 19:10:29 +0000
changeset 664140 61f1ec6d40790f905e3d20f27faac827849f6c24
parent 664115 bcbb4575e482748f1d264727a71cdd459a9df031
child 731383 27dbea4dcfb9e8f5a17ba69b2afae769d35d1d3b
push id79633
push userbschouten@mozilla.com
push dateWed, 13 Sep 2017 19:10:46 +0000
reviewersdvander
bugs1399178
milestone57.0a1
Bug 1399178: Record SetPermitSubpixelAA. r=dvander MozReview-Commit-ID: HfMK5SOSFtr
gfx/2d/DrawCommand.h
gfx/2d/DrawTargetCapture.cpp
gfx/2d/DrawTargetCapture.h
--- a/gfx/2d/DrawCommand.h
+++ b/gfx/2d/DrawCommand.h
@@ -32,16 +32,17 @@ enum class CommandType : int8_t {
   MASK,
   MASKSURFACE,
   PUSHCLIP,
   PUSHCLIPRECT,
   PUSHLAYER,
   POPCLIP,
   POPLAYER,
   SETTRANSFORM,
+  SETPERMITSUBPIXELAA,
   FLUSH
 };
 
 class DrawingCommand
 {
 public:
   virtual ~DrawingCommand() {}
 
@@ -670,16 +671,35 @@ public:
       aDT->SetTransform(mTransform);
     }
   }
 
 private:
   Matrix mTransform;
 };
 
+class SetPermitSubpixelAACommand : public DrawingCommand
+{
+  friend class DrawTargetCaptureImpl;
+public:
+  explicit SetPermitSubpixelAACommand(bool aPermitSubpixelAA)
+    : DrawingCommand(CommandType::SETPERMITSUBPIXELAA)
+    , mPermitSubpixelAA(aPermitSubpixelAA)
+  {
+  }
+
+  virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix* aMatrix) const
+  {
+    aDT->SetPermitSubpixelAA(mPermitSubpixelAA);
+  }
+
+private:
+  bool mPermitSubpixelAA;
+};
+
 class FlushCommand : public DrawingCommand
 {
 public:
   explicit FlushCommand()
     : DrawingCommand(CommandType::FLUSH)
   {
   }
 
--- a/gfx/2d/DrawTargetCapture.cpp
+++ b/gfx/2d/DrawTargetCapture.cpp
@@ -73,16 +73,27 @@ DrawTargetCaptureImpl::Snapshot()
 
 void
 DrawTargetCaptureImpl::DetachAllSnapshots()
 {}
 
 #define AppendCommand(arg) new (AppendToCommandList<arg>()) arg
 
 void
+DrawTargetCaptureImpl::SetPermitSubpixelAA(bool aPermitSubpixelAA)
+{
+  AppendCommand(SetPermitSubpixelAACommand)(aPermitSubpixelAA);
+
+  // Have to update the transform for this DT
+  // because some code paths query the current transform
+  // to render specific things.
+  DrawTarget::SetPermitSubpixelAA(aPermitSubpixelAA);
+}
+
+void
 DrawTargetCaptureImpl::DrawSurface(SourceSurface *aSurface,
                                    const Rect &aDest,
                                    const Rect &aSource,
                                    const DrawSurfaceOptions &aSurfOptions,
                                    const DrawOptions &aOptions)
 {
   aSurface->GuaranteePersistance();
   AppendCommand(DrawSurfaceCommand)(aSurface, aDest, aSource, aSurfOptions, aOptions);
--- a/gfx/2d/DrawTargetCapture.h
+++ b/gfx/2d/DrawTargetCapture.h
@@ -22,16 +22,17 @@ public:
   DrawTargetCaptureImpl(BackendType aBackend, const IntSize& aSize, SurfaceFormat aFormat);
 
   bool Init(const IntSize& aSize, DrawTarget* aRefDT);
 
   virtual BackendType GetBackendType() const override { return mRefDT->GetBackendType(); }
   virtual DrawTargetType GetType() const override { return mRefDT->GetType(); }
   virtual bool IsCaptureDT() const override { return true; }
   virtual already_AddRefed<SourceSurface> Snapshot() override;
+  virtual void SetPermitSubpixelAA(bool aPermitSubpixelAA) override;
   virtual void DetachAllSnapshots() override;
   virtual IntSize GetSize() override { return mSize; }
   virtual void Flush() override {}
   virtual void DrawSurface(SourceSurface *aSurface,
                            const Rect &aDest,
                            const Rect &aSource,
                            const DrawSurfaceOptions &aSurfOptions,
                            const DrawOptions &aOptions) override;