gfx/skia/trunk/src/core/SkAlphaRuns.cpp

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     2 /*
     3  * Copyright 2006 The Android Open Source Project
     4  *
     5  * Use of this source code is governed by a BSD-style license that can be
     6  * found in the LICENSE file.
     7  */
    10 #include "SkAntiRun.h"
    11 #include "SkUtils.h"
    13 void SkAlphaRuns::reset(int width) {
    14     SkASSERT(width > 0);
    16 #ifdef SK_DEBUG
    17     sk_memset16((uint16_t*)fRuns, (uint16_t)(-42), width);
    18 #endif
    19     fRuns[0] = SkToS16(width);
    20     fRuns[width] = 0;
    21     fAlpha[0] = 0;
    23     SkDEBUGCODE(fWidth = width;)
    24     SkDEBUGCODE(this->validate();)
    25 }
    27 #ifdef SK_DEBUG
    28     void SkAlphaRuns::assertValid(int y, int maxStep) const {
    29         int max = (y + 1) * maxStep - (y == maxStep - 1);
    31         const int16_t* runs = fRuns;
    32         const uint8_t*   alpha = fAlpha;
    34         while (*runs) {
    35             SkASSERT(*alpha <= max);
    36             alpha += *runs;
    37             runs += *runs;
    38         }
    39     }
    41     void SkAlphaRuns::dump() const {
    42         const int16_t* runs = fRuns;
    43         const uint8_t* alpha = fAlpha;
    45         SkDebugf("Runs");
    46         while (*runs) {
    47             int n = *runs;
    49             SkDebugf(" %02x", *alpha);
    50             if (n > 1) {
    51                 SkDebugf(",%d", n);
    52             }
    53             alpha += n;
    54             runs += n;
    55         }
    56         SkDebugf("\n");
    57     }
    59     void SkAlphaRuns::validate() const {
    60         SkASSERT(fWidth > 0);
    62         int         count = 0;
    63         const int16_t*  runs = fRuns;
    65         while (*runs) {
    66             SkASSERT(*runs > 0);
    67             count += *runs;
    68             SkASSERT(count <= fWidth);
    69             runs += *runs;
    70         }
    71         SkASSERT(count == fWidth);
    72     }
    73 #endif

mercurial