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.
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.
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
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() *
33 void SetPixelBuffer(uint32_t* pixel_buffer
,
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;
47 const pp::Size
& size() const {
48 return pixel_buffer_size_
;
52 uint32_t* pixel_buffer_
;
53 pp::Size pixel_buffer_size_
;