aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--dm/DMSrcSink.cpp4
-rw-r--r--gyp/core.gypi3
-rw-r--r--include/core/SkError.h91
-rw-r--r--src/animator/SkScriptRuntime.h4
-rw-r--r--src/core/SkCanvas.cpp3
-rw-r--r--src/core/SkError.cpp130
-rw-r--r--src/core/SkErrorInternals.h26
-rw-r--r--src/core/SkLightingShader.cpp1
-rw-r--r--src/core/SkPath.cpp7
-rw-r--r--src/core/SkReadBuffer.cpp21
-rw-r--r--src/core/SkValidatingReadBuffer.cpp1
-rw-r--r--src/gpu/SkGpuDevice.cpp10
-rw-r--r--src/gpu/SkGr.cpp6
-rw-r--r--src/utils/SkCanvasStateUtils.cpp3
-rw-r--r--tests/CanvasStateTest.cpp9
-rw-r--r--tests/ErrorTest.cpp64
-rw-r--r--tests/PictureTest.cpp24
-rw-r--r--tests/Test.cpp1
18 files changed, 15 insertions, 393 deletions
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp
index d4b5ace808..e777815baa 100644
--- a/dm/DMSrcSink.cpp
+++ b/dm/DMSrcSink.cpp
@@ -17,7 +17,6 @@
#include "SkData.h"
#include "SkDeferredCanvas.h"
#include "SkDocument.h"
-#include "SkError.h"
#include "SkImageGenerator.h"
#include "SkImageGeneratorCG.h"
#include "SkImageGeneratorWIC.h"
@@ -1181,8 +1180,6 @@ GPUSink::GPUSink(GrContextFactory::ContextType ct,
, fColorSpace(std::move(colorSpace))
, fThreaded(threaded) {}
-void PreAbandonGpuContextErrorHandler(SkError, void*) {}
-
DEFINE_bool(imm, false, "Run gpu configs in immediate mode.");
DEFINE_bool(batchClip, false, "Clip each GrBatch to its device bounds for testing.");
DEFINE_bool(batchBounds, false, "Draw a wireframe bounds of each GrBatch.");
@@ -1219,7 +1216,6 @@ Error GPUSink::draw(const Src& src, SkBitmap* dst, SkWStream*, SkString* log) co
return "Could not create a surface.";
}
if (FLAGS_preAbandonGpuContext) {
- SkSetErrorCallback(&PreAbandonGpuContextErrorHandler, nullptr);
factory.abandonContexts();
}
SkCanvas* canvas = surface->getCanvas();
diff --git a/gyp/core.gypi b/gyp/core.gypi
index ed83d94e6d..0f6c1e3981 100644
--- a/gyp/core.gypi
+++ b/gyp/core.gypi
@@ -118,8 +118,6 @@
'<(skia_src_path)/core/SkAAAConstants.h',
'<(skia_src_path)/core/SkEdge.cpp',
'<(skia_src_path)/core/SkEdge.h',
- '<(skia_src_path)/core/SkError.cpp',
- '<(skia_src_path)/core/SkErrorInternals.h',
'<(skia_src_path)/core/SkFDot6.h',
'<(skia_src_path)/core/SkFilterProc.cpp',
'<(skia_src_path)/core/SkFilterProc.h',
@@ -385,7 +383,6 @@
'<(skia_include_path)/core/SkDrawable.h',
'<(skia_include_path)/core/SkDrawFilter.h',
'<(skia_include_path)/core/SkDrawLooper.h',
- '<(skia_include_path)/core/SkError.h',
'<(skia_include_path)/core/SkFlattenable.h',
'<(skia_include_path)/core/SkFlattenableSerialization.h',
'<(skia_include_path)/core/SkFontLCDConfig.h',
diff --git a/include/core/SkError.h b/include/core/SkError.h
deleted file mode 100644
index 678c910253..0000000000
--- a/include/core/SkError.h
+++ /dev/null
@@ -1,91 +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 SkError_DEFINED
-#define SkError_DEFINED
-
-
-/** \file SkError.h
-*/
-
-enum SkError {
- /** All is well
- */
- kNoError_SkError=0,
-
- /** User argument passed to Skia function was invalid: NULL when that’s
- * not allowed, out of numeric range, bad enum, or violating some
- * other general precondition.
- */
- kInvalidArgument_SkError,
-
- /** User tried to perform some operation in a state when the operation
- * was not legal, or the operands make no sense (e.g., asking for
- * pixels from an SkPictureCanvas). Other examples might be
- * inset()’ing a rectangle to make it degenerate (negative width/height).
- */
- kInvalidOperation_SkError,
-
- /** Probably not needed right now, but in the future we could have opaque
- * handles for SkPictures floating around, and it would be a good idea
- * to anticipate this kind of issue.
- */
- kInvalidHandle_SkError,
-
- /** This is probably not possible because paint surely has defaults for
- * everything, but perhaps a paint can get into a bad state somehow.
- */
- kInvalidPaint_SkError,
-
- /** Skia was unable to allocate memory to perform some task.
- */
- kOutOfMemory_SkError,
-
- /** Skia failed while trying to consume some external resource.
- */
- kParseError_SkError,
-
- /** Something went wrong internally; could be resource exhaustion but
- * will often be a bug.
- */
- kInternalError_SkError
-};
-
-/** Return the current per-thread error code. Error codes are "sticky"; they
- * are not not reset by subsequent successful operations.
- */
-SkError SkGetLastError();
-
-/** Clear the current per-thread error code back to kNoError_SkError.
- */
-void SkClearLastError();
-
-/** Type for callback functions to be invoked whenever an error is registered.
- * Callback functions take the error code being set, as well as a context
- * argument that is provided when the callback is registered.
- */
-typedef void (*SkErrorCallbackFunction)(SkError, void *);
-
-/** Set the current per-thread error callback.
- *
- * @param cb The callback function to be invoked. Passing NULL
- * for cb will revert to the default error callback which
- * does nothing on release builds, but on debug builds will
- * print an informative error message to the screen.
- * @param context An arbitrary pointer that will be passed to
- * the provided callback function.
- */
-void SkSetErrorCallback(SkErrorCallbackFunction cb, void *context);
-
-/** Get a human-readable description of the last (per-thread) error that
- * occurred. The returned error message will include not only a human
- * readable version of the error code, but also information about the
- * conditions that led to the error itself.
- */
-const char *SkGetLastErrorString();
-
-#endif /* SkError_DEFINED */
diff --git a/src/animator/SkScriptRuntime.h b/src/animator/SkScriptRuntime.h
index 3e73801148..1fcdf20079 100644
--- a/src/animator/SkScriptRuntime.h
+++ b/src/animator/SkScriptRuntime.h
@@ -19,7 +19,7 @@ typedef SkLongArray(SkScriptCallBack*) SkTDScriptCallBackArray;
class SkScriptRuntime {
public:
- enum SkError {
+ enum Error {
kNoError,
kArrayIndexOutOfBounds,
kCouldNotFindReferencedID,
@@ -39,7 +39,7 @@ private:
void track(SkOpArray* array);
void track(SkString* string);
SkTDScriptCallBackArray& fCallBackArray;
- SkError fError;
+ Error fError;
SkTDStack<SkOperand2> fRunStack;
SkLongArray(SkOpArray*) fTrackArray;
SkTDStringArray fTrackString;
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index cf3b5309c4..fc2e48a395 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -14,7 +14,6 @@
#include "SkDrawable.h"
#include "SkDrawFilter.h"
#include "SkDrawLooper.h"
-#include "SkErrorInternals.h"
#include "SkImage.h"
#include "SkImage_Base.h"
#include "SkImageFilter.h"
@@ -1263,8 +1262,6 @@ void SkCanvas::internalSaveLayer(const SaveLayerRec& rec, SaveLayerStrategy stra
preserveLCDText);
newDevice.reset(priorDevice->onCreateDevice(createInfo, paint));
if (!newDevice) {
- SkErrorInternals::SetError(kInternalError_SkError,
- "Unable to create device for layer.");
return;
}
}
diff --git a/src/core/SkError.cpp b/src/core/SkError.cpp
deleted file mode 100644
index 96bda7ebf4..0000000000
--- a/src/core/SkError.cpp
+++ /dev/null
@@ -1,130 +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 "SkTLS.h"
-#include "SkTypes.h"
-#include "SkError.h"
-#include "SkErrorInternals.h"
-
-#include <stdio.h>
-#include <stdarg.h>
-
-namespace {
-void *CreateThreadError() { return new SkError(kNoError_SkError); }
-void DeleteThreadError(void *v) { delete reinterpret_cast<SkError *>(v); }
- #define THREAD_ERROR \
- (*reinterpret_cast<SkError*>(SkTLS::Get(CreateThreadError, DeleteThreadError)))
-
- void *CreateThreadErrorCallback() {
- return new SkErrorCallbackFunction(SkErrorInternals::DefaultErrorCallback);
- }
- void DeleteThreadErrorCallback(void* v) {
- delete reinterpret_cast<SkErrorCallbackFunction *>(v);
- }
-
- #define THREAD_ERROR_CALLBACK \
- *(reinterpret_cast<SkErrorCallbackFunction *>(SkTLS::Get(CreateThreadErrorCallback, \
- DeleteThreadErrorCallback)))
-
- void *CreateThreadErrorContext() { return new void **(nullptr); }
- void DeleteThreadErrorContext(void *v) { delete reinterpret_cast<void **>(v); }
- #define THREAD_ERROR_CONTEXT \
- (*reinterpret_cast<void **>(SkTLS::Get(CreateThreadErrorContext, DeleteThreadErrorContext)))
-
- #define ERROR_STRING_LENGTH 2048
-
- void *CreateThreadErrorString() { return new char[(ERROR_STRING_LENGTH)]; }
- void DeleteThreadErrorString(void *v) { delete[] reinterpret_cast<char *>(v); }
- #define THREAD_ERROR_STRING \
- (reinterpret_cast<char *>(SkTLS::Get(CreateThreadErrorString, DeleteThreadErrorString)))
-}
-
-SkError SkGetLastError() {
- return SkErrorInternals::GetLastError();
-}
-void SkClearLastError() {
- SkErrorInternals::ClearError();
-}
-void SkSetErrorCallback(SkErrorCallbackFunction cb, void *context) {
- SkErrorInternals::SetErrorCallback(cb, context);
-}
-const char *SkGetLastErrorString() {
- return SkErrorInternals::GetLastErrorString();
-}
-
-// ------------ Private Error functions ---------
-
-void SkErrorInternals::SetErrorCallback(SkErrorCallbackFunction cb, void *context) {
- if (cb == nullptr) {
- THREAD_ERROR_CALLBACK = SkErrorInternals::DefaultErrorCallback;
- } else {
- THREAD_ERROR_CALLBACK = cb;
- }
- THREAD_ERROR_CONTEXT = context;
-}
-
-void SkErrorInternals::DefaultErrorCallback(SkError code, void *context) {
- SkDebugf("Skia Error: %s\n", SkGetLastErrorString());
-}
-
-void SkErrorInternals::ClearError() {
- SkErrorInternals::SetError( kNoError_SkError, "All is well" );
-}
-
-SkError SkErrorInternals::GetLastError() {
- return THREAD_ERROR;
-}
-
-const char *SkErrorInternals::GetLastErrorString() {
- return THREAD_ERROR_STRING;
-}
-
-void SkErrorInternals::SetError(SkError code, const char *fmt, ...) {
- THREAD_ERROR = code;
- va_list args;
-
- char *str = THREAD_ERROR_STRING;
- const char *error_name = nullptr;
- switch( code ) {
- case kNoError_SkError:
- error_name = "No Error";
- break;
- case kInvalidArgument_SkError:
- error_name = "Invalid Argument";
- break;
- case kInvalidOperation_SkError:
- error_name = "Invalid Operation";
- break;
- case kInvalidHandle_SkError:
- error_name = "Invalid Handle";
- break;
- case kInvalidPaint_SkError:
- error_name = "Invalid Paint";
- break;
- case kOutOfMemory_SkError:
- error_name = "Out Of Memory";
- break;
- case kParseError_SkError:
- error_name = "Parse Error";
- break;
- default:
- error_name = "Unknown error";
- break;
- }
-
- snprintf( str, ERROR_STRING_LENGTH, "%s: ", error_name );
- int string_left = SkToInt(ERROR_STRING_LENGTH - strlen(str));
- str += strlen(str);
-
- va_start( args, fmt );
- vsnprintf( str, string_left, fmt, args );
- va_end( args );
- SkErrorCallbackFunction fn = THREAD_ERROR_CALLBACK;
- if (fn && code != kNoError_SkError) {
- fn(code, THREAD_ERROR_CONTEXT);
- }
-}
diff --git a/src/core/SkErrorInternals.h b/src/core/SkErrorInternals.h
deleted file mode 100644
index d573576099..0000000000
--- a/src/core/SkErrorInternals.h
+++ /dev/null
@@ -1,26 +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 SkErrorInternals_DEFINED
-#define SkErrorInternals_DEFINED
-
-#include "SkError.h"
-
-class SkErrorInternals {
-
-public:
- static void ClearError();
- static void SetError(SkError code, const char *fmt, ...);
- static SkError GetLastError();
- static const char *GetLastErrorString();
- static void SetErrorCallback(SkErrorCallbackFunction cb, void *context);
- static void DefaultErrorCallback(SkError code, void *context);
-};
-
-
-
-#endif /* SkErrorInternals_DEFINED */
diff --git a/src/core/SkLightingShader.cpp b/src/core/SkLightingShader.cpp
index 9030a192b4..16b0ddd90d 100644
--- a/src/core/SkLightingShader.cpp
+++ b/src/core/SkLightingShader.cpp
@@ -9,7 +9,6 @@
#include "SkBitmapProcState.h"
#include "SkColor.h"
#include "SkEmptyShader.h"
-#include "SkErrorInternals.h"
#include "SkLightingShader.h"
#include "SkMathPriv.h"
#include "SkNormalSource.h"
diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp
index 4c49e6bc12..59b63b82af 100644
--- a/src/core/SkPath.cpp
+++ b/src/core/SkPath.cpp
@@ -8,7 +8,6 @@
#include <cmath>
#include "SkBuffer.h"
#include "SkCubicClipper.h"
-#include "SkErrorInternals.h"
#include "SkGeometry.h"
#include "SkMath.h"
#include "SkPathPriv.h"
@@ -1205,10 +1204,6 @@ void SkPath::addRoundRect(const SkRect& rect, SkScalar rx, SkScalar ry,
assert_known_direction(dir);
if (rx < 0 || ry < 0) {
- SkErrorInternals::SetError( kInvalidArgument_SkError,
- "I got %f and %f as radii to SkPath::AddRoundRect, "
- "but negative radii are not allowed.",
- SkScalarToDouble(rx), SkScalarToDouble(ry) );
return;
}
@@ -1301,7 +1296,7 @@ void SkPath::arcTo(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle,
// We cannot use SkScalarSinCos function in the next line because
// SkScalarSinCos has a threshold *SkScalarNearlyZero*. When sin(startAngle)
// is 0 and sweepAngle is very small and radius is huge, the expected
- // behavior here is to draw a line. But calling SkScalarSinCos will
+ // behavior here is to draw a line. But calling SkScalarSinCos will
// make sin(endAngle) to be 0 which will then draw a dot.
singlePt.set(oval.centerX() + radiusX * sk_float_cos(endAngle),
oval.centerY() + radiusY * sk_float_sin(endAngle));
diff --git a/src/core/SkReadBuffer.cpp b/src/core/SkReadBuffer.cpp
index 7679622c58..fc818e1f2f 100644
--- a/src/core/SkReadBuffer.cpp
+++ b/src/core/SkReadBuffer.cpp
@@ -7,7 +7,6 @@
#include "SkBitmap.h"
#include "SkDeduper.h"
-#include "SkErrorInternals.h"
#include "SkImage.h"
#include "SkImageDeserializer.h"
#include "SkImageGenerator.h"
@@ -31,7 +30,7 @@ namespace {
return SkImage::MakeFromGenerator(
new EmptyImageGenerator(SkImageInfo::MakeN32Premul(width, height)));
}
-
+
} // anonymous namespace
@@ -225,9 +224,7 @@ sk_sp<SkImage> SkReadBuffer::readBitmapAsImage() {
if (this->readBool()) {
this->readUInt(); // Bitmap index
this->readUInt(); // Bitmap generation ID
- SkErrorInternals::SetError(kParseError_SkError, "SkWriteBuffer::writeBitmap "
- "stored the SkBitmap in an SkBitmapHeap, but "
- "that feature is no longer supported.");
+ // Old unsupported SkBitmapHeap format. No longer supported.
} else {
// The writer stored false, meaning the SkBitmap was not stored in an SkBitmapHeap.
const size_t length = this->readUInt();
@@ -246,13 +243,11 @@ sk_sp<SkImage> SkReadBuffer::readBitmapAsImage() {
return image;
}
- // This bitmap was encoded when written, but we are unable to decode, possibly due to
- // not having a decoder.
- SkErrorInternals::SetError(kParseError_SkError,
- "Could not decode bitmap. Resulting bitmap will be empty.");
- // Even though we weren't able to decode the pixels, the readbuffer should still be
- // intact, so we return true with an empty bitmap, so we don't force an abort of the
- // larger deserialize.
+ // This bitmap was encoded when written, but we are unable to
+ // decode, possibly due to not having a decoder. Even though we
+ // weren't able to decode the pixels, the readbuffer should still
+ // be intact, so we return true with an empty bitmap, so we don't
+ // force an abort of the larger deserialize.
return MakeEmptyImage(width, height);
} else {
SkBitmap bitmap;
@@ -315,7 +310,7 @@ sk_sp<SkTypeface> SkReadBuffer::readTypeface() {
if (fInflator) {
return sk_ref_sp(fInflator->getTypeface(this->read32()));
}
-
+
uint32_t index = fReader.readU32();
if (0 == index || index > (unsigned)fTFCount) {
return nullptr;
diff --git a/src/core/SkValidatingReadBuffer.cpp b/src/core/SkValidatingReadBuffer.cpp
index e1b84d597f..13c54c4910 100644
--- a/src/core/SkValidatingReadBuffer.cpp
+++ b/src/core/SkValidatingReadBuffer.cpp
@@ -6,7 +6,6 @@
*/
#include "SkBitmap.h"
-#include "SkErrorInternals.h"
#include "SkValidatingReadBuffer.h"
#include "SkStream.h"
#include "SkTypeface.h"
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index d4d361d4fb..0957412697 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -17,7 +17,6 @@
#include "SkCanvasPriv.h"
#include "SkDraw.h"
-#include "SkErrorInternals.h"
#include "SkGlyphCache.h"
#include "SkGr.h"
#include "SkGrPriv.h"
@@ -242,7 +241,7 @@ void SkGpuDevice::replaceDrawContext(bool shouldRetainContent) {
SkBudgeted budgeted = fDrawContext->drawContextPriv().isBudgeted();
- sk_sp<GrDrawContext> newDC(MakeDrawContext(this->context(),
+ sk_sp<GrDrawContext> newDC(MakeDrawContext(this->context(),
budgeted,
this->imageInfo(),
fDrawContext->numColorSamples(),
@@ -1123,7 +1122,7 @@ void SkGpuDevice::drawSprite(const SkDraw& draw, const SkBitmap& bitmap,
}
-void SkGpuDevice::drawSpecial(const SkDraw& draw,
+void SkGpuDevice::drawSpecial(const SkDraw& draw,
SkSpecialImage* special1,
int left, int top,
const SkPaint& paint) {
@@ -1791,10 +1790,7 @@ SkBaseDevice* SkGpuDevice::onCreateDevice(const CreateInfo& cinfo, const SkPaint
kDefault_GrSurfaceOrigin,
&props));
if (!dc) {
- SkErrorInternals::SetError( kInternalError_SkError,
- "---- failed to create gpu device texture [%d %d]\n",
- cinfo.fInfo.width(), cinfo.fInfo.height());
- return nullptr;
+ return nullptr;
}
// Skia's convention is to only clear a device if it is non-opaque.
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index ee4e40a642..8f28d70ac4 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -25,7 +25,6 @@
#include "SkConfig8888.h"
#include "SkCanvas.h"
#include "SkData.h"
-#include "SkErrorInternals.h"
#include "SkMessageBus.h"
#include "SkMipMap.h"
#include "SkPixelRef.h"
@@ -801,10 +800,7 @@ GrTextureParams::FilterMode GrSkFilterQualityToGrFilterMode(SkFilterQuality pain
break;
}
default:
- SkErrorInternals::SetError( kInvalidPaint_SkError,
- "Sorry, I don't understand the filtering "
- "mode you asked for. Falling back to "
- "MIPMaps.");
+ // Should be unreachable. If not, fall back to mipmaps.
textureFilterMode = GrTextureParams::kMipMap_FilterMode;
break;
diff --git a/src/utils/SkCanvasStateUtils.cpp b/src/utils/SkCanvasStateUtils.cpp
index cc8ea43d43..60484a4db1 100644
--- a/src/utils/SkCanvasStateUtils.cpp
+++ b/src/utils/SkCanvasStateUtils.cpp
@@ -10,7 +10,6 @@
#include "SkCanvas.h"
#include "SkCanvasStack.h"
#include "SkDevice.h"
-#include "SkErrorInternals.h"
#include "SkRasterClip.h"
#include "SkWriter32.h"
@@ -202,8 +201,6 @@ SkCanvasState* SkCanvasStateUtils::CaptureCanvasState(SkCanvas* canvas) {
ClipValidator validator;
canvas->replayClips(&validator);
if (validator.failed()) {
- SkErrorInternals::SetError(kInvalidOperation_SkError,
- "CaptureCanvasState does not support canvases with antialiased clips.\n");
return nullptr;
}
diff --git a/tests/CanvasStateTest.cpp b/tests/CanvasStateTest.cpp
index d9abd9d633..890e85d3b8 100644
--- a/tests/CanvasStateTest.cpp
+++ b/tests/CanvasStateTest.cpp
@@ -10,7 +10,6 @@
#include "SkCanvasStateUtils.h"
#include "SkCommandLineFlags.h"
#include "SkDrawFilter.h"
-#include "SkError.h"
#include "SkPaint.h"
#include "SkRRect.h"
#include "SkRect.h"
@@ -293,9 +292,6 @@ DEF_TEST(CanvasState_test_draw_filters, reporter) {
////////////////////////////////////////////////////////////////////////////////
-// we need this function to prevent SkError from printing to stdout
-static void error_callback(SkError code, void* ctx) {}
-
DEF_TEST(CanvasState_test_soft_clips, reporter) {
SkBitmap bitmap;
bitmap.allocN32Pixels(10, 10);
@@ -306,13 +302,8 @@ DEF_TEST(CanvasState_test_soft_clips, reporter) {
canvas.clipRRect(roundRect, SkCanvas::kIntersect_Op, true);
- SkSetErrorCallback(error_callback, nullptr);
-
SkCanvasState* state = SkCanvasStateUtils::CaptureCanvasState(&canvas);
REPORTER_ASSERT(reporter, !state);
-
- REPORTER_ASSERT(reporter, kInvalidOperation_SkError == SkGetLastError());
- SkClearLastError();
}
#ifdef SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG
diff --git a/tests/ErrorTest.cpp b/tests/ErrorTest.cpp
deleted file mode 100644
index 4802d53e14..0000000000
--- a/tests/ErrorTest.cpp
+++ /dev/null
@@ -1,64 +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 "SkError.h"
-#include "SkPath.h"
-#include "SkRect.h"
-#include "Test.h"
-
-typedef struct {
- skiatest::Reporter *fReporter;
- unsigned int *fIntPointer;
-} ErrorContext;
-
-#define CHECK(errcode) \
- REPORTER_ASSERT( reporter, (err = SkGetLastError()) == errcode); \
- if (err != kNoError_SkError) \
- { \
- SkClearLastError(); \
- }
-
-static void cb(SkError err, void *context) {
- ErrorContext *context_ptr = static_cast<ErrorContext *>(context);
- REPORTER_ASSERT( context_ptr->fReporter, (*(context_ptr->fIntPointer) == 0xdeadbeef) );
-}
-
-DEF_TEST(Error, reporter) {
- // Some previous user of this thread may have left an error laying around.
- SkClearLastError();
-
- SkError err;
-
- unsigned int test_value = 0xdeadbeef;
- ErrorContext context;
- context.fReporter = reporter;
- context.fIntPointer = &test_value;
-
- SkSetErrorCallback(cb, &context);
-
- CHECK(kNoError_SkError);
-
- SkRect r = SkRect::MakeWH(50, 100);
- CHECK(kNoError_SkError);
-
- SkPath path;
- path.addRect(r);
- CHECK(kNoError_SkError);
-
- path.addRoundRect(r, 10, 10);
- CHECK(kNoError_SkError);
-
- // should trigger the default error callback, which just prints to the screen.
- path.addRoundRect(r, -10, -10);
- CHECK(kInvalidArgument_SkError);
- CHECK(kNoError_SkError);
-
- // should trigger *our* callback.
- path.addRoundRect(r, -10, -10);
- CHECK(kInvalidArgument_SkError);
- CHECK(kNoError_SkError);
-}
diff --git a/tests/PictureTest.cpp b/tests/PictureTest.cpp
index 5076f5d828..3aca69f4e1 100644
--- a/tests/PictureTest.cpp
+++ b/tests/PictureTest.cpp
@@ -14,7 +14,6 @@
#include "SkDashPathEffect.h"
#include "SkData.h"
#include "SkImageGenerator.h"
-#include "SkError.h"
#include "SkImageEncoder.h"
#include "SkImageGenerator.h"
#include "SkMD5.h"
@@ -635,22 +634,6 @@ static sk_sp<SkData> serialized_picture_from_bitmap(const SkBitmap& bitmap) {
return wStream.detachAsData();
}
-struct ErrorContext {
- int fErrors;
- skiatest::Reporter* fReporter;
-};
-
-static void assert_one_parse_error_cb(SkError error, void* context) {
- ErrorContext* errorContext = static_cast<ErrorContext*>(context);
- errorContext->fErrors++;
- // This test only expects one error, and that is a kParseError. If there are others,
- // there is some unknown problem.
- REPORTER_ASSERT_MESSAGE(errorContext->fReporter, 1 == errorContext->fErrors,
- "This threw more errors than expected.");
- REPORTER_ASSERT_MESSAGE(errorContext->fReporter, kParseError_SkError == error,
- SkGetLastErrorString());
-}
-
static void md5(const SkBitmap& bm, SkMD5::Digest* digest) {
SkAutoLockPixels autoLockPixels(bm);
SkASSERT(bm.getPixels());
@@ -685,16 +668,9 @@ DEF_TEST(Picture_EncodedData, reporter) {
// Now test that a parse error was generated when trying to create a new SkPicture without
// providing a function to decode the bitmap.
- ErrorContext context;
- context.fErrors = 0;
- context.fReporter = reporter;
- SkSetErrorCallback(assert_one_parse_error_cb, &context);
SkMemoryStream pictureStream(std::move(picture1));
- SkClearLastError();
sk_sp<SkPicture> pictureFromStream(SkPicture::MakeFromStream(&pictureStream));
REPORTER_ASSERT(reporter, pictureFromStream.get() != nullptr);
- SkClearLastError();
- SkSetErrorCallback(nullptr, nullptr);
// Test that using the version of CreateFromStream that just takes a stream also decodes the
// bitmap. Drawing this picture should look exactly like the original bitmap.
diff --git a/tests/Test.cpp b/tests/Test.cpp
index dcb08e6bad..37515ddf42 100644
--- a/tests/Test.cpp
+++ b/tests/Test.cpp
@@ -8,7 +8,6 @@
#include "Test.h"
#include "SkCommandLineFlags.h"
-#include "SkError.h"
#include "SkString.h"
#include "SkTime.h"