Explicitly call deprecated AX name calculation API.
[chromium-blink-merge.git] / native_client_sdk / src / examples / demo / flock / sprite.h
blobb846768f56c8ead5919e6ee31d47e9135430e6de
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef SPRITE_H_
6 #define SPRITE_H_
8 #include <vector>
9 #include "ppapi/cpp/point.h"
10 #include "ppapi/cpp/rect.h"
11 #include "ppapi/cpp/size.h"
14 // A Sprite is a simple container of a pixel buffer. It knows how to
15 // composite itself to another pixel buffer of the same format.
16 class Sprite {
17 public:
18 // Initialize a Sprite to use the attached pixel buffer. The Sprite takes
19 // ownership of the pixel buffer, deleting it in the dtor. The pixel
20 // buffer is assumed to be 32-bit ARGB-8-8-8-8 pixel format, with pre-
21 // multiplied alpha. If |row_bytes| is 0, then the number of bytes per row
22 // is assumed to be size.width() * sizeof(uint32_t).
23 Sprite(uint32_t* pixel_buffer, const pp::Size& size, int32_t stride = 0);
25 // Delete the pixel buffer. It is assumed that the pixel buffer was created
26 // using malloc().
27 ~Sprite();
29 // Reset the internal pixel buffer to a new one. Deletes the old pixel
30 // buffer. Sprite takes ownership of the new pixel buffer. If |row_bytes|
31 // is 0, then the number of bytes per row is assumed to be size.width() *
32 // sizeof(uint32_t).
33 void SetPixelBuffer(uint32_t* pixel_buffer,
34 const pp::Size& size,
35 int32_t row_bytes);
37 // Composite the section of the Sprite contained in |src_rect| into the given
38 // pixel buffer at |dest_point|. Performs an average of the source and
39 // dest pixel, and all necessary clipping.
40 void CompositeFromRectToPoint(const pp::Rect& src_rect,
41 uint32_t* dest_pixel_buffer,
42 const pp::Rect& dest_bounds,
43 int32_t dest_row_bytes,
44 const pp::Point& dest_point) const;
46 // Accessors.
47 const pp::Size& size() const {
48 return pixel_buffer_size_;
51 private:
52 uint32_t* pixel_buffer_;
53 pp::Size pixel_buffer_size_;
54 int32_t row_bytes_;
57 #endif // SPRITE_H_