Skip to content

Commit

Permalink
remove SkTLS
Browse files Browse the repository at this point in the history
  - used for debug lock tracking in SkFont*
  - used for debug logging in SkPathOps
  - genuine use in GLTestContext_cmd_buf?
    switched that to thread_local
  - keep empty SkTLS_{pthread,win}.cpp until
    references to them can be cleaned up

Bug: skia:10006
Change-Id: I195a94c95d3f1a1918ee8c9bc4a15fa5b4344fbc
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/275282
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
  • Loading branch information
Mike Klein authored and Skia Commit-Bot committed Mar 6, 2020
1 parent 93a2a6b commit 491df6b
Show file tree
Hide file tree
Showing 25 changed files with 4 additions and 571 deletions.
2 changes: 0 additions & 2 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,6 @@ component("skia") {
"src/ports/SkImageGeneratorWIC.cpp",
"src/ports/SkOSFile_win.cpp",
"src/ports/SkOSLibrary_win.cpp",
"src/ports/SkTLS_win.cpp",
]
libs += [
"FontSub.lib",
Expand All @@ -960,7 +959,6 @@ component("skia") {
sources += [
"src/ports/SkOSFile_posix.cpp",
"src/ports/SkOSLibrary_posix.cpp",
"src/ports/SkTLS_pthread.cpp",
]
libs += [ "dl" ]
}
Expand Down
1 change: 0 additions & 1 deletion gn/core.gni
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,6 @@ skia_core_sources = [
"$_src/core/SkThreadID.cpp",
"$_src/core/SkTLazy.h",
"$_src/core/SkTLList.h",
"$_src/core/SkTLS.cpp",
"$_src/core/SkTMultiMap.h",
"$_src/core/SkTraceEvent.h",
"$_src/core/SkTraceEventCommon.h",
Expand Down
4 changes: 0 additions & 4 deletions public.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,6 @@ PORTS_SRCS_UNIX = struct(
"src/ports/SkFontMgr_fontconfig_factory.cpp",
"src/ports/SkFontMgr_fuchsia.cpp",
"src/ports/SkImageGenerator_none.cpp",
"src/ports/SkTLS_none.cpp",
],
)

Expand Down Expand Up @@ -338,7 +337,6 @@ PORTS_SRCS_ANDROID = struct(
"src/ports/SkFontMgr_empty_factory.cpp",
"src/ports/SkFontMgr_fuchsia.cpp",
"src/ports/SkImageGenerator_none.cpp",
"src/ports/SkTLS_none.cpp",
],
)

Expand Down Expand Up @@ -374,7 +372,6 @@ PORTS_SRCS_IOS = struct(
"src/ports/SkFontMgr_empty_factory.cpp",
"src/ports/SkFontMgr_fuchsia.cpp",
"src/ports/SkImageGenerator_none.cpp",
"src/ports/SkTLS_none.cpp",
],
)

Expand Down Expand Up @@ -416,7 +413,6 @@ PORTS_SRCS_WASM = struct(
"src/ports/SkFontMgr_fontconfig_factory.cpp",
"src/ports/SkFontMgr_fuchsia.cpp",
"src/ports/SkImageGenerator_none.cpp",
"src/ports/SkTLS_none.cpp",
],
)

Expand Down
105 changes: 0 additions & 105 deletions src/core/SkTLS.cpp

This file was deleted.

83 changes: 0 additions & 83 deletions src/core/SkTLS.h

This file was deleted.

