2013-04-08 21:44:11 +00:00
|
|
|
|
/*
|
|
|
|
|
* Copyright 2013 Google Inc.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
|
* found in the LICENSE file.
|
|
|
|
|
*/
|
2013-04-09 07:01:27 +00:00
|
|
|
|
|
2013-04-08 21:44:11 +00:00
|
|
|
|
#ifndef SkError_DEFINED
|
|
|
|
|
#define SkError_DEFINED
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** \file SkError.h
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
enum SkError {
|
|
|
|
|
/** All is well
|
|
|
|
|
*/
|
2013-08-23 13:43:35 +00:00
|
|
|
|
kNoError_SkError = 0x00,
|
2013-04-09 07:01:27 +00:00
|
|
|
|
|
|
|
|
|
/** User argument passed to Skia function was invalid: NULL when that’s
|
|
|
|
|
* not allowed, out of numeric range, bad enum, or violating some
|
2013-04-08 21:44:11 +00:00
|
|
|
|
* other general precondition.
|
|
|
|
|
*/
|
2013-08-23 13:43:35 +00:00
|
|
|
|
kInvalidArgument_SkError = 0x01,
|
2013-04-09 07:01:27 +00:00
|
|
|
|
|
|
|
|
|
/** 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
|
2013-04-08 21:44:11 +00:00
|
|
|
|
* inset()’ing a rectangle to make it degenerate (negative width/height).
|
|
|
|
|
*/
|
2013-08-23 13:43:35 +00:00
|
|
|
|
kInvalidOperation_SkError = 0x02,
|
2013-04-09 07:01:27 +00:00
|
|
|
|
|
|
|
|
|
/** 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
|
2013-04-08 21:44:11 +00:00
|
|
|
|
* to anticipate this kind of issue.
|
|
|
|
|
*/
|
2013-08-23 13:43:35 +00:00
|
|
|
|
kInvalidHandle_SkError = 0x04,
|
2013-04-09 07:01:27 +00:00
|
|
|
|
|
|
|
|
|
/** This is probably not possible because paint surely has defaults for
|
2013-04-08 21:44:11 +00:00
|
|
|
|
* everything, but perhaps a paint can get into a bad state somehow.
|
|
|
|
|
*/
|
2013-08-23 13:43:35 +00:00
|
|
|
|
kInvalidPaint_SkError = 0x08,
|
2013-04-09 07:01:27 +00:00
|
|
|
|
|
2013-04-08 21:44:11 +00:00
|
|
|
|
/** Skia was unable to allocate memory to perform some task.
|
|
|
|
|
*/
|
2013-08-23 13:43:35 +00:00
|
|
|
|
kOutOfMemory_SkError = 0x10,
|
2013-04-09 07:01:27 +00:00
|
|
|
|
|
2013-04-08 21:44:11 +00:00
|
|
|
|
/** Skia failed while trying to consume some external resource.
|
|
|
|
|
*/
|
2013-08-23 13:43:35 +00:00
|
|
|
|
kParseError_SkError = 0x20
|
2013-04-08 21:44:11 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/** Return the current per-thread error code. Error codes are "sticky"; they
|
|
|
|
|
* are not not reset by subsequent successful operations.
|
2013-04-09 07:01:27 +00:00
|
|
|
|
*/
|
2013-04-08 21:44:11 +00:00
|
|
|
|
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.
|
2013-04-09 07:01:27 +00:00
|
|
|
|
* Callback functions take the error code being set, as well as a context
|
2013-04-08 21:44:11 +00:00
|
|
|
|
* argument that is provided when the callback is registered.
|
|
|
|
|
*/
|
|
|
|
|
typedef void (*SkErrorCallbackFunction)(SkError, void *);
|
|
|
|
|
|
|
|
|
|
/** Set the current per-thread error callback.
|
2013-04-09 07:01:27 +00:00
|
|
|
|
*
|
2013-04-08 21:44:11 +00:00
|
|
|
|
* @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.
|
2013-04-09 07:01:27 +00:00
|
|
|
|
* @param context An arbitrary pointer that will be passed to
|
2013-04-08 21:44:11 +00:00
|
|
|
|
* the provided callback function.
|
|
|
|
|
*/
|
|
|
|
|
void SkSetErrorCallback(SkErrorCallbackFunction cb, void *context);
|
|
|
|
|
|
2013-04-09 07:01:27 +00:00
|
|
|
|
/** 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
|
2013-04-08 21:44:11 +00:00
|
|
|
|
* conditions that led to the error itself.
|
|
|
|
|
*/
|
|
|
|
|
const char *SkGetLastErrorString();
|
|
|
|
|
|
|
|
|
|
#endif /* SkError_DEFINED */
|