Bug 993323 - Make nsWindowGfx::CreateIcon() use the new gfxUtils helper for format conversion. r=Bas
authorJonathan Watt <jwatt@jwatt.org>
Tue, 08 Apr 2014 16:12:28 +0100
changeset 177587 468b75c559b8c18eaec508a8354d6597767a9acc
parent 177586 ee5d2f8d5c7d4b6c1604afa1125e01070efaab76
child 177588 22a4fae1f56a421cf917d89fd4a67ee041cf63b4
push id26556
push userryanvm@gmail.com
push dateTue, 08 Apr 2014 22:16:57 +0000
treeherdermozilla-central@5811efc11011 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersBas
bugs993323
milestone31.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 993323 - Make nsWindowGfx::CreateIcon() use the new gfxUtils helper for format conversion. r=Bas
widget/windows/nsWindowGfx.cpp
--- a/widget/windows/nsWindowGfx.cpp
+++ b/widget/windows/nsWindowGfx.cpp
@@ -22,16 +22,17 @@
  **************************************************************/
 
 #include "mozilla/plugins/PluginInstanceParent.h"
 using mozilla::plugins::PluginInstanceParent;
 
 #include "nsWindowGfx.h"
 #include <windows.h>
 #include "gfxImageSurface.h"
+#include "gfxUtils.h"
 #include "gfxWindowsSurface.h"
 #include "gfxWindowsPlatform.h"
 #include "mozilla/gfx/2D.h"
 #include "mozilla/gfx/DataSurfaceHelpers.h"
 #include "mozilla/gfx/Tools.h"
 #include "mozilla/RefPtr.h"
 #include "nsGfxCIID.h"
 #include "gfxContext.h"
@@ -668,31 +669,21 @@ nsresult nsWindowGfx::CreateIcon(imgICon
                                        SurfaceFormat::B8G8R8A8);
     dt->DrawSurface(surface,
                     Rect(0, 0, iconSize.width, iconSize.height),
                     Rect(0, 0, surfaceSize.width, surfaceSize.height),
                     DrawSurfaceOptions(),
                     DrawOptions(1.0f, CompositionOp::OP_SOURCE));
   } else if (surface->GetFormat() != SurfaceFormat::B8G8R8A8) {
     // Convert format to SurfaceFormat::B8G8R8A8
-    dataSurface = Factory::CreateDataSourceSurface(iconSize,
-                                                   SurfaceFormat::B8G8R8A8);
+    dataSurface = gfxUtils::
+      CopySurfaceToDataSourceSurfaceWithFormat(surface,
+                                               SurfaceFormat::B8G8R8A8);
     NS_ENSURE_TRUE(dataSurface, NS_ERROR_FAILURE);
-
-    mappedOK = dataSurface->Map(DataSourceSurface::MapType::READ_WRITE, &map);
-    NS_ENSURE_TRUE(mappedOK, NS_ERROR_FAILURE);
-
-    RefPtr<DrawTarget> dt =
-      Factory::CreateDrawTargetForData(BackendType::CAIRO,
-                                       map.mData,
-                                       dataSurface->GetSize(),
-                                       map.mStride,
-                                       SurfaceFormat::B8G8R8A8);
-    dt->CopySurface(surface, IntRect(IntPoint(0, 0), iconSize),
-                    IntPoint(0, 0));
+    mappedOK = dataSurface->Map(DataSourceSurface::MapType::READ, &map);
   } else {
     dataSurface = surface->GetDataSurface();
     NS_ENSURE_TRUE(dataSurface, NS_ERROR_FAILURE);
     mappedOK = dataSurface->Map(DataSourceSurface::MapType::READ, &map);
   }
   NS_ENSURE_TRUE(dataSurface && mappedOK, NS_ERROR_FAILURE);
   MOZ_ASSERT(dataSurface->GetFormat() == SurfaceFormat::B8G8R8A8);