author Phil Ringnalda <>
Wed, 28 Oct 2015 22:57:43 -0700
changeset 270180 b4c323832f317d650acd4bd7066d9432f3c1768c
parent 267658 4d87d0f8b7043cc170e0b8f51e0e612cfdfe1ee4
child 289720 bc854d1c6ab72ffa8ce770a2171e002dfe7231c6
permissions -rw-r--r--
Back out 8 changesets (bug 1207355) for OS X 10.10 reftest failures in generated-content/ CLOSED TREE Backed out changeset aafd6db2fbb4 (bug 1207355) Backed out changeset 9dd950b837fb (bug 1207355) Backed out changeset e941e0e106a1 (bug 1207355) Backed out changeset ecebca101fcb (bug 1207355) Backed out changeset 08f2017137e1 (bug 1207355) Backed out changeset 3dc69e37c9b4 (bug 1207355) Backed out changeset bcdf51edb121 (bug 1207355) Backed out changeset 1d4c00dbf49a (bug 1207355)

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at */

#ifndef mozilla_image_DrawResult_h
#define mozilla_image_DrawResult_h

#include "mozilla/Attributes.h"
#include "mozilla/Likely.h"

namespace mozilla {
namespace image {

 * An enumeration representing the result of a drawing operation.
 * Most users of DrawResult will only be interested in whether the value is
 * SUCCESS or not. The other values are primarily useful for debugging and error
 * handling.
 * SUCCESS: We successfully drew a completely decoded frame of the requested
 * size. Drawing again with FLAG_SYNC_DECODE would not change the result.
 * INCOMPLETE: We successfully drew a frame that was partially decoded. (Note
 * that successfully drawing a partially decoded frame may not actually draw any
 * pixels!) Drawing again with FLAG_SYNC_DECODE would improve the result.
 * WRONG_SIZE: We successfully drew a wrongly-sized frame that had to be scaled.
 * This is only returned if drawing again with FLAG_SYNC_DECODE would improve
 * the result; if the size requested was larger than the intrinsic size of the
 * image, for example, we would generally have to scale whether FLAG_SYNC_DECODE
 * was specified or not, and therefore we would not return WRONG_SIZE.
 * NOT_READY: We failed to draw because no decoded version of the image was
 * available. Drawing again with FLAG_SYNC_DECODE would improve the result.
 * (Though FLAG_SYNC_DECODE will not necessarily work until after the image's
 * load event!)
 * TEMPORARY_ERROR: We failed to draw due to a temporary error. Drawing may
 * succeed at a later time.
 * BAD_IMAGE: We failed to draw because the image has an error. This is a
 * permanent condition.
 * BAD_ARGS: We failed to draw because bad arguments were passed to draw().
enum class DrawResult : uint8_t

 * You can combine DrawResults with &. By analogy to bitwise-&, the result is
 * DrawResult::SUCCESS only if both operands are DrawResult::SUCCESS. Otherwise,
 * a failing DrawResult is returned; we favor the left operand's failure when
 * deciding which failure to return, with the exception that we always prefer
 * any other kind of failure over DrawResult::BAD_IMAGE, since other failures
 * are recoverable and we want to know if any recoverable failures occurred.
inline DrawResult
operator&(const DrawResult aLeft, const DrawResult aRight)
  if (MOZ_LIKELY(aLeft == DrawResult::SUCCESS)) {
    return aRight;
  if (aLeft == DrawResult::BAD_IMAGE && aRight != DrawResult::SUCCESS) {
    return aRight;
  return aLeft;

inline DrawResult&
operator&=(DrawResult& aLeft, const DrawResult aRight)
  aLeft = aLeft & aRight;
  return aLeft;

} // namespace image
} // namespace mozilla

#endif // mozilla_image_DrawResult_h