Skip to content

Commit

Permalink
Start removing SkNoncopyable.
Browse files Browse the repository at this point in the history
Just removing these a little at a time.

Change-Id: Ieaed3dc84ca0f29f4fbda2176d92eb0df858390c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/647038
Auto-Submit: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
  • Loading branch information
jvanverth authored and SkCQ committed Feb 21, 2023
1 parent f47e3c8 commit 4cf8c75
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 10 deletions.
7 changes: 6 additions & 1 deletion fuzz/Fuzz.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,14 @@
#include <signal.h>
#include <limits>

class Fuzz : SkNoncopyable {
class Fuzz {
public:
explicit Fuzz(sk_sp<SkData> bytes) : fBytes(bytes), fNextByte(0) {}
Fuzz() = delete;

// Make noncopyable
Fuzz(Fuzz&) = delete;
Fuzz& operator=(Fuzz&) = delete;

// Returns the total number of "random" bytes available.
size_t size() { return fBytes->size(); }
Expand Down
16 changes: 13 additions & 3 deletions fuzz/FuzzDDLThreading.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include "include/gpu/GrDirectContext.h"
#include "include/private/base/SkDeque.h"
#include "include/private/base/SkMutex.h"
#include "include/private/base/SkNoncopyable.h"
#include "include/private/base/SkTemplates.h"
#include "include/private/base/SkThreadID.h"
#include "src/core/SkTaskGroup.h"
Expand Down Expand Up @@ -46,14 +45,15 @@ class DDLFuzzer;

// This class stores the state of a given promise image owned by the fuzzer. It acts as the
// context for the callback procs of the promise image.
class PromiseImageInfo : public SkNVRefCnt<PromiseImageInfo>, SkNoncopyable {
class PromiseImageInfo : public SkNVRefCnt<PromiseImageInfo> {
public:
enum class State : int {
kInitial,
kTriedToFulfill,
kDone
};

PromiseImageInfo() = default;
~PromiseImageInfo() {
// If we hit this, then the image or the texture will outlive this object which is bad.
SkASSERT_RELEASE(!fImage || fImage->unique());
Expand All @@ -64,12 +64,17 @@ class PromiseImageInfo : public SkNVRefCnt<PromiseImageInfo>, SkNoncopyable {
SkASSERT_RELEASE(!fDrawn || s == State::kDone);
}

// Make noncopyable
PromiseImageInfo(PromiseImageInfo&) = delete;
PromiseImageInfo& operator=(PromiseImageInfo&) = delete;

DDLFuzzer* fFuzzer = nullptr;
sk_sp<SkImage> fImage;
// At the moment, the atomicity of this isn't used because all our promise image callbacks
// happen on the same thread. See the TODO below about them unreffing them off the GPU thread.
std::atomic<State> fState{State::kInitial};
std::atomic<bool> fDrawn{false};

sk_sp<SkPromiseImageTexture> fTexture;
};

Expand All @@ -83,9 +88,14 @@ static constexpr int kIterationCount = 10000;
// and concurrently records DDLs that reference them, playing each DDL back on the GPU thread.
// The backing textures for promise images may be recycled into a pool, or not, for each case
// as determined by the fuzzing data.
class DDLFuzzer : SkNoncopyable {
class DDLFuzzer {
public:
DDLFuzzer(Fuzz*, ContextType);
DDLFuzzer() = delete;
// Make noncopyable
DDLFuzzer(DDLFuzzer&) = delete;
DDLFuzzer& operator=(DDLFuzzer&) = delete;

void run();

sk_sp<SkPromiseImageTexture> fulfillPromiseImage(PromiseImageInfo&);
Expand Down
6 changes: 4 additions & 2 deletions gm/convexpaths.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,17 @@
#include "include/core/SkSize.h"
#include "include/core/SkString.h"
#include "include/core/SkTypes.h"
#include "include/private/base/SkNoncopyable.h"
#include "include/private/base/SkTArray.h"
#include "src/base/SkRandom.h"

namespace {

class SkDoOnce : SkNoncopyable {
class SkDoOnce {
public:
SkDoOnce() { fDidOnce = false; }
// Make noncopyable
SkDoOnce(SkDoOnce&) = delete;
SkDoOnce& operator=(SkDoOnce&) = delete;

bool needToDo() const { return !fDidOnce; }
bool alreadyDone() const { return fDidOnce; }
Expand Down
8 changes: 6 additions & 2 deletions include/private/SkChecksum.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,18 @@
#include "include/core/SkString.h"
#include "include/core/SkTypes.h"
#include "include/private/SkOpts_spi.h"
#include "include/private/base/SkNoncopyable.h"
#include "include/private/base/SkTLogic.h"

#include <string>
#include <string_view>

class SkChecksum : SkNoncopyable {
class SkChecksum {
public:
SkChecksum() = default;
// Make noncopyable
SkChecksum(const SkChecksum&) = delete;
SkChecksum& operator=(const SkChecksum&) = delete;

/**
* uint32_t -> uint32_t hash, useful for when you're about to trucate this hash but you
* suspect its low bits aren't well mixed.
Expand Down
2 changes: 1 addition & 1 deletion include/private/base/SkNoncopyable.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#include "include/private/base/SkAPI.h"

/** \class SkNoncopyable
/** \class SkNoncopyable (DEPRECATED)
SkNoncopyable is the base class for objects that do not want to
be copied. It hides its copy-constructor and its assignment-operator.
Expand Down
7 changes: 6 additions & 1 deletion src/core/SkLRUCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* A generic LRU cache.
*/
template <typename K, typename V, typename HashK = SkGoodHash>
class SkLRUCache : public SkNoncopyable {
class SkLRUCache {
private:
struct Entry {
Entry(const K& key, V&& value)
Expand All @@ -31,6 +31,7 @@ class SkLRUCache : public SkNoncopyable {

public:
explicit SkLRUCache(int maxCount) : fMaxCount(maxCount) {}
SkLRUCache() = delete;

~SkLRUCache() {
Entry* node = fLRU.head();
Expand All @@ -41,6 +42,10 @@ class SkLRUCache : public SkNoncopyable {
}
}

// Make noncopyable
SkLRUCache(const SkLRUCache&) = delete;
SkLRUCache& operator=(const SkLRUCache&) = delete;

V* find(const K& key) {
Entry** value = fMap.find(key);
if (!value) {
Expand Down

0 comments on commit 4cf8c75

Please sign in to comment.