Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(136)

Side by Side Diff: experimental/conways_life/stamp.h

Issue 10928195: First round of dead file removal (Closed) Base URL: https://github.com/samclegg/nativeclient-sdk.git@master
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Native Client 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.
4
5 #ifndef STAMP_H_
6 #define STAMP_H_
7
8 #include <string>
9 #include <vector>
10 #include "ppapi/cpp/point.h"
11 #include "ppapi/cpp/rect.h"
12 #include "ppapi/cpp/size.h"
13
14 namespace life {
15 // A stamp object. This holds a bitmap for an initial-value stamp. Applying
16 // the stamp puts values in the cell bitmap and a pixel buffer. Stamps are
17 // initialized using the .LIF 1.05 format (see:
18 // http://psoup.math.wisc.edu/mcell/ca_files_formats.html). Stamps are always
19 // rectangular, and have minimum dimensions of (3 x 3).
20 class Stamp {
21 public:
22 // Create the default stamp: size of minimum dimensions and all cells alive.
23 Stamp();
24 virtual ~Stamp();
25
26 // Create a stamp using the supplied stamp description. |stamp_desription| is
27 // expressed as a string where each character represents a cell: '*' is a
28 // live cell and '.' is a dead one. A new-line represents the end of arow of
29 // cells. See the .LIF 1.05 format for more details:
30 // http://psoup.math.wisc.edu/mcell/ca_files_formats.html
31 // Returns success.
32 bool InitFromDescription(const std::string& stamp_description);
33
34 // Apply the stamp to the color and cell buffers. The stamp is cropped to
35 // the buffer rectangles. Both the pixel and cell buffer must have the same
36 // dimensions, and are assumed to have matching coordinate systems (that is,
37 // (x, y) in the pixel buffer corresponds to the same location in the cell
38 // buffer).
39 void StampAtPointInBuffers(const pp::Point& point,
40 uint32_t* dest_pixel_buffer,
41 uint8_t* dest_cell_buffer,
42 const pp::Size& buffer_size) const;
43
44 pp::Size size() const {
45 return size_;
46 }
47
48 // The stamp offset represents the origin of the stamp in the stamp's
49 // coordinate system, where (0, 0) is the upper-left corner.
50 pp::Point stamp_offset() const {
51 return stamp_offset_;
52 }
53 void set_stamp_offset(const pp::Point& offset) {
54 stamp_offset_ = offset;
55 }
56
57 private:
58 pp::Size size_;
59 pp::Point stamp_offset_;
60 std::vector<uint32_t> pixel_buffer_;
61 std::vector<uint8_t> cell_buffer_;
62 };
63
64 } // namespace life
65
66 #endif // LIFE_H_
67
OLDNEW
« no previous file with comments | « experimental/conways_life/sounds/doorbell_attrib.txt ('k') | experimental/conways_life/stamp.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698