aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Mike Klein <mtklein@chromium.org>2016-10-04 15:45:56 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-10-04 20:13:31 +0000
commit511f2d79bf6ea0ee858a3468d3aa8dcbfca58648 (patch)
tree50d33801abe2245cd147ca4bc477f6f205c0a494
parent1834242ec6e3cd62669227d394bc79e1cd66dcfb (diff)
Make global use-analytic-AA bit threadsafe.
I also had to cut it down to just a global atomic bool... as a field in a global singleton accessed through instance(), it's very hard to make threadsafe. CQ_INCLUDE_TRYBOTS=master.client.skia:Test-Ubuntu-Clang-GCE-CPU-AVX2-x86_64-Release-TSAN-Trybot BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2937 Change-Id: If80be987906dd521fbe644d1d0d577009f06d0e3 Reviewed-on: https://skia-review.googlesource.com/2937 Reviewed-by: Yuqian Li <liyuqian@google.com> Commit-Queue: Yuqian Li <liyuqian@google.com> Commit-Queue: Mike Klein <mtklein@chromium.org>
-rw-r--r--bench/nanobench.cpp2
-rw-r--r--dm/DM.cpp2
-rw-r--r--samplecode/SampleApp.cpp3
-rw-r--r--src/core/SkScan.cpp2
-rw-r--r--src/core/SkScan.h17
-rw-r--r--src/core/SkScan_AAAPath.cpp2
-rw-r--r--src/core/SkScan_AntiPath.cpp2
7 files changed, 9 insertions, 21 deletions
diff --git a/bench/nanobench.cpp b/bench/nanobench.cpp
index 1191423544..8d42b12f5e 100644
--- a/bench/nanobench.cpp
+++ b/bench/nanobench.cpp
@@ -1180,7 +1180,7 @@ int nanobench_main() {
}
if (FLAGS_analyticAA) {
- GlobalAAConfig::getInstance().fUseAnalyticAA = true;
+ gSkUseAnalyticAA = true;
}
int runs = 0;
diff --git a/dm/DM.cpp b/dm/DM.cpp
index c6e2ab98c7..0ce3738e32 100644
--- a/dm/DM.cpp
+++ b/dm/DM.cpp
@@ -1276,7 +1276,7 @@ int dm_main() {
setup_crash_handler();
if (FLAGS_analyticAA) {
- GlobalAAConfig::getInstance().fUseAnalyticAA = true;
+ gSkUseAnalyticAA = true;
}
if (FLAGS_verbose) {
diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp
index 5d73162ae0..52e063d367 100644
--- a/samplecode/SampleApp.cpp
+++ b/samplecode/SampleApp.cpp
@@ -1802,8 +1802,7 @@ bool SampleWindow::onHandleChar(SkUnichar uni) {
}
break;
case 'A':
- GlobalAAConfig::getInstance().fUseAnalyticAA =
- !GlobalAAConfig::getInstance().fUseAnalyticAA;
+ gSkUseAnalyticAA = !gSkUseAnalyticAA.load();
this->inval(nullptr);
break;
case 'B':
diff --git a/src/core/SkScan.cpp b/src/core/SkScan.cpp
index 7fce3f1726..ceb9ff6e7a 100644
--- a/src/core/SkScan.cpp
+++ b/src/core/SkScan.cpp
@@ -10,6 +10,8 @@
#include "SkBlitter.h"
#include "SkRasterClip.h"
+std::atomic<bool> gSkUseAnalyticAA{false};
+
static inline void blitrect(SkBlitter* blitter, const SkIRect& r) {
blitter->blitRect(r.fLeft, r.fTop, r.width(), r.height());
}
diff --git a/src/core/SkScan.h b/src/core/SkScan.h
index 1e3d60a290..7d513693fe 100644
--- a/src/core/SkScan.h
+++ b/src/core/SkScan.h
@@ -11,6 +11,7 @@
#include "SkFixed.h"
#include "SkRect.h"
+#include <atomic>
class SkRasterClip;
class SkRegion;
@@ -22,21 +23,7 @@ class SkPath;
*/
typedef SkIRect SkXRect;
-class GlobalAAConfig {
-private:
- GlobalAAConfig() {}
-
-public:
- bool fUseAnalyticAA = false;
-
- GlobalAAConfig(const GlobalAAConfig&) = delete;
- void operator=(const GlobalAAConfig&) = delete;
-
- static GlobalAAConfig& getInstance() {
- static GlobalAAConfig instance;
- return instance;
- }
-};
+extern std::atomic<bool> gSkUseAnalyticAA;
class AdditiveBlitter;
diff --git a/src/core/SkScan_AAAPath.cpp b/src/core/SkScan_AAAPath.cpp
index e5b8c57d5f..501b2e67d8 100644
--- a/src/core/SkScan_AAAPath.cpp
+++ b/src/core/SkScan_AAAPath.cpp
@@ -1109,7 +1109,7 @@ void SkScan::aaa_fill_path(const SkPath& path, const SkIRect* clipRect, Additive
// If we're convex, then we need both edges, even the right edge is past the clip
const bool canCullToTheRight = !path.isConvex();
- SkASSERT(GlobalAAConfig::getInstance().fUseAnalyticAA);
+ SkASSERT(gSkUseAnalyticAA.load());
int count = builder.build(path, clipRect, 0, canCullToTheRight, true);
SkASSERT(count >= 0);
diff --git a/src/core/SkScan_AntiPath.cpp b/src/core/SkScan_AntiPath.cpp
index a300d74d8f..53dac3f65f 100644
--- a/src/core/SkScan_AntiPath.cpp
+++ b/src/core/SkScan_AntiPath.cpp
@@ -750,7 +750,7 @@ void SkScan::FillPath(const SkPath& path, const SkRasterClip& clip,
void SkScan::AntiFillPath(const SkPath& path, const SkRasterClip& clip,
SkBlitter* blitter) {
- if (GlobalAAConfig::getInstance().fUseAnalyticAA) {
+ if (gSkUseAnalyticAA.load()) {
SkScan::AAAFillPath(path, clip, blitter);
return;
}