framebuffer.cc (10907:94d5a1476c5b) framebuffer.cc (12366:3b4b6fa339a9)
1/*
2 * Copyright (c) 2015 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software

--- 27 unchanged lines hidden (view full) ---

36 *
37 * Authors: Andreas Sandberg
38 */
39
40#include "base/framebuffer.hh"
41
42#include <zlib.h>
43
1/*
2 * Copyright (c) 2015 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software

--- 27 unchanged lines hidden (view full) ---

36 *
37 * Authors: Andreas Sandberg
38 */
39
40#include "base/framebuffer.hh"
41
42#include <zlib.h>
43
44#include <cassert>
45
46#include "base/bitfield.hh"
47
44#include "base/bitfield.hh"
45
48const PixelConverter PixelConverter::rgba8888_le(4, 0, 8, 16, 8, 8, 8);
49const PixelConverter PixelConverter::rgba8888_be(4, 0, 8, 16, 8, 8, 8,
50 BigEndianByteOrder);
51const PixelConverter PixelConverter::rgb565_le(2, 0, 5, 11, 5, 6, 5);
52const PixelConverter PixelConverter::rgb565_be(2, 0, 5, 11, 5, 6, 5,
53 BigEndianByteOrder);
54
55const FrameBuffer FrameBuffer::dummy(320, 240);
56
46const FrameBuffer FrameBuffer::dummy(320, 240);
47
57PixelConverter::PixelConverter(unsigned _length,
58 unsigned ro, unsigned go, unsigned bo,
59 unsigned rw, unsigned gw, unsigned bw,
60 ByteOrder _byte_order)
61 : length(_length),
62 depth(rw + gw + bw),
63 byte_order(_byte_order),
64 ch_r(ro, rw),
65 ch_g(go, gw),
66 ch_b(bo, bw)
67{
68 assert(length > 1);
69}
70
71PixelConverter::Channel::Channel(unsigned _offset, unsigned width)
72 : offset(_offset),
73 mask(::mask(width)),
74 factor(255.0 / mask)
75{
76}
77
78uint32_t
79PixelConverter::readWord(const uint8_t *p) const
80{
81 uint32_t word(0);
82
83 if (byte_order == LittleEndianByteOrder) {
84 for (int i = 0; i < length; ++i)
85 word |= p[i] << (8 * i);
86 } else {
87 for (int i = 0; i < length; ++i)
88 word |= p[i] << (8 * (length - i - 1));
89 }
90
91 return word;
92}
93
94void
95PixelConverter::writeWord(uint8_t *p, uint32_t word) const
96{
97 if (byte_order == LittleEndianByteOrder) {
98 for (int i = 0; i < length; ++i)
99 p[i] = (word >> (8 * i)) & 0xFF;
100 } else {
101 for (int i = 0; i < length; ++i)
102 p[i] = (word >> (8 * (length - i - 1))) & 0xFF;
103 }
104}
105
106
107
108
109FrameBuffer::FrameBuffer(unsigned width, unsigned height)
110 : pixels(width * height),
111 _width(width), _height(height)
112{
113 clear();
114}
115
116FrameBuffer::FrameBuffer()

--- 74 unchanged lines hidden ---
48FrameBuffer::FrameBuffer(unsigned width, unsigned height)
49 : pixels(width * height),
50 _width(width), _height(height)
51{
52 clear();
53}
54
55FrameBuffer::FrameBuffer()

--- 74 unchanged lines hidden ---