aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--gn/core.gni1
-rw-r--r--src/core/SkDeviceProfile.cpp77
-rw-r--r--src/core/SkDeviceProfile.h98
-rw-r--r--tests/ResourceCacheTest.cpp18
-rw-r--r--tools/gpu/gl/debug/DebugGLTestContext.cpp10
5 files changed, 14 insertions, 190 deletions
diff --git a/gn/core.gni b/gn/core.gni
index 7881579e38..5b3e053ea8 100644
--- a/gn/core.gni
+++ b/gn/core.gni
@@ -103,7 +103,6 @@ skia_core_sources = [
"$_src/core/SkDescriptor.h",
"$_src/core/SkDevice.cpp",
"$_src/core/SkDevice.h",
- "$_src/core/SkDeviceProfile.cpp",
"$_src/core/SkDiscardableMemory.h",
"$_src/lazy/SkDiscardableMemoryPool.cpp",
"$_src/core/SkDistanceFieldGen.cpp",
diff --git a/src/core/SkDeviceProfile.cpp b/src/core/SkDeviceProfile.cpp
deleted file mode 100644
index e1c10c87d7..0000000000
--- a/src/core/SkDeviceProfile.cpp
+++ /dev/null
@@ -1,77 +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.
- */
-
-
-#include "SkDeviceProfile.h"
-#include "SkMutex.h"
-
-#define DEFAULT_GAMMAEXP 2.2f
-#define DEFAULT_CONTRASTSCALE 0.5f
-#define DEFAULT_LCDCONFIG SkDeviceProfile::kNone_LCDConfig
-#define DEFAULT_FONTHINTLEVEL SkDeviceProfile::kSlight_FontHintLevel
-
-static float pin(float value, float min, float max) {
- if (value < min) {
- value = min;
- } else if (value > max) {
- value = max;
- }
- return value;
-}
-
-SkDeviceProfile::SkDeviceProfile(float gammaExp, float contrast,
- LCDConfig config, FontHintLevel level) {
- fGammaExponent = pin(gammaExp, 0, 10);
- fContrastScale = pin(contrast, 0, 1);
- fLCDConfig = config;
- fFontHintLevel = level;
-}
-
-void SkDeviceProfile::generateTableForLuminanceByte(U8CPU lumByte,
- uint8_t table[256]) const {
-}
-
-///////////////////////////////////////////////////////////////////////////////
-
-SkDeviceProfile* SkDeviceProfile::Create(float gammaExp,
- float contrast,
- LCDConfig config,
- FontHintLevel level) {
- return new SkDeviceProfile(gammaExp, contrast, config, level);
-}
-
-SK_DECLARE_STATIC_MUTEX(gMutex);
-static SkDeviceProfile* gDefaultProfile;
-static SkDeviceProfile* gGlobalProfile;
-
-SkDeviceProfile* SkDeviceProfile::GetDefault() {
- SkAutoMutexAcquire amc(gMutex);
-
- if (nullptr == gDefaultProfile) {
- gDefaultProfile = SkDeviceProfile::Create(DEFAULT_GAMMAEXP,
- DEFAULT_CONTRASTSCALE,
- DEFAULT_LCDCONFIG,
- DEFAULT_FONTHINTLEVEL);
- }
- return gDefaultProfile;
-}
-
-SkDeviceProfile* SkDeviceProfile::RefGlobal() {
- SkAutoMutexAcquire amc(gMutex);
-
- if (nullptr == gGlobalProfile) {
- gGlobalProfile = SkDeviceProfile::GetDefault();
- }
- gGlobalProfile->ref();
- return gGlobalProfile;
-}
-
-void SkDeviceProfile::SetGlobal(SkDeviceProfile* profile) {
- SkAutoMutexAcquire amc(gMutex);
-
- SkRefCnt_SafeAssign(gGlobalProfile, profile);
-}
diff --git a/src/core/SkDeviceProfile.h b/src/core/SkDeviceProfile.h
deleted file mode 100644
index ed533f8329..0000000000
--- a/src/core/SkDeviceProfile.h
+++ /dev/null
@@ -1,98 +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 SkDeviceProfile_DEFINED
-#define SkDeviceProfile_DEFINED
-
-#include "SkRefCnt.h"
-
-class SkDeviceProfile : public SkRefCnt {
-public:
-
-
- enum LCDConfig {
- kNone_LCDConfig, // disables LCD text rendering, uses A8 instead
- kRGB_Horizontal_LCDConfig,
- kBGR_Horizontal_LCDConfig,
- kRGB_Vertical_LCDConfig,
- kBGR_Vertical_LCDConfig
- };
-
- enum FontHintLevel {
- kNone_FontHintLevel,
- kSlight_FontHintLevel,
- kNormal_FontHintLevel,
- kFull_FontHintLevel,
- kAuto_FontHintLevel
- };
-
- /**
- * gammaExp is typically between 1.0 and 2.2. For no gamma adjustment,
- * specify 1.0
- *
- * contrastScale will be pinned between 0.0 and 1.0. For no contrast
- * adjustment, specify 0.0
- *
- * @param config Describes the LCD layout for this device. If this is set
- * to kNone, then all requests for LCD text will be
- * devolved to A8 antialiasing.
- *
- * @param level The hinting level to be used, IF the paint specifies
- * "default". Otherwise the paint's hinting level will be
- * respected.
- */
- static SkDeviceProfile* Create(float gammaExp,
- float contrastScale,
- LCDConfig,
- FontHintLevel);
-
- /**
- * Returns the global default profile, that is used if no global profile is
- * specified with SetGlobal(), or if nullptr is specified to SetGlobal().
- * The references count is *not* incremented, and the caller should not
- * call unref().
- */
- static SkDeviceProfile* GetDefault();
-
- /**
- * Return the current global profile (or the default if no global had yet
- * been set) and increment its reference count. The call *must* call unref()
- * when it is done using it.
- */
- static SkDeviceProfile* RefGlobal();
-
- /**
- * Make the specified profile be the global value for all subsequently
- * instantiated devices. Does not affect any existing devices.
- * Increments the reference count on the profile.
- * Specify nullptr for the "identity" profile (where there is no gamma or
- * contrast correction).
- */
- static void SetGlobal(SkDeviceProfile*);
-
- float getFontGammaExponent() const { return fGammaExponent; }
- float getFontContrastScale() const { return fContrastScale; }
-
- /**
- * Given a luminance byte (0 for black, 0xFF for white), generate a table
- * that applies the gamma/contrast settings to linear coverage values.
- */
- void generateTableForLuminanceByte(U8CPU lumByte, uint8_t table[256]) const;
-
-private:
- SkDeviceProfile(float gammaExp, float contrastScale, LCDConfig,
- FontHintLevel);
-
- float fGammaExponent;
- float fContrastScale;
- LCDConfig fLCDConfig;
- FontHintLevel fFontHintLevel;
-
- typedef SkRefCnt INHERITED;
-};
-
-#endif
diff --git a/tests/ResourceCacheTest.cpp b/tests/ResourceCacheTest.cpp
index 113945b414..dceb3e74ed 100644
--- a/tests/ResourceCacheTest.cpp
+++ b/tests/ResourceCacheTest.cpp
@@ -283,13 +283,12 @@ public:
~TestResource() override {
--fNumAlive;
- SkSafeUnref(fToDelete);
}
static int NumAlive() { return fNumAlive; }
- void setUnrefWhenDestroyed(TestResource* resource) {
- SkRefCnt_SafeAssign(fToDelete, resource);
+ void setUnrefWhenDestroyed(sk_sp<TestResource> resource) {
+ fToDelete = std::move(resource);
}
static void ComputeScratchKey(SimulatedProperty property, GrScratchKey* key) {
@@ -337,7 +336,7 @@ private:
size_t onGpuMemorySize() const override { return fSize; }
const char* getResourceType() const override { return "Test"; }
- TestResource* fToDelete;
+ sk_sp<TestResource> fToDelete;
size_t fSize;
static int fNumAlive;
SimulatedProperty fProperty;
@@ -1051,8 +1050,8 @@ static void test_cache_chained_purge(skiatest::Reporter* reporter) {
make_unique_key<0>(&key1, 1);
make_unique_key<0>(&key2, 2);
- TestResource* a = new TestResource(gpu);
- TestResource* b = new TestResource(gpu);
+ sk_sp<TestResource> a(new TestResource(gpu));
+ sk_sp<TestResource> b(new TestResource(gpu));
a->resourcePriv().setUniqueKey(key1);
b->resourcePriv().setUniqueKey(key2);
@@ -1062,8 +1061,9 @@ static void test_cache_chained_purge(skiatest::Reporter* reporter) {
REPORTER_ASSERT(reporter, 2 == TestResource::NumAlive());
- a->unref();
- b->unref();
+ TestResource* unownedA = a.release();
+ unownedA->unref();
+ b.reset();
REPORTER_ASSERT(reporter, 2 == TestResource::NumAlive());
@@ -1071,7 +1071,7 @@ static void test_cache_chained_purge(skiatest::Reporter* reporter) {
REPORTER_ASSERT(reporter, 2 == TestResource::NumAlive());
// Break the cycle
- a->setUnrefWhenDestroyed(nullptr);
+ unownedA->setUnrefWhenDestroyed(nullptr);
REPORTER_ASSERT(reporter, 2 == TestResource::NumAlive());
cache->purgeAllUnlocked();
diff --git a/tools/gpu/gl/debug/DebugGLTestContext.cpp b/tools/gpu/gl/debug/DebugGLTestContext.cpp
index 3a2c0b93f6..01e151cb76 100644
--- a/tools/gpu/gl/debug/DebugGLTestContext.cpp
+++ b/tools/gpu/gl/debug/DebugGLTestContext.cpp
@@ -789,7 +789,7 @@ public:
GrGLvoid bindVertexArray(GrGLuint id) override {
GrVertexArrayObj* array = FIND(id, GrVertexArrayObj, kVertexArray_ObjTypes);
GrAlwaysAssert((0 == id) || array);
- this->setVertexArray(array);
+ this->setVertexArray(sk_ref_sp(array));
}
GrGLvoid bindBuffer(GrGLenum target, GrGLuint bufferID) override {
@@ -939,7 +939,7 @@ private:
GrGLuint fCurrTextureUnit;
GrTextureUnitObj* fTextureUnits[kDefaultMaxTextureUnits];
GrBufferObj* fBoundBuffers[kNumBufferTargets];
- GrVertexArrayObj* fVertexArray;
+ sk_sp<GrVertexArrayObj> fVertexArray;
GrGLint fPackRowLength;
GrGLint fUnpackRowLength;
GrGLint fPackAlignment;
@@ -1089,14 +1089,14 @@ private:
fBoundBuffers[buffIdx] = buffer;
}
- void setVertexArray(GrVertexArrayObj* vertexArray) {
+ void setVertexArray(sk_sp<GrVertexArrayObj> vertexArray) {
if (vertexArray) {
SkASSERT(!vertexArray->getDeleted());
}
- SkRefCnt_SafeAssign(fVertexArray, vertexArray);
+ fVertexArray = std::move(vertexArray);
}
- GrVertexArrayObj* getVertexArray() { return fVertexArray; }
+ GrVertexArrayObj* getVertexArray() { return fVertexArray.get(); }
void setTexture(GrTextureObj *texture) {
fTextureUnits[fCurrTextureUnit]->setTexture(texture);