aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2016-02-16 19:06:15 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-02-16 19:06:15 -0800
commit048494c1e236c4db9d18952de83d2602c1abc7c3 (patch)
tree69997f908e6a8162e4f2d5ad854f10070bc4b6fd
parentf60a8908d2ee5cc2e699dc42c17a6e431c3a49ac (diff)
clean up more dead code
- SkSHA1 is unused - SkRunnable is obsolete now that we have std::function BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1705583003 Review URL: https://codereview.chromium.org/1705583003
-rw-r--r--bench/ChecksumBench.cpp12
-rw-r--r--gyp/utils.gypi2
-rw-r--r--src/core/SkTaskGroup.cpp11
-rw-r--r--src/core/SkTaskGroup.h5
-rw-r--r--src/utils/SkRunnable.h16
-rw-r--r--src/utils/SkSHA1.cpp268
-rw-r--r--src/utils/SkSHA1.h55
-rw-r--r--tests/OnceTest.cpp1
-rw-r--r--tests/PathOpsSkpClipTest.cpp9
-rw-r--r--tests/PathOpsThreadedCommon.cpp2
-rw-r--r--tests/PathOpsThreadedCommon.h5
-rw-r--r--tests/SHA1Test.cpp53
-rw-r--r--tests/SkpSkGrTest.cpp9
-rw-r--r--tests/skia_test.cpp11
14 files changed, 13 insertions, 446 deletions
diff --git a/bench/ChecksumBench.cpp b/bench/ChecksumBench.cpp
index bac7bddc81..cba9572aa3 100644
--- a/bench/ChecksumBench.cpp
+++ b/bench/ChecksumBench.cpp
@@ -9,12 +9,10 @@
#include "SkChecksum.h"
#include "SkMD5.h"
#include "SkRandom.h"
-#include "SkSHA1.h"
#include "SkTemplates.h"
enum ChecksumType {
kMD5_ChecksumType,
- kSHA1_ChecksumType,
kMurmur3_ChecksumType,
};
@@ -42,7 +40,6 @@ protected:
const char* onGetName() override {
switch (fType) {
case kMD5_ChecksumType: return "compute_md5";
- case kSHA1_ChecksumType: return "compute_sha1";
case kMurmur3_ChecksumType: return "compute_murmur3";
default: SK_ABORT("Invalid Type"); return "";
@@ -59,14 +56,6 @@ protected:
md5.finish(digest);
}
} break;
- case kSHA1_ChecksumType: {
- for (int i = 0; i < loops; i++) {
- SkSHA1 sha1;
- sha1.update(reinterpret_cast<uint8_t*>(fData), sizeof(fData));
- SkSHA1::Digest digest;
- sha1.finish(digest);
- }
- } break;
case kMurmur3_ChecksumType: {
for (int i = 0; i < loops; i++) {
volatile uint32_t result = SkChecksum::Murmur3(fData, sizeof(fData));
@@ -84,5 +73,4 @@ private:
///////////////////////////////////////////////////////////////////////////////
DEF_BENCH( return new ComputeChecksumBench(kMD5_ChecksumType); )
-DEF_BENCH( return new ComputeChecksumBench(kSHA1_ChecksumType); )
DEF_BENCH( return new ComputeChecksumBench(kMurmur3_ChecksumType); )
diff --git a/gyp/utils.gypi b/gyp/utils.gypi
index 9a974ce532..018eb12056 100644
--- a/gyp/utils.gypi
+++ b/gyp/utils.gypi
@@ -74,8 +74,6 @@
'<(skia_src_path)/utils/SkRGBAToYUV.cpp',
'<(skia_src_path)/utils/SkRGBAToYUV.h',
'<(skia_src_path)/utils/SkRTConf.cpp',
- '<(skia_src_path)/utils/SkSHA1.cpp',
- '<(skia_src_path)/utils/SkSHA1.h',
'<(skia_src_path)/utils/SkTextBox.cpp',
'<(skia_src_path)/utils/SkTextureCompressor.cpp',
'<(skia_src_path)/utils/SkTextureCompressor.h',
diff --git a/src/core/SkTaskGroup.cpp b/src/core/SkTaskGroup.cpp
index 1799256d6f..b3c23b649b 100644
--- a/src/core/SkTaskGroup.cpp
+++ b/src/core/SkTaskGroup.cpp
@@ -6,7 +6,6 @@
*/
#include "SkOnce.h"
-#include "SkRunnable.h"
#include "SkSemaphore.h"
#include "SkSpinlock.h"
#include "SkTArray.h"
@@ -40,13 +39,6 @@ namespace {
class ThreadPool : SkNoncopyable {
public:
- static void Add(SkRunnable* task, SkAtomic<int32_t>* pending) {
- if (!gGlobal) { // If we have no threads, run synchronously.
- return task->run();
- }
- gGlobal->add([task]() { task->run(); }, pending);
- }
-
static void Add(std::function<void(void)> fn, SkAtomic<int32_t>* pending) {
if (!gGlobal) {
return fn();
@@ -99,8 +91,6 @@ private:
SkSpinlock* fLock;
};
- static void CallRunnable(void* arg) { static_cast<SkRunnable*>(arg)->run(); }
-
struct Work {
std::function<void(void)> fn; // A function to call
SkAtomic<int32_t>* pending; // then decrement pending afterwards.
@@ -213,7 +203,6 @@ SkTaskGroup::Enabler::~Enabler() { delete ThreadPool::gGlobal; }
SkTaskGroup::SkTaskGroup() : fPending(0) {}
void SkTaskGroup::wait() { ThreadPool::Wait(&fPending); }
-void SkTaskGroup::add(SkRunnable* task) { ThreadPool::Add(task, &fPending); }
void SkTaskGroup::add(std::function<void(void)> fn) { ThreadPool::Add(fn, &fPending); }
void SkTaskGroup::batch(int N, std::function<void(int)> fn) {
ThreadPool::Batch(N, fn, &fPending);
diff --git a/src/core/SkTaskGroup.h b/src/core/SkTaskGroup.h
index e6c36651fd..0d86cdb829 100644
--- a/src/core/SkTaskGroup.h
+++ b/src/core/SkTaskGroup.h
@@ -14,8 +14,6 @@
#include "SkAtomics.h"
#include "SkTemplates.h"
-struct SkRunnable;
-
class SkTaskGroup : SkNoncopyable {
public:
// Create one of these in main() to enable SkTaskGroups globally.
@@ -28,9 +26,6 @@ public:
~SkTaskGroup() { this->wait(); }
// Add a task to this SkTaskGroup. It will likely run on another thread.
- // Neither add() method takes owership of any of its parameters.
- void add(SkRunnable*);
-
void add(std::function<void(void)> fn);
// Add a batch of N tasks, all calling fn with different arguments.
diff --git a/src/utils/SkRunnable.h b/src/utils/SkRunnable.h
deleted file mode 100644
index 7a93b60c89..0000000000
--- a/src/utils/SkRunnable.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * Copyright 2012 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef SkRunnable_DEFINED
-#define SkRunnable_DEFINED
-
-struct SkRunnable {
- virtual ~SkRunnable() {};
- virtual void run() = 0;
-};
-
-#endif
diff --git a/src/utils/SkSHA1.cpp b/src/utils/SkSHA1.cpp
deleted file mode 100644
index 1abac0640e..0000000000
--- a/src/utils/SkSHA1.cpp
+++ /dev/null
@@ -1,268 +0,0 @@
-/*
- * Copyright 2013 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- *
- * The following code is based on the description in RFC 3174.
- * http://www.ietf.org/rfc/rfc3174.txt
- */
-
-#include "SkTypes.h"
-#include "SkSHA1.h"
-#include <string.h>
-
-/** SHA1 basic transformation. Transforms state based on block. */
-static void transform(uint32_t state[5], const uint8_t block[64]);
-
-/** Encodes input into output (5 big endian 32 bit values). */
-static void encode(uint8_t output[20], const uint32_t input[5]);
-
-/** Encodes input into output (big endian 64 bit value). */
-static void encode(uint8_t output[8], const uint64_t input);
-
-SkSHA1::SkSHA1() : byteCount(0) {
- // These are magic numbers from the specification. The first four are the same as MD5.
- this->state[0] = 0x67452301;
- this->state[1] = 0xefcdab89;
- this->state[2] = 0x98badcfe;
- this->state[3] = 0x10325476;
- this->state[4] = 0xc3d2e1f0;
-}
-
-void SkSHA1::update(const uint8_t* input, size_t inputLength) {
- unsigned int bufferIndex = (unsigned int)(this->byteCount & 0x3F);
- unsigned int bufferAvailable = 64 - bufferIndex;
-
- unsigned int inputIndex;
- if (inputLength >= bufferAvailable) {
- if (bufferIndex) {
- memcpy(&this->buffer[bufferIndex], input, bufferAvailable);
- transform(this->state, this->buffer);
- inputIndex = bufferAvailable;
- } else {
- inputIndex = 0;
- }
-
- for (; inputIndex + 63 < inputLength; inputIndex += 64) {
- transform(this->state, &input[inputIndex]);
- }
-
- bufferIndex = 0;
- } else {
- inputIndex = 0;
- }
-
- memcpy(&this->buffer[bufferIndex], &input[inputIndex], inputLength - inputIndex);
-
- this->byteCount += inputLength;
-}
-
-void SkSHA1::finish(Digest& digest) {
- // Get the number of bits before padding.
- uint8_t bits[8];
- encode(bits, this->byteCount << 3);
-
- // Pad out to 56 mod 64.
- unsigned int bufferIndex = (unsigned int)(this->byteCount & 0x3F);
- unsigned int paddingLength = (bufferIndex < 56) ? (56 - bufferIndex) : (120 - bufferIndex);
- static uint8_t PADDING[64] = {
- 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- };
- this->update(PADDING, paddingLength);
-
- // Append length (length before padding, will cause final update).
- this->update(bits, 8);
-
- // Write out digest.
- encode(digest.data, this->state);
-
-#if defined(SK_SHA1_CLEAR_DATA)
- // Clear state.
- memset(this, 0, sizeof(*this));
-#endif
-}
-
-struct F1 { uint32_t operator()(uint32_t B, uint32_t C, uint32_t D) {
- return (B & C) | ((~B) & D);
- //return D ^ (B & (C ^ D));
- //return (B & C) ^ ((~B) & D);
- //return (B & C) + ((~B) & D);
- //return _mm_or_ps(_mm_andnot_ps(B, D), _mm_and_ps(B, C)); //SSE2
- //return vec_sel(D, C, B); //PPC
-}};
-
-struct F2 { uint32_t operator()(uint32_t B, uint32_t C, uint32_t D) {
- return B ^ C ^ D;
-}};
-
-struct F3 { uint32_t operator()(uint32_t B, uint32_t C, uint32_t D) {
- return (B & C) | (B & D) | (C & D);
- //return (B & C) | (D & (B | C));
- //return (B & C) | (D & (B ^ C));
- //return (B & C) + (D & (B ^ C));
- //return (B & C) ^ (B & D) ^ (C & D);
-}};
-
-/** Rotates x left n bits. */
-static inline uint32_t rotate_left(uint32_t x, uint8_t n) {
- return (x << n) | (x >> (32 - n));
-}
-
-template <typename T>
-static inline void operation(T operation,
- uint32_t A, uint32_t& B, uint32_t C, uint32_t D, uint32_t& E,
- uint32_t w, uint32_t k) {
- E += rotate_left(A, 5) + operation(B, C, D) + w + k;
- B = rotate_left(B, 30);
-}
-
-static void transform(uint32_t state[5], const uint8_t block[64]) {
- uint32_t A = state[0], B = state[1], C = state[2], D = state[3], E = state[4];
-
- // Round constants defined in SHA-1.
- static const uint32_t K[] = {
- 0x5A827999, //sqrt(2) * 2^30
- 0x6ED9EBA1, //sqrt(3) * 2^30
- 0x8F1BBCDC, //sqrt(5) * 2^30
- 0xCA62C1D6, //sqrt(10) * 2^30
- };
-
- uint32_t W[80];
-
- // Initialize the array W.
- size_t i = 0;
- for (size_t j = 0; i < 16; ++i, j += 4) {
- W[i] = (((uint32_t)block[j ]) << 24) |
- (((uint32_t)block[j+1]) << 16) |
- (((uint32_t)block[j+2]) << 8) |
- (((uint32_t)block[j+3]) );
- }
- for (; i < 80; ++i) {
- W[i] = rotate_left(W[i-3] ^ W[i-8] ^ W[i-14] ^ W[i-16], 1);
- //The following is equivelent and speeds up SSE implementations, but slows non-SSE.
- //W[i] = rotate_left(W[i-6] ^ W[i-16] ^ W[i-28] ^ W[i-32], 2);
- }
-
- // Round 1
- operation(F1(), A, B, C, D, E, W[ 0], K[0]);
- operation(F1(), E, A, B, C, D, W[ 1], K[0]);
- operation(F1(), D, E, A, B, C, W[ 2], K[0]);
- operation(F1(), C, D, E, A, B, W[ 3], K[0]);
- operation(F1(), B, C, D, E, A, W[ 4], K[0]);
- operation(F1(), A, B, C, D, E, W[ 5], K[0]);
- operation(F1(), E, A, B, C, D, W[ 6], K[0]);
- operation(F1(), D, E, A, B, C, W[ 7], K[0]);
- operation(F1(), C, D, E, A, B, W[ 8], K[0]);
- operation(F1(), B, C, D, E, A, W[ 9], K[0]);
- operation(F1(), A, B, C, D, E, W[10], K[0]);
- operation(F1(), E, A, B, C, D, W[11], K[0]);
- operation(F1(), D, E, A, B, C, W[12], K[0]);
- operation(F1(), C, D, E, A, B, W[13], K[0]);
- operation(F1(), B, C, D, E, A, W[14], K[0]);
- operation(F1(), A, B, C, D, E, W[15], K[0]);
- operation(F1(), E, A, B, C, D, W[16], K[0]);
- operation(F1(), D, E, A, B, C, W[17], K[0]);
- operation(F1(), C, D, E, A, B, W[18], K[0]);
- operation(F1(), B, C, D, E, A, W[19], K[0]);
-
- // Round 2
- operation(F2(), A, B, C, D, E, W[20], K[1]);
- operation(F2(), E, A, B, C, D, W[21], K[1]);
- operation(F2(), D, E, A, B, C, W[22], K[1]);
- operation(F2(), C, D, E, A, B, W[23], K[1]);
- operation(F2(), B, C, D, E, A, W[24], K[1]);
- operation(F2(), A, B, C, D, E, W[25], K[1]);
- operation(F2(), E, A, B, C, D, W[26], K[1]);
- operation(F2(), D, E, A, B, C, W[27], K[1]);
- operation(F2(), C, D, E, A, B, W[28], K[1]);
- operation(F2(), B, C, D, E, A, W[29], K[1]);
- operation(F2(), A, B, C, D, E, W[30], K[1]);
- operation(F2(), E, A, B, C, D, W[31], K[1]);
- operation(F2(), D, E, A, B, C, W[32], K[1]);
- operation(F2(), C, D, E, A, B, W[33], K[1]);
- operation(F2(), B, C, D, E, A, W[34], K[1]);
- operation(F2(), A, B, C, D, E, W[35], K[1]);
- operation(F2(), E, A, B, C, D, W[36], K[1]);
- operation(F2(), D, E, A, B, C, W[37], K[1]);
- operation(F2(), C, D, E, A, B, W[38], K[1]);
- operation(F2(), B, C, D, E, A, W[39], K[1]);
-
- // Round 3
- operation(F3(), A, B, C, D, E, W[40], K[2]);
- operation(F3(), E, A, B, C, D, W[41], K[2]);
- operation(F3(), D, E, A, B, C, W[42], K[2]);
- operation(F3(), C, D, E, A, B, W[43], K[2]);
- operation(F3(), B, C, D, E, A, W[44], K[2]);
- operation(F3(), A, B, C, D, E, W[45], K[2]);
- operation(F3(), E, A, B, C, D, W[46], K[2]);
- operation(F3(), D, E, A, B, C, W[47], K[2]);
- operation(F3(), C, D, E, A, B, W[48], K[2]);
- operation(F3(), B, C, D, E, A, W[49], K[2]);
- operation(F3(), A, B, C, D, E, W[50], K[2]);
- operation(F3(), E, A, B, C, D, W[51], K[2]);
- operation(F3(), D, E, A, B, C, W[52], K[2]);
- operation(F3(), C, D, E, A, B, W[53], K[2]);
- operation(F3(), B, C, D, E, A, W[54], K[2]);
- operation(F3(), A, B, C, D, E, W[55], K[2]);
- operation(F3(), E, A, B, C, D, W[56], K[2]);
- operation(F3(), D, E, A, B, C, W[57], K[2]);
- operation(F3(), C, D, E, A, B, W[58], K[2]);
- operation(F3(), B, C, D, E, A, W[59], K[2]);
-
- // Round 4
- operation(F2(), A, B, C, D, E, W[60], K[3]);
- operation(F2(), E, A, B, C, D, W[61], K[3]);
- operation(F2(), D, E, A, B, C, W[62], K[3]);
- operation(F2(), C, D, E, A, B, W[63], K[3]);
- operation(F2(), B, C, D, E, A, W[64], K[3]);
- operation(F2(), A, B, C, D, E, W[65], K[3]);
- operation(F2(), E, A, B, C, D, W[66], K[3]);
- operation(F2(), D, E, A, B, C, W[67], K[3]);
- operation(F2(), C, D, E, A, B, W[68], K[3]);
- operation(F2(), B, C, D, E, A, W[69], K[3]);
- operation(F2(), A, B, C, D, E, W[70], K[3]);
- operation(F2(), E, A, B, C, D, W[71], K[3]);
- operation(F2(), D, E, A, B, C, W[72], K[3]);
- operation(F2(), C, D, E, A, B, W[73], K[3]);
- operation(F2(), B, C, D, E, A, W[74], K[3]);
- operation(F2(), A, B, C, D, E, W[75], K[3]);
- operation(F2(), E, A, B, C, D, W[76], K[3]);
- operation(F2(), D, E, A, B, C, W[77], K[3]);
- operation(F2(), C, D, E, A, B, W[78], K[3]);
- operation(F2(), B, C, D, E, A, W[79], K[3]);
-
- state[0] += A;
- state[1] += B;
- state[2] += C;
- state[3] += D;
- state[4] += E;
-
-#if defined(SK_SHA1_CLEAR_DATA)
- // Clear sensitive information.
- memset(W, 0, sizeof(W));
-#endif
-}
-
-static void encode(uint8_t output[20], const uint32_t input[5]) {
- for (size_t i = 0, j = 0; i < 5; i++, j += 4) {
- output[j ] = (uint8_t)((input[i] >> 24) & 0xff);
- output[j+1] = (uint8_t)((input[i] >> 16) & 0xff);
- output[j+2] = (uint8_t)((input[i] >> 8) & 0xff);
- output[j+3] = (uint8_t)((input[i] ) & 0xff);
- }
-}
-
-static void encode(uint8_t output[8], const uint64_t input) {
- output[0] = (uint8_t)((input >> 56) & 0xff);
- output[1] = (uint8_t)((input >> 48) & 0xff);
- output[2] = (uint8_t)((input >> 40) & 0xff);
- output[3] = (uint8_t)((input >> 32) & 0xff);
- output[4] = (uint8_t)((input >> 24) & 0xff);
- output[5] = (uint8_t)((input >> 16) & 0xff);
- output[6] = (uint8_t)((input >> 8) & 0xff);
- output[7] = (uint8_t)((input ) & 0xff);
-}
diff --git a/src/utils/SkSHA1.h b/src/utils/SkSHA1.h
deleted file mode 100644
index aa0867fed3..0000000000
--- a/src/utils/SkSHA1.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright 2013 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef SkSHA1_DEFINED
-#define SkSHA1_DEFINED
-
-#include "SkTypes.h"
-#include "SkEndian.h"
-#include "SkStream.h"
-
-//The following macros can be defined to affect the SHA1 code generated.
-//SK_SHA1_CLEAR_DATA causes all intermediate state to be overwritten with 0's.
-//SK_CPU_BENDIAN allows 32 bit <=> 8 bit conversions without copies (if alligned).
-//SK_CPU_FAST_UNALIGNED_ACCESS allows 32 bit <=> 8 bit conversions without copies if SK_CPU_BENDIAN.
-
-class SkSHA1 : public SkWStream {
-public:
- SkSHA1();
-
- /** Processes input, adding it to the digest.
- * Note that this treats the buffer as a series of uint8_t values.
- */
- bool write(const void* buffer, size_t size) override {
- update(reinterpret_cast<const uint8_t*>(buffer), size);
- return true;
- }
-
- size_t bytesWritten() const override { return SkToSizeT(this->byteCount); }
-
- /** Processes input, adding it to the digest. Calling this after finish is undefined. */
- void update(const uint8_t* input, size_t length);
-
- struct Digest {
- uint8_t data[20];
- };
-
- /** Computes and returns the digest. */
- void finish(Digest& digest);
-
-private:
- // number of bytes, modulo 2^64
- uint64_t byteCount;
-
- // state (ABCDE)
- uint32_t state[5];
-
- // input buffer
- uint8_t buffer[64];
-};
-
-#endif
diff --git a/tests/OnceTest.cpp b/tests/OnceTest.cpp
index 3fd569a42a..83ee66b6c8 100644
--- a/tests/OnceTest.cpp
+++ b/tests/OnceTest.cpp
@@ -6,7 +6,6 @@
*/
#include "SkOnce.h"
-#include "SkRunnable.h"
#include "SkTaskGroup.h"
#include "Test.h"
diff --git a/tests/PathOpsSkpClipTest.cpp b/tests/PathOpsSkpClipTest.cpp
index e70e1c0c66..326abb66c7 100644
--- a/tests/PathOpsSkpClipTest.cpp
+++ b/tests/PathOpsSkpClipTest.cpp
@@ -22,7 +22,6 @@
#include "SkPathOpsDebug.h"
#include "SkPicture.h"
#include "SkRTConf.h"
-#include "SkRunnable.h"
#include "SkTSort.h"
#include "SkStream.h"
#include "SkString.h"
@@ -260,9 +259,9 @@ struct TestRunner {
SkTDArray<class TestRunnable*> fRunnables;
};
-class TestRunnable : public SkRunnable {
+class TestRunnable {
public:
- void run() override {
+ void operator()() {
SkGraphics::SetTLSFontCacheLimit(1 * 1024 * 1024);
(*fTestFun)(&fState);
}
@@ -305,10 +304,8 @@ TestRunner::~TestRunner() {
}
void TestRunner::render() {
- // TODO: this doesn't really need to use SkRunnables any more.
- // We can just write the code to run in the for-loop directly.
SkTaskGroup().batch(fRunnables.count(), [&](int i) {
- fRunnables[i]->run();
+ (*fRunnables[i])();
});
}
diff --git a/tests/PathOpsThreadedCommon.cpp b/tests/PathOpsThreadedCommon.cpp
index c9a06f0a52..a1a65b70a9 100644
--- a/tests/PathOpsThreadedCommon.cpp
+++ b/tests/PathOpsThreadedCommon.cpp
@@ -17,6 +17,6 @@ PathOpsThreadedTestRunner::~PathOpsThreadedTestRunner() {
void PathOpsThreadedTestRunner::render() {
SkTaskGroup().batch(fRunnables.count(), [&](int i) {
- fRunnables[i]->run();
+ (*fRunnables[i])();
});
}
diff --git a/tests/PathOpsThreadedCommon.h b/tests/PathOpsThreadedCommon.h
index 5bf5da2682..54586d95cc 100644
--- a/tests/PathOpsThreadedCommon.h
+++ b/tests/PathOpsThreadedCommon.h
@@ -8,7 +8,6 @@
#define PathOpsThreadedCommon_DEFINED
#include "SkGraphics.h"
-#include "SkRunnable.h"
#include "SkTDArray.h"
#define PATH_STR_SIZE 512
@@ -44,7 +43,7 @@ public:
skiatest::Reporter* fReporter;
};
-class PathOpsThreadedRunnable : public SkRunnable {
+class PathOpsThreadedRunnable {
public:
PathOpsThreadedRunnable(void (*testFun)(PathOpsThreadState*), int a, int b, int c, int d,
PathOpsThreadedTestRunner* runner) {
@@ -73,7 +72,7 @@ public:
fTestFun = testFun;
}
- void run() override {
+ void operator()() {
SkBitmap bitmap;
fState.fBitmap = &bitmap;
char pathStr[PATH_STR_SIZE];
diff --git a/tests/SHA1Test.cpp b/tests/SHA1Test.cpp
deleted file mode 100644
index fd5fcb7efa..0000000000
--- a/tests/SHA1Test.cpp
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright 2013 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "SkSHA1.h"
-#include "Test.h"
-
-static bool digests_equal(const SkSHA1::Digest& expectedDigest, const SkSHA1::Digest& computedDigest) {
- for (size_t i = 0; i < SK_ARRAY_COUNT(expectedDigest.data); ++i) {
- if (expectedDigest.data[i] != computedDigest.data[i]) {
- return false;
- }
- }
- return true;
-}
-
-static struct SHA1Test {
- const char* message;
- const unsigned long int repeatCount;
- const SkSHA1::Digest digest;
-} sha1_tests[] = {
- // Reference tests from RFC3174 Section 7.3 ( http://www.ietf.org/rfc/rfc3174.txt )
- { "abc", 1, {{ 0xA9, 0x99, 0x3E, 0x36, 0x47, 0x06, 0x81, 0x6A, 0xBA, 0x3E, 0x25, 0x71, 0x78, 0x50, 0xC2, 0x6C, 0x9C, 0xD0, 0xD8, 0x9D }} },
- { "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", 1, {{ 0x84, 0x98, 0x3E, 0x44, 0x1C, 0x3B, 0xD2, 0x6E, 0xBA, 0xAE, 0x4A, 0xA1, 0xF9, 0x51, 0x29, 0xE5, 0xE5, 0x46, 0x70, 0xF1 }} },
- { "a", 1000000, {{ 0x34, 0xAA, 0x97, 0x3C, 0xD4, 0xC4, 0xDA, 0xA4, 0xF6, 0x1E, 0xEB, 0x2B, 0xDB, 0xAD, 0x27, 0x31, 0x65, 0x34, 0x01, 0x6F }} },
- { "0123456701234567012345670123456701234567012345670123456701234567", 10, {{ 0xDE, 0xA3, 0x56, 0xA2, 0xCD, 0xDD, 0x90, 0xC7, 0xA7, 0xEC, 0xED, 0xC5, 0xEB, 0xB5, 0x63, 0x93, 0x4F, 0x46, 0x04, 0x52 }} },
-
- // Reference tests from running GNU sha1sum on test input
- { "The quick brown fox jumps over the lazy dog", 1, {{ 0x2f, 0xd4, 0xe1, 0xc6, 0x7a, 0x2d, 0x28, 0xfc, 0xed, 0x84, 0x9e, 0xe1, 0xbb, 0x76, 0xe7, 0x39, 0x1b, 0x93, 0xeb, 0x12 }} },
- { "", 1, {{ 0xda, 0x39, 0xa3, 0xee, 0x5e, 0x6b, 0x4b, 0x0d, 0x32, 0x55, 0xbf, 0xef, 0x95, 0x60, 0x18, 0x90, 0xaf, 0xd8, 0x07, 0x09 }} },
-};
-
-static void sha1_test(const SHA1Test& test, skiatest::Reporter* reporter) {
- size_t len = strlen(test.message);
-
- SkSHA1 context;
- for (unsigned long int i = 0; i < test.repeatCount; ++i) {
- context.update(reinterpret_cast<const uint8_t*>(test.message), len);
- }
- SkSHA1::Digest digest;
- context.finish(digest);
-
- REPORTER_ASSERT(reporter, digests_equal(test.digest, digest));
-}
-
-DEF_TEST(SHA1, reporter) {
- for (size_t i = 0; i < SK_ARRAY_COUNT(sha1_tests); ++i) {
- sha1_test(sha1_tests[i], reporter);
- }
-}
diff --git a/tests/SkpSkGrTest.cpp b/tests/SkpSkGrTest.cpp
index 241395a753..8cc7ec4a2d 100644
--- a/tests/SkpSkGrTest.cpp
+++ b/tests/SkpSkGrTest.cpp
@@ -21,7 +21,6 @@
#include "SkOSFile.h"
#include "SkPicture.h"
#include "SkRTConf.h"
-#include "SkRunnable.h"
#include "SkStream.h"
#include "SkString.h"
#include "SkTArray.h"
@@ -142,7 +141,7 @@ struct SkpSkGrThreadedTestRunner {
skiatest::Reporter* fReporter;
};
-class SkpSkGrThreadedRunnable : public SkRunnable {
+class SkpSkGrThreadedRunnable {
public:
SkpSkGrThreadedRunnable(void (*testFun)(SkpSkGrThreadState*), int dirNo, const char* str,
SkpSkGrThreadedTestRunner* runner) {
@@ -153,7 +152,7 @@ public:
fTestFun = testFun;
}
- void run() override {
+ void operator()() {
SkGraphics::SetTLSFontCacheLimit(1 * 1024 * 1024);
(*fTestFun)(&fState);
}
@@ -169,10 +168,8 @@ SkpSkGrThreadedTestRunner::~SkpSkGrThreadedTestRunner() {
}
void SkpSkGrThreadedTestRunner::render() {
- // TODO: we don't really need to be using SkRunnables here anymore.
- // We can just write the code we'd run right in the for loop.
SkTaskGroup().batch(fRunnables.count(), [&](int i) {
- fRunnables[i]->run();
+ fRunnables[i]();
});
}
diff --git a/tests/skia_test.cpp b/tests/skia_test.cpp
index 38237e4c02..65fbc32842 100644
--- a/tests/skia_test.cpp
+++ b/tests/skia_test.cpp
@@ -12,7 +12,6 @@
#include "SkCommonFlags.h"
#include "SkGraphics.h"
#include "SkOSFile.h"
-#include "SkRunnable.h"
#include "SkTArray.h"
#include "SkTaskGroup.h"
#include "SkTemplates.h"
@@ -72,15 +71,14 @@ private:
const int fTotal;
};
-// Deletes self when run.
-class SkTestRunnable : public SkRunnable {
+class SkTestRunnable {
public:
SkTestRunnable(const Test& test,
Status* status,
GrContextFactory* grContextFactory = nullptr)
: fTest(test), fStatus(status), fGrContextFactory(grContextFactory) {}
- virtual void run() {
+ void operator()() {
struct TestReporter : public skiatest::Reporter {
public:
TestReporter() : fError(false), fTestCount(0) {}
@@ -105,7 +103,6 @@ public:
}
fStatus->endTest(fTest.name, !reporter.fError, elapsed,
reporter.fTestCount);
- delete this;
}
private:
@@ -190,7 +187,7 @@ int test_main() {
} else if (test.needsGpu) {
gpuTests.push_back(&test);
} else {
- cpuTests.add(new SkTestRunnable(test, &status));
+ cpuTests.add(SkTestRunnable(test, &status));
}
}
@@ -204,7 +201,7 @@ int test_main() {
// Run GPU tests on this thread.
for (int i = 0; i < gpuTests.count(); i++) {
- (new SkTestRunnable(*gpuTests[i], &status, grContextFactoryPtr))->run();
+ SkTestRunnable(*gpuTests[i], &status, grContextFactoryPtr)();
}
// Block until threaded tests finish.