gfx/skia/trunk/include/core/SkError.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/skia/trunk/include/core/SkError.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,91 @@
     1.4 +/*
     1.5 + * Copyright 2013 Google Inc.
     1.6 + *
     1.7 + * Use of this source code is governed by a BSD-style license that can be
     1.8 + * found in the LICENSE file.
     1.9 + */
    1.10 +
    1.11 +#ifndef SkError_DEFINED
    1.12 +#define SkError_DEFINED
    1.13 +
    1.14 +
    1.15 +/** \file SkError.h
    1.16 +*/
    1.17 +
    1.18 +enum SkError {
    1.19 +    /** All is well
    1.20 +     */
    1.21 +    kNoError_SkError=0,
    1.22 +
    1.23 +    /** User argument passed to Skia function was invalid: NULL when that’s
    1.24 +     *  not allowed, out of numeric range, bad enum, or violating some
    1.25 +     *  other general precondition.
    1.26 +     */
    1.27 +    kInvalidArgument_SkError,
    1.28 +
    1.29 +    /** User tried to perform some operation in a state when the operation
    1.30 +     *  was not legal, or the operands make no sense (e.g., asking for
    1.31 +     *  pixels from an SkPictureCanvas).  Other examples might be
    1.32 +     *  inset()’ing a rectangle to make it degenerate (negative width/height).
    1.33 +     */
    1.34 +    kInvalidOperation_SkError,
    1.35 +
    1.36 +    /** Probably not needed right now, but in the future we could have opaque
    1.37 +     *  handles for SkPictures floating around, and it would be a good idea
    1.38 +     *  to anticipate this kind of issue.
    1.39 +     */
    1.40 +    kInvalidHandle_SkError,
    1.41 +
    1.42 +    /** This is probably not possible because paint surely has defaults for
    1.43 +     *  everything, but perhaps a paint can get into a bad state somehow.
    1.44 +     */
    1.45 +    kInvalidPaint_SkError,
    1.46 +
    1.47 +    /** Skia was unable to allocate memory to perform some task.
    1.48 +     */
    1.49 +    kOutOfMemory_SkError,
    1.50 +
    1.51 +    /** Skia failed while trying to consume some external resource.
    1.52 +     */
    1.53 +    kParseError_SkError,
    1.54 +
    1.55 +    /** Something went wrong internally; could be resource exhaustion but
    1.56 +      * will often be a bug.
    1.57 +     */
    1.58 +    kInternalError_SkError
    1.59 +};
    1.60 +
    1.61 +/** Return the current per-thread error code.  Error codes are "sticky"; they
    1.62 + *  are not not reset by subsequent successful operations.
    1.63 + */
    1.64 +SkError SkGetLastError();
    1.65 +
    1.66 +/** Clear the current per-thread error code back to kNoError_SkError.
    1.67 + */
    1.68 +void SkClearLastError();
    1.69 +
    1.70 +/** Type for callback functions to be invoked whenever an error is registered.
    1.71 + *  Callback functions take the error code being set, as well as a context
    1.72 + *  argument that is provided when the callback is registered.
    1.73 + */
    1.74 +typedef void (*SkErrorCallbackFunction)(SkError, void *);
    1.75 +
    1.76 +/** Set the current per-thread error callback.
    1.77 + *
    1.78 + *  @param cb The callback function to be invoked.  Passing NULL
    1.79 + *            for cb will revert to the default error callback which
    1.80 + *            does nothing on release builds, but on debug builds will
    1.81 + *            print an informative error message to the screen.
    1.82 + *  @param context An arbitrary pointer that will be passed to
    1.83 + *                 the provided callback function.
    1.84 + */
    1.85 +void SkSetErrorCallback(SkErrorCallbackFunction cb, void *context);
    1.86 +
    1.87 +/** Get a human-readable description of the last (per-thread) error that
    1.88 + *  occurred.  The returned error message will include not only a human
    1.89 + *  readable version of the error code, but also information about the
    1.90 + *  conditions that led to the error itself.
    1.91 + */
    1.92 +const char *SkGetLastErrorString();
    1.93 +
    1.94 +#endif /* SkError_DEFINED */

mercurial