summaryrefslogtreecommitdiff
path: root/chromium/third_party/skia/include/private
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/skia/include/private')
-rw-r--r--chromium/third_party/skia/include/private/GrContext_Base.h21
-rw-r--r--chromium/third_party/skia/include/private/GrImageContext.h7
-rw-r--r--chromium/third_party/skia/include/private/GrRecordingContext.h4
-rw-r--r--chromium/third_party/skia/include/private/GrResourceKey.h10
-rw-r--r--chromium/third_party/skia/include/private/GrSharedEnums.h6
-rw-r--r--chromium/third_party/skia/include/private/GrSingleOwner.h22
-rw-r--r--chromium/third_party/skia/include/private/GrTypesPriv.h17
-rw-r--r--chromium/third_party/skia/include/private/GrVkTypesPriv.h49
-rw-r--r--chromium/third_party/skia/include/private/SkChecksum.h7
-rw-r--r--chromium/third_party/skia/include/private/SkColorData.h1
-rw-r--r--chromium/third_party/skia/include/private/SkFixed.h8
-rw-r--r--chromium/third_party/skia/include/private/SkImageInfoPriv.h4
-rw-r--r--chromium/third_party/skia/include/private/SkOpts_spi.h21
-rw-r--r--chromium/third_party/skia/include/private/SkPathRef.h18
-rw-r--r--chromium/third_party/skia/include/private/SkSemaphore.h8
-rw-r--r--chromium/third_party/skia/include/private/SkTArray.h43
-rw-r--r--chromium/third_party/skia/include/private/SkTDArray.h9
-rw-r--r--chromium/third_party/skia/include/private/SkTemplates.h9
18 files changed, 187 insertions, 77 deletions
diff --git a/chromium/third_party/skia/include/private/GrContext_Base.h b/chromium/third_party/skia/include/private/GrContext_Base.h
index b5b3119361f..326c9107724 100644
--- a/chromium/third_party/skia/include/private/GrContext_Base.h
+++ b/chromium/third_party/skia/include/private/GrContext_Base.h
@@ -16,6 +16,7 @@
class GrBaseContextPriv;
class GrCaps;
class GrContext;
+class GrContextThreadSafeProxy;
class GrImageContext;
class GrRecordingContext;
@@ -26,7 +27,7 @@ public:
/*
* The 3D API backing this context
*/
- SK_API GrBackendApi backend() const { return fBackend; }
+ SK_API GrBackendApi backend() const;
/*
* Retrieve the default GrBackendFormat for a given SkColorType and renderability.
@@ -39,6 +40,9 @@ public:
SK_API GrBackendFormat compressedBackendFormat(SkImage::CompressionType) const;
+ // TODO: When the public version is gone, rename to refThreadSafeProxy and add raw ptr ver.
+ sk_sp<GrContextThreadSafeProxy> threadSafeProxy();
+
// Provides access to functions that aren't part of the public API.
GrBaseContextPriv priv();
const GrBaseContextPriv priv() const;
@@ -46,9 +50,9 @@ public:
protected:
friend class GrBaseContextPriv; // for hidden functions
- GrContext_Base(GrBackendApi backend, const GrContextOptions& options, uint32_t contextID);
+ GrContext_Base(sk_sp<GrContextThreadSafeProxy>);
- virtual bool init(sk_sp<const GrCaps>);
+ virtual bool init();
/**
* An identifier for this context. The id is used by all compatible contexts. For example,
@@ -57,7 +61,7 @@ protected:
* a third thread with a direct context, then all three contexts will report the same id.
* It is an error for an image to be used with contexts that report different ids.
*/
- uint32_t contextID() const { return fContextID; }
+ uint32_t contextID() const;
bool matches(GrContext_Base* candidate) const {
return candidate->contextID() == this->contextID();
@@ -66,7 +70,7 @@ protected:
/*
* The options in effect for this context
*/
- const GrContextOptions& options() const { return fOptions; }
+ const GrContextOptions& options() const;
const GrCaps* caps() const;
sk_sp<const GrCaps> refCaps() const;
@@ -75,12 +79,9 @@ protected:
virtual GrRecordingContext* asRecordingContext() { return nullptr; }
virtual GrContext* asDirectContext() { return nullptr; }
-private:
- const GrBackendApi fBackend;
- const GrContextOptions fOptions;
- const uint32_t fContextID;
- sk_sp<const GrCaps> fCaps;
+ sk_sp<GrContextThreadSafeProxy> fThreadSafeProxy;
+private:
typedef SkRefCnt INHERITED;
};
diff --git a/chromium/third_party/skia/include/private/GrImageContext.h b/chromium/third_party/skia/include/private/GrImageContext.h
index 9dc0acb8154..65d30642bc5 100644
--- a/chromium/third_party/skia/include/private/GrImageContext.h
+++ b/chromium/third_party/skia/include/private/GrImageContext.h
@@ -18,10 +18,6 @@ class GrImageContext : public GrContext_Base {
public:
~GrImageContext() override;
- SK_API GrBackendFormat defaultBackendFormat(SkColorType ct, GrRenderable renderable) const {
- return INHERITED::defaultBackendFormat(ct, renderable);
- }
-
// Provides access to functions that aren't part of the public API.
GrImageContextPriv priv();
const GrImageContextPriv priv() const;
@@ -29,7 +25,7 @@ public:
protected:
friend class GrImageContextPriv; // for hidden functions
- GrImageContext(GrBackendApi, const GrContextOptions&, uint32_t contextID);
+ GrImageContext(sk_sp<GrContextThreadSafeProxy>);
SK_API virtual void abandonContext();
SK_API virtual bool abandoned();
@@ -44,7 +40,6 @@ protected:
private:
std::unique_ptr<GrProxyProvider> fProxyProvider;
- bool fAbandoned = false;
// In debug builds we guard against improper thread handling
// This guard is passed to the GrDrawingManager and, from there to all the
diff --git a/chromium/third_party/skia/include/private/GrRecordingContext.h b/chromium/third_party/skia/include/private/GrRecordingContext.h
index 921731c5dd0..945ed3e9e61 100644
--- a/chromium/third_party/skia/include/private/GrRecordingContext.h
+++ b/chromium/third_party/skia/include/private/GrRecordingContext.h
@@ -75,8 +75,8 @@ protected:
std::unique_ptr<SkArenaAlloc> fRecordTimeAllocator;
};
- GrRecordingContext(GrBackendApi, const GrContextOptions&, uint32_t contextID);
- bool init(sk_sp<const GrCaps>) override;
+ GrRecordingContext(sk_sp<GrContextThreadSafeProxy>);
+ bool init() override;
void setupDrawingManager(bool sortOpsTasks, bool reduceOpsTaskSplitting);
void abandonContext() override;
diff --git a/chromium/third_party/skia/include/private/GrResourceKey.h b/chromium/third_party/skia/include/private/GrResourceKey.h
index 977eecf25ed..ee39e903048 100644
--- a/chromium/third_party/skia/include/private/GrResourceKey.h
+++ b/chromium/third_party/skia/include/private/GrResourceKey.h
@@ -62,7 +62,7 @@ protected:
} else {
size_t bytes = that.size();
SkASSERT(SkIsAlign4(bytes));
- fKey.reset(SkToInt(bytes / sizeof(uint32_t)));
+ fKey.reset(bytes / sizeof(uint32_t));
memcpy(fKey.get(), that.fKey.get(), bytes);
this->validate();
}
@@ -103,10 +103,10 @@ protected:
class Builder {
public:
Builder(GrResourceKey* key, uint32_t domain, int data32Count) : fKey(key) {
- SkASSERT(data32Count >= 0);
+ size_t count = SkToSizeT(data32Count);
SkASSERT(domain != kInvalidDomain);
- key->fKey.reset(kMetaDataCnt + data32Count);
- int size = (data32Count + kMetaDataCnt) * sizeof(uint32_t);
+ key->fKey.reset(kMetaDataCnt + count);
+ size_t size = (count + kMetaDataCnt) * sizeof(uint32_t);
SkASSERT(SkToU16(size) == size);
SkASSERT(SkToU16(domain) == domain);
key->fKey[kDomainAndSize_MetaDataIdx] = domain | (size << 16);
@@ -128,7 +128,7 @@ protected:
SkASSERT(fKey);
SkDEBUGCODE(size_t dataCount = fKey->internalSize() / sizeof(uint32_t) - kMetaDataCnt;)
SkASSERT(SkToU32(dataIdx) < dataCount);
- return fKey->fKey[kMetaDataCnt + dataIdx];
+ return fKey->fKey[(int)kMetaDataCnt + dataIdx];
}
private:
diff --git a/chromium/third_party/skia/include/private/GrSharedEnums.h b/chromium/third_party/skia/include/private/GrSharedEnums.h
index d745b70bd43..cdb0f80b14d 100644
--- a/chromium/third_party/skia/include/private/GrSharedEnums.h
+++ b/chromium/third_party/skia/include/private/GrSharedEnums.h
@@ -15,17 +15,15 @@
/**
* We have coverage effects that clip rendering to the edge of some geometric primitive.
* This enum specifies how that clipping is performed. Not all factories that take a
- * GrProcessorEdgeType will succeed with all values and it is up to the caller to check for
- * a NULL return.
+ * GrProcessorEdgeType will succeed with all values and it is up to the caller to verify success.
*/
enum class GrClipEdgeType {
kFillBW,
kFillAA,
kInverseFillBW,
kInverseFillAA,
- kHairlineAA,
- kLast = kHairlineAA
+ kLast = kInverseFillAA
};
enum class PMConversion {
diff --git a/chromium/third_party/skia/include/private/GrSingleOwner.h b/chromium/third_party/skia/include/private/GrSingleOwner.h
index 6369ae82c88..0bbaeb7849f 100644
--- a/chromium/third_party/skia/include/private/GrSingleOwner.h
+++ b/chromium/third_party/skia/include/private/GrSingleOwner.h
@@ -14,30 +14,39 @@
#include "include/private/SkMutex.h"
#include "include/private/SkThreadID.h"
+#define GR_ASSERT_SINGLE_OWNER(obj) \
+ GrSingleOwner::AutoEnforce debug_SingleOwner(obj, __FILE__, __LINE__);
+
// This is a debug tool to verify an object is only being used from one thread at a time.
class GrSingleOwner {
public:
GrSingleOwner() : fOwner(kIllegalThreadID), fReentranceCount(0) {}
struct AutoEnforce {
- AutoEnforce(GrSingleOwner* so) : fSO(so) { fSO->enter(); }
- ~AutoEnforce() { fSO->exit(); }
+ AutoEnforce(GrSingleOwner* so, const char* file, int line)
+ : fFile(file), fLine(line), fSO(so) {
+ fSO->enter(file, line);
+ }
+ ~AutoEnforce() { fSO->exit(fFile, fLine); }
+ const char* fFile;
+ int fLine;
GrSingleOwner* fSO;
};
private:
- void enter() {
+ void enter(const char* file, int line) {
SkAutoMutexExclusive lock(fMutex);
SkThreadID self = SkGetThreadID();
- SkASSERT(fOwner == self || fOwner == kIllegalThreadID);
+ SkASSERTF(fOwner == self || fOwner == kIllegalThreadID, "%s:%d Single owner failure.",
+ file, line);
fReentranceCount++;
fOwner = self;
}
- void exit() {
+ void exit(const char* file, int line) {
SkAutoMutexExclusive lock(fMutex);
- SkASSERT(fOwner == SkGetThreadID());
+ SkASSERTF(fOwner == SkGetThreadID(), "%s:%d Single owner failure.", file, line);
fReentranceCount--;
if (fReentranceCount == 0) {
fOwner = kIllegalThreadID;
@@ -49,6 +58,7 @@ private:
int fReentranceCount SK_GUARDED_BY(fMutex);
};
#else
+#define GR_ASSERT_SINGLE_OWNER(obj)
class GrSingleOwner {}; // Provide a dummy implementation so we can pass pointers to constructors
#endif
diff --git a/chromium/third_party/skia/include/private/GrTypesPriv.h b/chromium/third_party/skia/include/private/GrTypesPriv.h
index 03ac124c0d4..21e13b80ccd 100644
--- a/chromium/third_party/skia/include/private/GrTypesPriv.h
+++ b/chromium/third_party/skia/include/private/GrTypesPriv.h
@@ -99,6 +99,13 @@ enum class GrTexturable : bool {
kYes = true
};
+// A DDL recorder has its own proxy provider and proxy cache. This enum indicates if
+// a given proxy provider is one of these special ones.
+enum class GrDDLProvider : bool {
+ kNo = false,
+ kYes = true
+};
+
/**
* Formats for masks, used by the font cache. Important that these are 0-based.
*/
@@ -114,18 +121,16 @@ static const int kMaskFormatCount = kLast_GrMaskFormat + 1;
/**
* Return the number of bytes-per-pixel for the specified mask format.
*/
-static inline int GrMaskFormatBytesPerPixel(GrMaskFormat format) {
+inline constexpr int GrMaskFormatBytesPerPixel(GrMaskFormat format) {
SkASSERT(format < kMaskFormatCount);
// kA8 (0) -> 1
// kA565 (1) -> 2
// kARGB (2) -> 4
- static const int sBytesPerPixel[] = {1, 2, 4};
- static_assert(SK_ARRAY_COUNT(sBytesPerPixel) == kMaskFormatCount, "array_size_mismatch");
static_assert(kA8_GrMaskFormat == 0, "enum_order_dependency");
static_assert(kA565_GrMaskFormat == 1, "enum_order_dependency");
static_assert(kARGB_GrMaskFormat == 2, "enum_order_dependency");
- return sBytesPerPixel[(int)format];
+ return SkTo<int>(1u << format);
}
/** Ownership rules for external GPU resources imported into Skia. */
@@ -650,10 +655,8 @@ static inline GrClipEdgeType GrInvertProcessorEdgeType(const GrClipEdgeType edge
return GrClipEdgeType::kFillBW;
case GrClipEdgeType::kInverseFillAA:
return GrClipEdgeType::kFillAA;
- case GrClipEdgeType::kHairlineAA:
- SK_ABORT("Hairline fill isn't invertible.");
}
- return GrClipEdgeType::kFillAA; // suppress warning.
+ SkUNREACHABLE;
}
/**
diff --git a/chromium/third_party/skia/include/private/GrVkTypesPriv.h b/chromium/third_party/skia/include/private/GrVkTypesPriv.h
index 49b392c52b5..b46cf8bf914 100644
--- a/chromium/third_party/skia/include/private/GrVkTypesPriv.h
+++ b/chromium/third_party/skia/include/private/GrVkTypesPriv.h
@@ -11,7 +11,7 @@
#include "include/core/SkRefCnt.h"
#include "include/gpu/vk/GrVkTypes.h"
-class GrVkImageLayout;
+class GrBackendSurfaceMutableStateImpl;
// This struct is to used to store the the actual information about the vulkan backend image on the
// GrBackendTexture and GrBackendRenderTarget. When a client calls getVkImageInfo on a
@@ -20,8 +20,7 @@ class GrVkImageLayout;
// current VkImageLayout which can be shared with an internal GrVkImage so that layout updates can
// be seen by all users of the image.
struct GrVkBackendSurfaceInfo {
- GrVkBackendSurfaceInfo(GrVkImageInfo info, GrVkImageLayout* layout)
- : fImageInfo(info), fLayout(layout) {}
+ GrVkBackendSurfaceInfo(GrVkImageInfo info) : fImageInfo(info) {}
void cleanup();
@@ -31,11 +30,7 @@ struct GrVkBackendSurfaceInfo {
// attempt to unref the old fLayout on this object.
void assign(const GrVkBackendSurfaceInfo&, bool isValid);
- void setImageLayout(VkImageLayout layout);
-
- sk_sp<GrVkImageLayout> getGrVkImageLayout() const;
-
- GrVkImageInfo snapImageInfo() const;
+ GrVkImageInfo snapImageInfo(const GrBackendSurfaceMutableStateImpl*) const;
bool isProtected() const { return fImageInfo.fProtected == GrProtected::kYes; }
#if GR_TEST_UTILS
@@ -44,7 +39,43 @@ struct GrVkBackendSurfaceInfo {
private:
GrVkImageInfo fImageInfo;
- GrVkImageLayout* fLayout;
+};
+
+class GrVkSharedImageInfo {
+public:
+ GrVkSharedImageInfo(VkImageLayout layout, uint32_t queueFamilyIndex)
+ : fLayout(layout)
+ , fQueueFamilyIndex(queueFamilyIndex) {}
+
+ GrVkSharedImageInfo& operator=(const GrVkSharedImageInfo& that) {
+ fLayout = that.getImageLayout();
+ fQueueFamilyIndex = that.getQueueFamilyIndex();
+ return *this;
+ }
+
+ void setImageLayout(VkImageLayout layout) {
+ // Defaulting to use std::memory_order_seq_cst
+ fLayout.store(layout);
+ }
+
+ VkImageLayout getImageLayout() const {
+ // Defaulting to use std::memory_order_seq_cst
+ return fLayout.load();
+ }
+
+ void setQueueFamilyIndex(uint32_t queueFamilyIndex) {
+ // Defaulting to use std::memory_order_seq_cst
+ fQueueFamilyIndex.store(queueFamilyIndex);
+ }
+
+ uint32_t getQueueFamilyIndex() const {
+ // Defaulting to use std::memory_order_seq_cst
+ return fQueueFamilyIndex.load();
+ }
+
+private:
+ std::atomic<VkImageLayout> fLayout;
+ std::atomic<uint32_t> fQueueFamilyIndex;
};
#endif
diff --git a/chromium/third_party/skia/include/private/SkChecksum.h b/chromium/third_party/skia/include/private/SkChecksum.h
index 8e2a4ba5248..6339239d65c 100644
--- a/chromium/third_party/skia/include/private/SkChecksum.h
+++ b/chromium/third_party/skia/include/private/SkChecksum.h
@@ -11,14 +11,9 @@
#include "include/core/SkString.h"
#include "include/core/SkTypes.h"
#include "include/private/SkNoncopyable.h"
+#include "include/private/SkOpts_spi.h"
#include "include/private/SkTLogic.h"
-// #include "src/core/SkOpts.h"
-// It's sort of pesky to be able to include SkOpts.h here, so we'll just re-declare what we need.
-namespace SkOpts {
- extern uint32_t (*hash_fn)(const void*, size_t, uint32_t);
-}
-
class SkChecksum : SkNoncopyable {
public:
/**
diff --git a/chromium/third_party/skia/include/private/SkColorData.h b/chromium/third_party/skia/include/private/SkColorData.h
index 2090ab4b7ee..aba610eacf6 100644
--- a/chromium/third_party/skia/include/private/SkColorData.h
+++ b/chromium/third_party/skia/include/private/SkColorData.h
@@ -435,6 +435,7 @@ static inline uint32_t Sk4f_toL32(const Sk4f& px) {
using SkPMColor4f = SkRGBA4f<kPremul_SkAlphaType>;
constexpr SkPMColor4f SK_PMColor4fTRANSPARENT = { 0, 0, 0, 0 };
+constexpr SkPMColor4f SK_PMColor4fBLACK = { 0, 0, 0, 1 };
constexpr SkPMColor4f SK_PMColor4fWHITE = { 1, 1, 1, 1 };
constexpr SkPMColor4f SK_PMColor4fILLEGAL = { SK_FloatNegativeInfinity,
SK_FloatNegativeInfinity,
diff --git a/chromium/third_party/skia/include/private/SkFixed.h b/chromium/third_party/skia/include/private/SkFixed.h
index af858efc89c..6e8990f574b 100644
--- a/chromium/third_party/skia/include/private/SkFixed.h
+++ b/chromium/third_party/skia/include/private/SkFixed.h
@@ -62,7 +62,7 @@ typedef int32_t SkFixed;
SkASSERT(n >= -32768 && n <= 32767);
// Left shifting a negative value has undefined behavior in C, so we cast to unsigned before
// shifting.
- return (unsigned)n << 16;
+ return (SkFixed)( (unsigned)n << 16 );
}
#else
// Left shifting a negative value has undefined behavior in C, so we cast to unsigned before
@@ -76,13 +76,13 @@ typedef int32_t SkFixed;
#define SkFixedFloorToInt(x) ((x) >> 16)
static inline SkFixed SkFixedRoundToFixed(SkFixed x) {
- return (x + SK_FixedHalf) & 0xFFFF0000;
+ return (SkFixed)( (uint32_t)(x + SK_FixedHalf) & 0xFFFF0000 );
}
static inline SkFixed SkFixedCeilToFixed(SkFixed x) {
- return (x + SK_Fixed1 - 1) & 0xFFFF0000;
+ return (SkFixed)( (uint32_t)(x + SK_Fixed1 - 1) & 0xFFFF0000 );
}
static inline SkFixed SkFixedFloorToFixed(SkFixed x) {
- return x & 0xFFFF0000;
+ return (SkFixed)( (uint32_t)x & 0xFFFF0000 );
}
#define SkFixedAbs(x) SkAbs32(x)
diff --git a/chromium/third_party/skia/include/private/SkImageInfoPriv.h b/chromium/third_party/skia/include/private/SkImageInfoPriv.h
index 582867162f6..6a3c0d17362 100644
--- a/chromium/third_party/skia/include/private/SkImageInfoPriv.h
+++ b/chromium/third_party/skia/include/private/SkImageInfoPriv.h
@@ -74,7 +74,7 @@ static int SkColorTypeShiftPerPixel(SkColorType ct) {
}
static inline size_t SkColorTypeMinRowBytes(SkColorType ct, int width) {
- return width * SkColorTypeBytesPerPixel(ct);
+ return (size_t)(width * SkColorTypeBytesPerPixel(ct));
}
static inline bool SkColorTypeIsValid(unsigned value) {
@@ -85,7 +85,7 @@ static inline size_t SkColorTypeComputeOffset(SkColorType ct, int x, int y, size
if (kUnknown_SkColorType == ct) {
return 0;
}
- return y * rowBytes + (x << SkColorTypeShiftPerPixel(ct));
+ return (size_t)y * rowBytes + ((size_t)x << SkColorTypeShiftPerPixel(ct));
}
static inline bool SkColorTypeIsNormalized(SkColorType ct) {
diff --git a/chromium/third_party/skia/include/private/SkOpts_spi.h b/chromium/third_party/skia/include/private/SkOpts_spi.h
new file mode 100644
index 00000000000..528e322113b
--- /dev/null
+++ b/chromium/third_party/skia/include/private/SkOpts_spi.h
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2020 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkOpts_spi_DEFINED
+#define SkOpts_spi_DEFINED
+
+#include "include/core/SkTypes.h"
+
+// These are exposed as SK_SPI (e.g. SkParagraph), the rest of SkOpts is
+// declared in src/core
+
+namespace SkOpts {
+ // The fastest high quality 32-bit hash we can provide on this platform.
+ extern uint32_t SK_SPI (*hash_fn)(const void* data, size_t bytes, uint32_t seed);
+}
+
+#endif
diff --git a/chromium/third_party/skia/include/private/SkPathRef.h b/chromium/third_party/skia/include/private/SkPathRef.h
index 7afe4f9a52e..f9533d72615 100644
--- a/chromium/third_party/skia/include/private/SkPathRef.h
+++ b/chromium/third_party/skia/include/private/SkPathRef.h
@@ -42,6 +42,24 @@ class SkWBuffer;
class SK_API SkPathRef final : public SkNVRefCnt<SkPathRef> {
public:
+ SkPathRef(SkTDArray<SkPoint> points, SkTDArray<uint8_t> verbs, SkTDArray<SkScalar> weights,
+ unsigned segmentMask)
+ : fPoints(std::move(points))
+ , fVerbs(std::move(verbs))
+ , fConicWeights(std::move(weights))
+ {
+ fBoundsIsDirty = true; // this also invalidates fIsFinite
+ fGenerationID = kEmptyGenID;
+ fSegmentMask = segmentMask;
+ fIsOval = false;
+ fIsRRect = false;
+ // The next two values don't matter unless fIsOval or fIsRRect are true.
+ fRRectOrOvalIsCCW = false;
+ fRRectOrOvalStartIdx = 0xAC;
+ SkDEBUGCODE(fEditorsAttached.store(0);)
+ SkDEBUGCODE(this->validate();)
+ }
+
class Editor {
public:
Editor(sk_sp<SkPathRef>* pathRef,
diff --git a/chromium/third_party/skia/include/private/SkSemaphore.h b/chromium/third_party/skia/include/private/SkSemaphore.h
index 265847b5e83..d7318be5779 100644
--- a/chromium/third_party/skia/include/private/SkSemaphore.h
+++ b/chromium/third_party/skia/include/private/SkSemaphore.h
@@ -19,7 +19,7 @@ public:
constexpr SkSemaphore(int count = 0) : fCount(count), fOSSemaphore(nullptr) {}
// Cleanup the underlying OS semaphore.
- ~SkSemaphore();
+ SK_SPI ~SkSemaphore();
// Increment the counter n times.
// Generally it's better to call signal(n) instead of signal() n times.
@@ -30,7 +30,7 @@ public:
void wait();
// If the counter is positive, decrement it by 1 and return true, otherwise return false.
- bool try_wait();
+ SK_SPI bool try_wait();
private:
// This implementation follows the general strategy of
@@ -44,8 +44,8 @@ private:
// moving the count from >=0 to <0 or vice-versa, i.e. sleeping or waking threads.
struct OSSemaphore;
- void osSignal(int n);
- void osWait();
+ SK_SPI void osSignal(int n);
+ SK_SPI void osWait();
std::atomic<int> fCount;
SkOnce fOSSemaphoreOnce;
diff --git a/chromium/third_party/skia/include/private/SkTArray.h b/chromium/third_party/skia/include/private/SkTArray.h
index 78ce51b270a..cc59aa6ba8b 100644
--- a/chromium/third_party/skia/include/private/SkTArray.h
+++ b/chromium/third_party/skia/include/private/SkTArray.h
@@ -20,10 +20,15 @@
#include <new>
#include <utility>
-/** When MEM_MOVE is true T will be bit copied when moved.
- When MEM_MOVE is false, T will be copy constructed / destructed.
- In all cases T will be default-initialized on allocation,
- and its destructor will be called from this object's destructor.
+/** SkTArray<T> implements a typical, mostly std::vector-like array.
+ Each T will be default-initialized on allocation, and ~T will be called on destruction.
+
+ MEM_MOVE controls the behavior when a T needs to be moved (e.g. when the array is resized)
+ - true: T will be bit-copied via memcpy.
+ - false: T will be moved via move-constructors.
+
+ Modern implementations of std::vector<T> will generally provide similar performance
+ characteristics when used with appropriate care. Consider using std::vector<T> in new code.
*/
template <typename T, bool MEM_MOVE = false> class SkTArray {
public:
@@ -47,10 +52,23 @@ public:
}
SkTArray(SkTArray&& that) {
- // TODO: If 'that' owns its memory why don't we just steal the pointer?
- this->init(that.fCount);
- that.move(fItemArray);
- that.fCount = 0;
+ if (that.fOwnMemory) {
+ fItemArray = that.fItemArray;
+ fCount = that.fCount;
+ fAllocCount = that.fAllocCount;
+ fOwnMemory = true;
+ fReserved = that.fReserved;
+
+ that.fItemArray = nullptr;
+ that.fCount = 0;
+ that.fAllocCount = 0;
+ that.fOwnMemory = true;
+ that.fReserved = false;
+ } else {
+ this->init(that.fCount);
+ that.move(fItemArray);
+ that.fCount = 0;
+ }
}
/**
@@ -351,6 +369,9 @@ public:
return fItemArray[i];
}
+ T& at(int i) { return (*this)[i]; }
+ const T& at(int i) const { return (*this)[i]; }
+
/**
* equivalent to operator[](0)
*/
@@ -455,7 +476,7 @@ private:
fReserved = false;
} else {
fAllocCount = std::max(count, std::max(kMinHeapAllocCount, reserveCount));
- fItemArray = (T*)sk_malloc_throw(fAllocCount, sizeof(T));
+ fItemArray = (T*)sk_malloc_throw((size_t)fAllocCount, sizeof(T));
fOwnMemory = true;
fReserved = reserveCount > 0;
}
@@ -505,7 +526,7 @@ private:
}
template <bool E = MEM_MOVE> std::enable_if_t<!E, void> move(void* dst) {
for (int i = 0; i < fCount; ++i) {
- new (static_cast<char*>(dst) + sizeof(T) * i) T(std::move(fItemArray[i]));
+ new (static_cast<char*>(dst) + sizeof(T) * (size_t)i) T(std::move(fItemArray[i]));
fItemArray[i].~T();
}
}
@@ -551,7 +572,7 @@ private:
fAllocCount = Sk64_pin_to_s32(newAllocCount);
SkASSERT(fAllocCount >= newCount);
- T* newItemArray = (T*)sk_malloc_throw(fAllocCount, sizeof(T));
+ T* newItemArray = (T*)sk_malloc_throw((size_t)fAllocCount, sizeof(T));
this->move(newItemArray);
if (fOwnMemory) {
sk_free(fItemArray);
diff --git a/chromium/third_party/skia/include/private/SkTDArray.h b/chromium/third_party/skia/include/private/SkTDArray.h
index 33d4d7cc2ba..9d475f6f8ea 100644
--- a/chromium/third_party/skia/include/private/SkTDArray.h
+++ b/chromium/third_party/skia/include/private/SkTDArray.h
@@ -17,6 +17,13 @@
#include <initializer_list>
#include <utility>
+/** SkTDArray<T> implements a std::vector-like array for raw data-only objects that do not require
+ construction or destruction. The constructor and destructor for T will not be called; T objects
+ will always be moved via raw memcpy. Newly created T objects will contain uninitialized memory.
+
+ In most cases, std::vector<T> can provide a similar level of performance for POD objects when
+ used with appropriate care. In new code, consider std::vector<T> instead.
+*/
template <typename T> class SkTDArray {
public:
SkTDArray() : fArray(nullptr), fReserve(0), fCount(0) {}
@@ -365,7 +372,7 @@ private:
SkASSERT_RELEASE( SkTFitsIn<int>(reserve) );
fReserve = SkTo<int>(reserve);
- fArray = (T*)sk_realloc_throw(fArray, fReserve * sizeof(T));
+ fArray = (T*)sk_realloc_throw(fArray, (size_t)fReserve * sizeof(T));
}
};
diff --git a/chromium/third_party/skia/include/private/SkTemplates.h b/chromium/third_party/skia/include/private/SkTemplates.h
index 477bbcb397f..1edf8120e4b 100644
--- a/chromium/third_party/skia/include/private/SkTemplates.h
+++ b/chromium/third_party/skia/include/private/SkTemplates.h
@@ -114,6 +114,10 @@ public:
return fArray[index];
}
+ // aliases matching other types like std::vector
+ const T* data() const { return fArray; }
+ T* data() { return fArray; }
+
private:
std::unique_ptr<T[]> fArray;
SkDEBUGCODE(int fCount = 0;)
@@ -203,6 +207,11 @@ public:
return fArray[index];
}
+ // aliases matching other types like std::vector
+ const T* data() const { return fArray; }
+ T* data() { return fArray; }
+ size_t size() const { return fCount; }
+
private:
#if defined(SK_BUILD_FOR_GOOGLE3)
// Stack frame size is limited for SK_BUILD_FOR_GOOGLE3. 4k is less than the actual max, but some functions