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

Side by Side Diff: native_client_sdk/src/examples/demo/life/life.c

Issue 23072027: Merge 217400 "Change ppapi_simple to support pixel format select..." (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1599/src/
Patch Set: Created 7 years, 4 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 | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
1 /* Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 /* Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be 2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file. 3 * found in the LICENSE file.
4 */ 4 */
5 5
6 #include <assert.h> 6 #include <assert.h>
7 #include <stdio.h> 7 #include <stdio.h>
8 #include <stdlib.h> 8 #include <stdlib.h>
9 #include <string.h> 9 #include <string.h>
10 10
(...skipping 24 matching lines...) Expand all
35 PP_Resource ctx; 35 PP_Resource ctx;
36 struct PP_Size size; 36 struct PP_Size size;
37 int bound; 37 int bound;
38 uint8_t* cell_in; 38 uint8_t* cell_in;
39 uint8_t* cell_out; 39 uint8_t* cell_out;
40 } g_Context; 40 } g_Context;
41 41
42 42
43 const unsigned int kInitialRandSeed = 0xC0DE533D; 43 const unsigned int kInitialRandSeed = 0xC0DE533D;
44 44
45 #define MakeRGBA(r, g, b, a) \ 45 /* BGRA helper macro, for constructing a pixel for a BGRA buffer. */
46 #define MakeBGRA(b, g, r, a) \
46 (((a) << 24) | ((r) << 16) | ((g) << 8) | (b)) 47 (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
47 48
48 49
49 /* 50 /*
50 * Given a count of cells in a 3x3 grid where cells are worth 1 except for 51 * Given a count of cells in a 3x3 grid where cells are worth 1 except for
51 * the center which is worth 9, this is a color representation of how 52 * the center which is worth 9, this is a color representation of how
52 * "alive" that cell is making for a more interesting representation than 53 * "alive" that cell is making for a more interesting representation than
53 * a binary alive or dead. 54 * a binary alive or dead.
54 */ 55 */
55 const uint32_t kNeighborColors[] = { 56 const uint32_t kNeighborColors[] = {
56 MakeRGBA(0x00, 0x00, 0x00, 0xff), 57 MakeBGRA(0x00, 0x00, 0x00, 0xff),
57 MakeRGBA(0x00, 0x40, 0x00, 0xff), 58 MakeBGRA(0x00, 0x40, 0x00, 0xff),
58 MakeRGBA(0x00, 0x60, 0x00, 0xff), 59 MakeBGRA(0x00, 0x60, 0x00, 0xff),
59 MakeRGBA(0x00, 0x80, 0x00, 0xff), 60 MakeBGRA(0x00, 0x80, 0x00, 0xff),
60 MakeRGBA(0x00, 0xA0, 0x00, 0xff), 61 MakeBGRA(0x00, 0xA0, 0x00, 0xff),
61 MakeRGBA(0x00, 0xC0, 0x00, 0xff), 62 MakeBGRA(0x00, 0xC0, 0x00, 0xff),
62 MakeRGBA(0x00, 0xE0, 0x00, 0xff), 63 MakeBGRA(0x00, 0xE0, 0x00, 0xff),
63 MakeRGBA(0x00, 0x00, 0x00, 0xff), 64 MakeBGRA(0x00, 0x00, 0x00, 0xff),
64 MakeRGBA(0x00, 0x40, 0x00, 0xff), 65 MakeBGRA(0x00, 0x40, 0x00, 0xff),
65 MakeRGBA(0x00, 0x60, 0x00, 0xff), 66 MakeBGRA(0x00, 0x60, 0x00, 0xff),
66 MakeRGBA(0x00, 0x80, 0x00, 0xff), 67 MakeBGRA(0x00, 0x80, 0x00, 0xff),
67 MakeRGBA(0x00, 0xA0, 0x00, 0xff), 68 MakeBGRA(0x00, 0xA0, 0x00, 0xff),
68 MakeRGBA(0x00, 0xC0, 0x00, 0xff), 69 MakeBGRA(0x00, 0xC0, 0x00, 0xff),
69 MakeRGBA(0x00, 0xE0, 0x00, 0xff), 70 MakeBGRA(0x00, 0xE0, 0x00, 0xff),
70 MakeRGBA(0x00, 0xFF, 0x00, 0xff), 71 MakeBGRA(0x00, 0xFF, 0x00, 0xff),
71 MakeRGBA(0x00, 0xFF, 0x00, 0xff), 72 MakeBGRA(0x00, 0xFF, 0x00, 0xff),
72 MakeRGBA(0x00, 0xFF, 0x00, 0xff), 73 MakeBGRA(0x00, 0xFF, 0x00, 0xff),
73 MakeRGBA(0x00, 0xFF, 0x00, 0xff), 74 MakeBGRA(0x00, 0xFF, 0x00, 0xff),
74 }; 75 };
75 76
76 /* 77 /*
77 * These represent the new health value of a cell based on its neighboring 78 * These represent the new health value of a cell based on its neighboring
78 * values. The health is binary: either alive or dead. 79 * values. The health is binary: either alive or dead.
79 */ 80 */
80 const uint8_t kIsAlive[] = { 81 const uint8_t kIsAlive[] = {
81 0, 0, 0, 1, 0, 0, 0, 0, 0, /* Values if the center cell is dead. */ 82 0, 0, 0, 1, 0, 0, 0, 0, 0, /* Values if the center cell is dead. */
82 0, 0, 1, 1, 0, 0, 0, 0, 0 /* Values if the center cell is alive. */ 83 0, 0, 1, 1, 0, 0, 0, 0, 0 /* Values if the center cell is alive. */
83 }; 84 };
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 } 297 }
297 } 298 }
298 return 0; 299 return 0;
299 } 300 }
300 301
301 /* 302 /*
302 * Register the function to call once the Instance Object is initialized. 303 * Register the function to call once the Instance Object is initialized.
303 * see: pappi_simple/ps_main.h 304 * see: pappi_simple/ps_main.h
304 */ 305 */
305 PPAPI_SIMPLE_REGISTER_MAIN(example_main); 306 PPAPI_SIMPLE_REGISTER_MAIN(example_main);
OLDNEW
« no previous file with comments | « native_client_sdk/src/examples/demo/flock/flock.cc ('k') | native_client_sdk/src/examples/demo/pi_generator/pi_generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698