Bug 1336986 - Return false in ContainsOnlyColoredGlyphs if no glyphs are drawing. r=jrmuizel draft
authorMorris Tseng <mtseng@mozilla.com>
Wed, 17 May 2017 16:43:22 +0800
changeset 579379 b3786cb67b7c51fd50ecc101d1a17a6432bf7c5c
parent 579378 f13047e755154657979ec951ef995b5687b23a74
child 628984 a30b8ec10610d96d8b3137f94b28c74e849c2429
push id59227
push userbmo:mtseng@mozilla.com
push dateWed, 17 May 2017 08:50:28 +0000
reviewersjrmuizel
bugs1336986
milestone55.0a1
Bug 1336986 - Return false in ContainsOnlyColoredGlyphs if no glyphs are drawing. r=jrmuizel If font is downloading, we don't draw any glyphs in drawtarget which means mDrawCommandsStorage doesn't contain any FILLGLYPHS command. Return false in this situation so that we can handle it correctly in the caller. MozReview-Commit-ID: CtxvCeYh0ii
gfx/2d/DrawTargetCapture.cpp
--- a/gfx/2d/DrawTargetCapture.cpp
+++ b/gfx/2d/DrawTargetCapture.cpp
@@ -199,16 +199,17 @@ DrawTargetCaptureImpl::ReplayToDrawTarge
 
 bool
 DrawTargetCaptureImpl::ContainsOnlyColoredGlyphs(RefPtr<ScaledFont>& aScaledFont,
                                                  Color& aColor,
                                                  std::vector<Glyph>& aGlyphs)
 {
   uint8_t* start = &mDrawCommandStorage.front();
   uint8_t* current = start;
+  bool result = false;
 
   while (current < start + mDrawCommandStorage.size()) {
     DrawingCommand* command =
       reinterpret_cast<DrawingCommand*>(current + sizeof(uint32_t));
     current += *(uint32_t*)current;
 
     if (command->GetType() != CommandType::FILLGLYPHS &&
         command->GetType() != CommandType::SETTRANSFORM) {
@@ -246,14 +247,15 @@ DrawTargetCaptureImpl::ContainsOnlyColor
       return false;
     }
 
     //TODO: Deal with AA on the DrawOptions, and the GlyphRenderingOptions
 
     aGlyphs.insert(aGlyphs.end(),
                    fillGlyphs->mGlyphs.begin(),
                    fillGlyphs->mGlyphs.end());
+    result = true;
   }
-  return true;
+  return result;
 }
 
 } // namespace gfx
 } // namespace mozilla