Bug 1362221. InlineTranslator should track DrawTargets. r=lsalzman
authorJeff Muizelaar <jmuizelaar@mozilla.com>
Thu, 04 May 2017 21:33:10 -0400
changeset 357043 dcfc38a97a8f1d4b4caa2968d5cfce4c5ac7b2d4
parent 357042 abfd063b18feaca9f3e5c1587fdbec4b8a6dbc33
child 357044 ec5a1251f38dfe14b902554beb2752d32c6e3636
push id31780
push userkwierso@gmail.com
push dateMon, 08 May 2017 20:34:47 +0000
treeherdermozilla-central@bab7046ee2d8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslsalzman
bugs1362221
milestone55.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 1362221. InlineTranslator should track DrawTargets. r=lsalzman Previously we always used the initial DrawTarget regardless of what was being drawn.
gfx/2d/InlineTranslator.cpp
gfx/2d/InlineTranslator.h
--- a/gfx/2d/InlineTranslator.cpp
+++ b/gfx/2d/InlineTranslator.cpp
@@ -72,16 +72,17 @@ InlineTranslator::TranslateRecording(std
 }
 
 already_AddRefed<DrawTarget>
 InlineTranslator::CreateDrawTarget(ReferencePtr aRefPtr,
                                   const gfx::IntSize &aSize,
                                   gfx::SurfaceFormat aFormat)
 {
   RefPtr<DrawTarget> drawTarget = mBaseDT;
+  AddDrawTarget(aRefPtr, drawTarget);
   return drawTarget.forget();
 }
 
 FontType
 InlineTranslator::GetDesiredFontType()
 {
   switch (mBaseDT->GetBackendType()) {
     case BackendType::DIRECT2D:
--- a/gfx/2d/InlineTranslator.h
+++ b/gfx/2d/InlineTranslator.h
@@ -31,17 +31,19 @@ class InlineTranslator final : public Tr
 {
 public:
   explicit InlineTranslator(DrawTarget* aDT, Matrix aMatrix);
 
   bool TranslateRecording(std::istream& aRecording);
 
   DrawTarget* LookupDrawTarget(ReferencePtr aRefPtr) final
   {
-    return mBaseDT;
+    DrawTarget* result = mDrawTargets.GetWeak(aRefPtr);
+    MOZ_ASSERT(result);
+    return result;
   }
 
   Path* LookupPath(ReferencePtr aRefPtr) final
   {
     Path* result = mPaths.GetWeak(aRefPtr);
     MOZ_ASSERT(result);
     return result;
   }
@@ -83,17 +85,20 @@ public:
 
   NativeFontResource* LookupNativeFontResource(uint64_t aKey) final
   {
     NativeFontResource* result = mNativeFontResources.GetWeak(aKey);
     MOZ_ASSERT(result);
     return result;
   }
 
-  void AddDrawTarget(ReferencePtr aRefPtr, DrawTarget *aDT) final { }
+  void AddDrawTarget(ReferencePtr aRefPtr, DrawTarget *aDT) final
+  {
+    mDrawTargets.Put(aRefPtr, aDT);
+  }
 
   void AddPath(ReferencePtr aRefPtr, Path *aPath) final
   {
     mPaths.Put(aRefPtr, aPath);
   }
 
   void AddSourceSurface(ReferencePtr aRefPtr, SourceSurface *aSurface) final
   {
@@ -121,17 +126,20 @@ public:
   }
 
   void AddNativeFontResource(uint64_t aKey,
                              NativeFontResource *aScaledFontResouce) final
   {
     mNativeFontResources.Put(aKey, aScaledFontResouce);
   }
 
-  void RemoveDrawTarget(ReferencePtr aRefPtr) final { }
+  void RemoveDrawTarget(ReferencePtr aRefPtr) final
+  {
+    mDrawTargets.Remove(aRefPtr);
+  }
 
   void RemovePath(ReferencePtr aRefPtr) final
   {
     mPaths.Remove(aRefPtr);
   }
 
   void RemoveSourceSurface(ReferencePtr aRefPtr) final
   {
@@ -166,16 +174,17 @@ public:
   mozilla::gfx::DrawTarget* GetReferenceDrawTarget() final { return mBaseDT; }
 
   mozilla::gfx::FontType GetDesiredFontType() final;
 
 private:
   RefPtr<DrawTarget> mBaseDT;
   Matrix             mBaseTransform;
 
+  nsRefPtrHashtable<nsPtrHashKey<void>, DrawTarget> mDrawTargets;
   nsRefPtrHashtable<nsPtrHashKey<void>, Path> mPaths;
   nsRefPtrHashtable<nsPtrHashKey<void>, SourceSurface> mSourceSurfaces;
   nsRefPtrHashtable<nsPtrHashKey<void>, FilterNode> mFilterNodes;
   nsRefPtrHashtable<nsPtrHashKey<void>, GradientStops> mGradientStops;
   nsRefPtrHashtable<nsPtrHashKey<void>, ScaledFont> mScaledFonts;
   nsRefPtrHashtable<nsPtrHashKey<void>, UnscaledFont> mUnscaledFonts;
   nsRefPtrHashtable<nsUint64HashKey, NativeFontResource> mNativeFontResources;
 };