Bug 1076910 - Don't use gfxPlatform::GetPlatform() off the main thread. r=Bas
authorJonathan Watt <jwatt@jwatt.org>
Fri, 31 Oct 2014 11:16:38 +0000
changeset 213389 920fc43b861f5335d32e830b96e4db793399bd56
parent 213388 e5eef92b2548f18c8ee50711f5ba98e79f27005c
child 213390 0e1a08d24467827e2082ed9fa4b927b3044e7bac
push id27748
push userryanvm@gmail.com
push dateFri, 31 Oct 2014 20:14:33 +0000
treeherdermozilla-central@12ac66e2c016 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersBas
bugs1076910
milestone36.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 1076910 - Don't use gfxPlatform::GetPlatform() off the main thread. r=Bas
widget/windows/WinUtils.cpp
--- a/widget/windows/WinUtils.cpp
+++ b/widget/windows/WinUtils.cpp
@@ -1210,21 +1210,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);