This file is indexed.

/usr/include/gnash/ImageIterators.h is in gnash-dev 0.8.11~git20160109-1build1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
// ImageIterators.h: Specialized iterators for image data.
// 
//   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
//   Free Software Foundation, Inc
// 
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
// 
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
//


#ifndef GNASH_IMAGE_ITERATORS_H
#define GNASH_IMAGE_ITERATORS_H

#include <boost/iterator/iterator_facade.hpp>
#include <iterator>
#include <algorithm>

#include "GnashImage.h"

namespace gnash {
namespace image {

/// Adapt a pixel_iterator to use 32-bit values in ARGB byte order.
class ARGB
{
public:

    typedef GnashImage::iterator iterator;

    /// Construct an ARGB pixel helper
    ARGB(iterator& i, ImageType t)
        :
        _it(i),
        _t(t)
    {}

    /// Standard assignment just copies bytes.
    //
    /// Underlying bytes are really in RGBA order, so we use that.
    ARGB& operator=(const ARGB& other) {
        switch (_t) {
            case TYPE_RGBA:
                // RGBA to RGBA
                if (other._t == TYPE_RGBA) {
                    std::copy(other._it, other._it + 4, _it);
                    break;
                }

                // RGB to RGBA
                std::copy(other._it, other._it + 3, _it);
                *(_it + 3) = 0xff;
                break;

            case TYPE_RGB:
                // It doesn't matter what the other image is.
                std::copy(other._it, other._it + 3, _it);

            default:
                break;
        }
        return *this;
    }
    
    /// Writes a 32-bit unsigned value in ARGB byte order to the image
    //
    /// Take note of the different byte order!
    const ARGB& operator=(std::uint32_t pixel) const {
        switch (_t) {
            case TYPE_RGBA:
                // alpha
                *(_it + 3) = (pixel & 0xff000000) >> 24;
            case TYPE_RGB:
                *_it = (pixel & 0x00ff0000) >> 16;
                *(_it + 1) = (pixel & 0x0000ff00) >> 8;
                *(_it + 2) = (pixel & 0x000000ff);
            default:
                break;
        }
        return *this;
    }
    
    /// Convert to uint32_t in ARGB order
    operator std::uint32_t() const {
        std::uint32_t ret = 0xff000000;
        switch (_t) {
            case TYPE_RGBA:
                // alpha
                ret = *(_it + 3) << 24;
            case TYPE_RGB:
                ret |= (*_it << 16 | *(_it + 1) << 8 | *(_it + 2));
            default:
                break;
        }
        return ret;
    }

private:
    iterator& _it;
    const ImageType _t;
};


/// The pixel_iterator class is a pixel-level adaptor for a GnashImage
//
/// Instead of iterating byte-by-byte, this iterator provides access at a
/// whole-pixel level. This makes it possible to assign custom colour values.
//
/// @tparam Pixel       A class that determines the byte order of the colour
///                     value.
template<typename Pixel>
struct pixel_iterator : public boost::iterator_facade<
                            pixel_iterator<Pixel>,
                            const Pixel,
                            std::random_access_iterator_tag>
{

    typedef std::ptrdiff_t difference_type;
    typedef typename Pixel::iterator iterator;

    /// Construct a pixel_iterator
    pixel_iterator(iterator it, ImageType t)
        :
        _it(it),
        _t(t),
        _p(_it, _t)
    {}
    
    /// Copy a pixel_iterator
    pixel_iterator(const pixel_iterator& other)
        :
        _it(other._it),
        _t(other._t),
        _p(_it, _t)
    {}
    
    /// Assign to a pixel_iterator
    pixel_iterator& operator=(const pixel_iterator& other)
    {
        _it = other._it;
        _t = other._t;
        _p = Pixel(_it, _t);
        return *this;
    }
 
private:

    friend class boost::iterator_core_access;

    const Pixel& dereference() const {
        return _p;
    }

    void increment() {
        _it += numChannels(_t);
    }
    
    void decrement() {
        _it -= numChannels(_t);
    }

    bool equal(const pixel_iterator& o) const {
        return o._it == _it;
    }

    difference_type distance_to(const pixel_iterator& o) const {
        return (o._it - _it) / static_cast<int>(numChannels(_t));
    }

    void advance(difference_type n) {
        _it += n * numChannels(_t);
    }

    iterator _it;
    ImageType _t;
    Pixel _p;
};

template<typename T>
pixel_iterator<T>
begin(GnashImage& im)
{
    return pixel_iterator<T>(im.begin(), im.type());
}

template<typename T>
pixel_iterator<T>
end(GnashImage& im)
{
    return pixel_iterator<T>(im.end(), im.type());
}

} // namespace image
} // namespace gnash

#endif