[M120 Migration][VD] Remove accessing oom_score_adj in zygote process
[platform/framework/web/chromium-efl.git] / printing / image.h
1 // Copyright 2011 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef PRINTING_IMAGE_H_
6 #define PRINTING_IMAGE_H_
7
8 #include <stddef.h>
9 #include <stdint.h>
10
11 #include <vector>
12
13 #include "base/check.h"
14 #include "ui/gfx/geometry/size.h"
15
16 namespace printing {
17
18 // Lightweight raw-bitmap management. The image, once initialized, is immutable.
19 // The only purpose is testing image contents.
20 class Image {
21  public:
22   // Creates an image from raw ARGB pixel data, 32 bits per pixel.
23   Image(gfx::Size size, int line_stride, std::vector<unsigned char> buffer);
24
25   Image(const Image& image);
26   Image& operator=(const Image& image) = delete;
27
28   ~Image();
29
30   bool operator==(const Image& other) const;
31
32   const gfx::Size& size() const { return size_; }
33
34   // Returns the 0x0RGB value of the pixel at the given location.
35   uint32_t Color(uint32_t color) const {
36     return color & 0xFFFFFF;  // Strip out alpha channel.
37   }
38
39   uint32_t pixel_at(int x, int y) const {
40     DCHECK(x >= 0 && x < size_.width());
41     DCHECK(y >= 0 && y < size_.height());
42     const uint32_t* data = reinterpret_cast<const uint32_t*>(&*data_.begin());
43     const uint32_t* data_row = data + y * row_length_ / sizeof(uint32_t);
44     return Color(data_row[x]);
45   }
46
47  private:
48   // Pixel dimensions of the image.
49   const gfx::Size size_;
50
51   // Length of a line in bytes.
52   const int row_length_;
53
54   // Actual bitmap data in arrays of RGBAs (so when loaded as uint32_t, it's
55   // 0xABGR).
56   const std::vector<unsigned char> data_;
57 };
58
59 }  // namespace printing
60
61 #endif  // PRINTING_IMAGE_H_