Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Unified Diff: include/gpu/GrContext.h

Issue 1329313002: Add a mutex to GrContext::readSurfacePixels to protect against multiple CPU raster threads accessin… (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: minor Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/gpu/GrContext.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/gpu/GrContext.h
diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h
index 7f1e4109fad9564e65fa6acbc25266d295878a3b..64f4f6ce30e6609b0d8ca3b1dd99cdde35739a86 100644
--- a/include/gpu/GrContext.h
+++ b/include/gpu/GrContext.h
@@ -15,6 +15,7 @@
#include "GrRenderTarget.h"
#include "GrTextureProvider.h"
#include "SkMatrix.h"
+#include "SkMutex.h"
#include "SkPathEffect.h"
#include "SkTypes.h"
@@ -380,6 +381,18 @@ 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;
struct CleanUpData {
PFCleanUpFunc fFunc;
@@ -446,9 +459,13 @@ private:
* return NULL.
*/
const GrFragmentProcessor* createPMToUPMEffect(GrProcessorDataManager*, GrTexture*,
- bool swapRAndB, const SkMatrix&);
+ bool swapRAndB, const SkMatrix&) const;
const GrFragmentProcessor* createUPMToPMEffect(GrProcessorDataManager*, GrTexture*,
- bool swapRAndB, const SkMatrix&);
+ bool swapRAndB, 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 befor a mutex is taken,
+ since testingvPM conversions itself will call readSurfacePixels */
+ 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. */
bool didFailPMUPMConversionTest() const;
« no previous file with comments | « no previous file | src/gpu/GrContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698