Remove mutex guards from GrContext::readSurfacePixels
authorRobert Phillips <robertphillips@google.com>
Tue, 13 Dec 2016 17:42:19 +0000 (12:42 -0500)
committerSkia Commit-Bot <skia-commit-bot@chromium.org>
Wed, 14 Dec 2016 13:04:01 +0000 (13:04 +0000)
Change-Id: Ief4f0faae7abeb996bdfc993e368e64755da15a7
Reviewed-on: https://skia-review.googlesource.com/5929
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>

include/gpu/GrContext.h
src/gpu/GrContext.cpp

index 9ccda23..de80b68 100644 (file)
@@ -19,7 +19,6 @@
 #include "SkTypes.h"
 #include "../private/GrAuditTrail.h"
 #include "../private/GrSingleOwner.h"
-#include "../private/SkMutex.h"
 
 struct GrBatchAtlasConfig;
 class GrBatchFontCache;
@@ -415,18 +414,6 @@ private:
     bool                                    fDidTestPMConversions;
     int                                     fPMToUPMConversion;
     int                                     fUPMToPMConversion;
-    // The sw backend may call GrContext::readSurfacePixels on multiple threads
-    // We may transfer the responsibilty for using a mutex to the sw backend
-    // when there are fewer code paths that lead to a readSurfacePixels call
-    // from the sw backend. readSurfacePixels is reentrant in one case - when performing
-    // the PM conversions test. To handle this we do the PM conversions test outside
-    // of fReadPixelsMutex and use a separate mutex to guard it. When it re-enters
-    // readSurfacePixels it will grab fReadPixelsMutex and release it before the outer
-    // readSurfacePixels proceeds to grab it.
-    // TODO: Stop pretending to make GrContext thread-safe for sw rasterization and provide
-    // a mechanism to make a SkPicture safe for multithreaded sw rasterization.
-    SkMutex                                 fReadPixelsMutex;
-    SkMutex                                 fTestPMConversionsMutex;
 
     // In debug builds we guard against improper thread handling
     // This guard is passed to the GrDrawingManager and, from there to all the
@@ -465,8 +452,7 @@ private:
     sk_sp<GrFragmentProcessor> createUPMToPMEffect(GrTexture*, const GrSwizzle&,
                                                    const SkMatrix&) const;
     /** Called before either of the above two functions to determine the appropriate fragment
-        processors for conversions. This must be called by readSurfacePixels before a mutex is
-        taken, since testingvPM conversions itself will call readSurfacePixels */
+        processors for conversions. */
     void testPMConversionsIfNecessary(uint32_t flags);
     /** Returns true if we've already determined that createPMtoUPMEffect and createUPMToPMEffect
         will fail. In such cases fall back to SW conversion. */
index ff5b026..7dd01de 100644 (file)
@@ -401,7 +401,6 @@ bool GrContext::readSurfacePixels(GrSurface* src,
     GR_AUDIT_TRAIL_AUTO_FRAME(&fAuditTrail, "GrContext::readSurfacePixels");
 
     this->testPMConversionsIfNecessary(flags);
-    SkAutoMutexAcquire ama(fReadPixelsMutex);
 
     // Adjust the params so that if we wind up using an intermediate surface we've already done
     // all the trimming and the temporary can be the min size required.
@@ -853,7 +852,6 @@ void test_pm_conversions(GrContext* ctx, int* pmToUPMValue, int* upmToPMValue) {
 void GrContext::testPMConversionsIfNecessary(uint32_t flags) {
     ASSERT_SINGLE_OWNER
     if (SkToBool(kUnpremul_PixelOpsFlag & flags)) {
-        SkAutoMutexAcquire ama(fTestPMConversionsMutex);
         if (!fDidTestPMConversions) {
             test_pm_conversions(this, &fPMToUPMConversion, &fUPMToPMConversion);
             fDidTestPMConversions = true;