22 changes: 0 additions & 22 deletions src/pathops/SkPathOpsDebug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -511,28 +511,6 @@ void SkPathOpsDebug::WindingPrintf(int wind) {
#endif // defined SK_DEBUG || !FORCE_RELEASE


#if DEBUG_SHOW_TEST_NAME
void* SkPathOpsDebug::CreateNameStr() { return new char[DEBUG_FILENAME_STRING_LENGTH]; }

void SkPathOpsDebug::DeleteNameStr(void* v) { delete[] reinterpret_cast<char*>(v); }

void SkPathOpsDebug::BumpTestName(char* test) {
char* num = test + strlen(test);
while (num[-1] >= '0' && num[-1] <= '9') {
--num;
}
if (num[0] == '\0') {
return;
}
int dec = atoi(num);
if (dec == 0) {
return;
}
++dec;
SK_SNPRINTF(num, DEBUG_FILENAME_STRING_LENGTH - (num - test), "%d", dec);
}
#endif

static void show_function_header(const char* functionName) {
SkDebugf("\nstatic void %s(skiatest::Reporter* reporter, const char* filename) {\n", functionName);
if (strcmp("skphealth_com76", functionName) == 0) {
Expand Down
14 changes: 0 additions & 14 deletions src/pathops/SkPathOpsDebug.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ DummyClasses(Cubic, Cubic);
#define DEBUG_MARK_DONE 0
#define DEBUG_PATH_CONSTRUCTION 0
#define DEBUG_PERP 0
#define DEBUG_SHOW_TEST_NAME 0
#define DEBUG_SORT 0
#define DEBUG_T_SECT 0
#define DEBUG_T_SECT_DUMP 0
Expand Down Expand Up @@ -128,7 +127,6 @@ DummyClasses(Cubic, Cubic);
#define DEBUG_MARK_DONE 1
#define DEBUG_PATH_CONSTRUCTION 1
#define DEBUG_PERP 1
#define DEBUG_SHOW_TEST_NAME 1
#define DEBUG_SORT 1
#define DEBUG_T_SECT 0 // enabling may trigger validate asserts even though op does not fail
#define DEBUG_T_SECT_DUMP 0 // Use 1 normally. Use 2 to number segments, 3 for script output
Expand Down Expand Up @@ -246,10 +244,6 @@ DummyClasses(Cubic, Cubic);
#define DEBUG_TEST 0
#endif

#if DEBUG_SHOW_TEST_NAME
#include "src/core/SkTLS.h"
#endif

// Tests with extreme numbers may fail, but all other tests should never fail.
#define FAIL_IF(cond) \
do { bool fail = (cond); SkOPASSERT(!fail); if (fail) return false; } while (false)
Expand Down Expand Up @@ -358,14 +352,6 @@ class SkPathOpsDebug {
static bool ValidWind(int winding);
static void WindingPrintf(int winding);

#if DEBUG_SHOW_TEST_NAME
static void* CreateNameStr();
static void DeleteNameStr(void* v);
#define DEBUG_FILENAME_STRING_LENGTH 64
#define DEBUG_FILENAME_STRING (reinterpret_cast<char* >(SkTLS::Get(SkPathOpsDebug::CreateNameStr, \
SkPathOpsDebug::DeleteNameStr)))
static void BumpTestName(char* );
#endif
static void ShowActiveSpans(SkOpContourHead* contourList);
static void ShowOnePath(const SkPath& path, const char* name, bool includeDeclaration);
static void ShowPath(const SkPath& one, const SkPath& two, SkPathOp op, const char* name);
Expand Down
3 changes: 0 additions & 3 deletions src/pathops/SkPathWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,6 @@ class DistanceLessThan {
reassemble contour pieces into new path
*/
void SkPathWriter::assemble() {
#if DEBUG_SHOW_TEST_NAME
SkDebugf("</div>\n");
#endif
if (!this->someAssemblyRequired()) {
return;
}
Expand Down
19 changes: 0 additions & 19 deletions src/ports/SkFontConfigInterface_direct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@
#include <fontconfig/fontconfig.h>
#include <unistd.h>

#ifdef SK_DEBUG
# include "src/core/SkTLS.h"
#endif

namespace {

// Fontconfig is not threadsafe before 2.10.91. Before that, we lock with a global mutex.
Expand All @@ -36,40 +32,25 @@ static SkMutex& f_c_mutex() {
return mutex;
}

#ifdef SK_DEBUG
void* CreateThreadFcLocked() { return new bool(false); }
void DeleteThreadFcLocked(void* v) { delete static_cast<bool*>(v); }
# define THREAD_FC_LOCKED \
static_cast<bool*>(SkTLS::Get(CreateThreadFcLocked, DeleteThreadFcLocked))
#endif

struct FCLocker {
// Assume FcGetVersion() has always been thread safe.

FCLocker() {
if (FcGetVersion() < 21091) {
f_c_mutex().acquire();
} else {
SkDEBUGCODE(bool* threadLocked = THREAD_FC_LOCKED);
SkASSERT(false == *threadLocked);
SkDEBUGCODE(*threadLocked = true);
}
}

~FCLocker() {
AssertHeld();
if (FcGetVersion() < 21091) {
f_c_mutex().release();
} else {
SkDEBUGCODE(*THREAD_FC_LOCKED = false);
}
}

static void AssertHeld() { SkDEBUGCODE(
if (FcGetVersion() < 21091) {
f_c_mutex().assertHeld();
} else {
SkASSERT(true == *THREAD_FC_LOCKED);
}
) }
};
Expand Down
Loading

0 comments on commit 491df6b

Please sign in to comment.