Bug 1528881 - Part 2: gfx: Remove some unused functions. r=jrmuizel
authorChris Peterson <cpeterson@mozilla.com>
Thu, 14 Feb 2019 15:58:22 -0800
changeset 461611 d87672a996677236c209cc6a067a84b9fb92e0e5
parent 461610 0573c6c669be0434b630bb90051298aaa5159ccc
child 461612 43d876b370317974ccc221278551be1b509d1647
push id35626
push usercsabou@mozilla.com
push dateThu, 28 Feb 2019 11:31:08 +0000
treeherdermozilla-central@2ea0c1db7e60 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs1528881
milestone67.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 1528881 - Part 2: gfx: Remove some unused functions. r=jrmuizel clang's -Wmissing-prototypes option identifies global functions that can be made static (because they're only called from one compilation unit) or removed (if they're never called). CreateDefaultTarget() NS_HSL2RGB() widget/headless/HeadlessWidget.cpp:49:30 [-Wmissing-prototypes] no previous prototype for function 'CreateDefaultTarget' Differential Revision: https://phabricator.services.mozilla.com/D20261
gfx/src/nsColor.cpp
gfx/src/nsColor.h
widget/headless/HeadlessWidget.cpp
--- a/gfx/src/nsColor.cpp
+++ b/gfx/src/nsColor.cpp
@@ -233,48 +233,16 @@ nscolor NS_ComposeColors(nscolor aBG, ns
   }
   MOZ_BLEND(r, NS_GET_R(aBG), NS_GET_R(aFG), blendAlpha);
   MOZ_BLEND(g, NS_GET_G(aBG), NS_GET_G(aFG), blendAlpha);
   MOZ_BLEND(b, NS_GET_B(aBG), NS_GET_B(aFG), blendAlpha);
 
   return NS_RGBA(r, g, b, a);
 }
 
-// Functions to convert from HSL color space to RGB color space.
-// This is the algorithm described in the CSS3 specification
-
-// helper
-static float HSL_HueToRGB(float m1, float m2, float h) {
-  if (h < 0.0f) h += 1.0f;
-  if (h > 1.0f) h -= 1.0f;
-  if (h < (float)(1.0 / 6.0)) return m1 + (m2 - m1) * h * 6.0f;
-  if (h < (float)(1.0 / 2.0)) return m2;
-  if (h < (float)(2.0 / 3.0))
-    return m1 + (m2 - m1) * ((float)(2.0 / 3.0) - h) * 6.0f;
-  return m1;
-}
-
-// The float parameters are all expected to be in the range 0-1
-nscolor NS_HSL2RGB(float h, float s, float l) {
-  uint8_t r, g, b;
-  float m1, m2;
-  if (l <= 0.5f) {
-    m2 = l * (s + 1);
-  } else {
-    m2 = l + s - l * s;
-  }
-  m1 = l * 2 - m2;
-  // We round, not floor, because that's how we handle
-  // percentage RGB values.
-  r = ClampColor(255 * HSL_HueToRGB(m1, m2, h + 1.0f / 3.0f));
-  g = ClampColor(255 * HSL_HueToRGB(m1, m2, h));
-  b = ClampColor(255 * HSL_HueToRGB(m1, m2, h - 1.0f / 3.0f));
-  return NS_RGB(r, g, b);
-}
-
 const char* NS_RGBToColorName(nscolor aColor) {
   for (size_t idx = 0; idx < ArrayLength(kColors); ++idx) {
     if (kColors[idx] == aColor) {
       return kColorNames[idx];
     }
   }
 
   return nullptr;
--- a/gfx/src/nsColor.h
+++ b/gfx/src/nsColor.h
@@ -93,20 +93,16 @@ bool NS_LooseHexToRGB(const nsString& aB
 
 // There is no function to translate a color to a hex string, because
 // the hex-string syntax does not support transparency.
 
 // Translate a color name to a color. Return true if it parses ok,
 // otherwise return false.
 bool NS_ColorNameToRGB(const nsAString& aBuf, nscolor* aResult);
 
-// function to convert from HSL color space to RGB color space
-// the float parameters are all expected to be in the range 0-1
-nscolor NS_HSL2RGB(float h, float s, float l);
-
 // Return a color name for the given nscolor.  If there is no color
 // name for it, returns null.  If there are multiple possible color
 // names for the given color, the first one in nsColorNameList.h
 // (which is generally the first one in alphabetical order) will be
 // returned.
 const char* NS_RGBToColorName(nscolor aColor);
 
 #endif /* nsColor_h___ */
--- a/widget/headless/HeadlessWidget.cpp
+++ b/widget/headless/HeadlessWidget.cpp
@@ -41,27 +41,16 @@ static mozilla::LazyLogModule sWidgetFoc
 /*static*/ already_AddRefed<nsIWidget> nsIWidget::CreateHeadlessWidget() {
   nsCOMPtr<nsIWidget> widget = new mozilla::widget::HeadlessWidget();
   return widget.forget();
 }
 
 namespace mozilla {
 namespace widget {
 
-already_AddRefed<gfxContext> CreateDefaultTarget(IntSize aSize) {
-  // Always use at least a 1x1 draw target to avoid gfx issues
-  // with 0x0 targets.
-  IntSize size =
-      (aSize.width <= 0 || aSize.height <= 0) ? gfx::IntSize(1, 1) : aSize;
-  RefPtr<DrawTarget> target = Factory::CreateDrawTarget(
-      gfxVars::ContentBackend(), size, SurfaceFormat::B8G8R8A8);
-  RefPtr<gfxContext> ctx = gfxContext::CreatePreservingTransformOrNull(target);
-  return ctx.forget();
-}
-
 StaticAutoPtr<nsTArray<HeadlessWidget*>> HeadlessWidget::sActiveWindows;
 
 already_AddRefed<HeadlessWidget> HeadlessWidget::GetActiveWindow() {
   if (!sActiveWindows) {
     return nullptr;
   }
   auto length = sActiveWindows->Length();
   if (length == 0) {