Bug 1076910 - Don't use gfxPlatform::GetPlatform() off the main thread. r=Bas, a=sledru
authorJonathan Watt <jwatt@jwatt.org>
Fri, 31 Oct 2014 11:16:38 +0000
changeset 225893 8977f5061773
parent 225892 546105a6d5c0
child 225894 3c329a6fd0cb
push id4059
push userryanvm@gmail.com
push date2014-10-31 21:13 +0000
treeherdermozilla-beta@631a73cdbc91 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersBas, sledru
bugs1076910
milestone34.0
Bug 1076910 - Don't use gfxPlatform::GetPlatform() off the main thread. r=Bas, a=sledru
widget/windows/WinUtils.cpp
--- a/widget/windows/WinUtils.cpp
+++ b/widget/windows/WinUtils.cpp
@@ -1206,21 +1206,22 @@ AsyncEncodeAndWriteIcon::AsyncEncodeAndW
   mHeight(aHeight)
 {
 }
 
 NS_IMETHODIMP AsyncEncodeAndWriteIcon::Run()
 {
   NS_PRECONDITION(!NS_IsMainThread(), "Should not be called on the main thread.");
 
-  RefPtr<DrawTarget> dt =
-    gfxPlatform::GetPlatform()->ScreenReferenceDrawTarget();
-  RefPtr<SourceSurface> surface =
-    dt->CreateSourceSurfaceFromData(mBuffer, IntSize(mWidth, mHeight), mStride,
-                                    SurfaceFormat::B8G8R8A8);
+  // Note that since we're off the main thread we can't use
+  // gfxPlatform::GetPlatform()->ScreenReferenceDrawTarget()
+  RefPtr<DataSourceSurface> surface =
+    Factory::CreateWrappingDataSourceSurface(mBuffer, mStride,
+                                             IntSize(mWidth, mHeight),
+                                             SurfaceFormat::B8G8R8A8);
 
   FILE* file = fopen(NS_ConvertUTF16toUTF8(mIconPath).get(), "wb");
   if (!file) {
     // Maybe the directory doesn't exist; try creating it, then fopen again.
     nsresult rv = NS_ERROR_FAILURE;
     nsCOMPtr<nsIFile> comFile = do_CreateInstance("@mozilla.org/file/local;1");
     if (comFile) {
       //NS_ConvertUTF8toUTF16 utf16path(mIconPath);