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

Unified Diff: native_client_sdk/src/examples/demo/earth/earth.cc

Issue 22824010: Change ppapi_simple to support pixel format selection. (Closed) Base URL: svn://chrome-svn/chrome/trunk/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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | native_client_sdk/src/examples/demo/flock/flock.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: native_client_sdk/src/examples/demo/earth/earth.cc
===================================================================
--- native_client_sdk/src/examples/demo/earth/earth.cc (revision 217039)
+++ native_client_sdk/src/examples/demo/earth/earth.cc (working copy)
@@ -60,7 +60,7 @@
return 0.0;
}
-// RGBA helper functions.
+// RGBA helper functions, used for extracting color from RGBA source image.
inline float ExtractR(uint32_t c) {
return static_cast<float>(c & 0xFF) * kOneOver255;
}
@@ -73,7 +73,8 @@
return static_cast<float>((c & 0xFF0000) >> 16) * kOneOver255;
}
-inline uint32_t MakeRGBA(uint32_t r, uint32_t g, uint32_t b, uint32_t a) {
+// BGRA helper function, for constructing a pixel for a BGRA buffer.
+inline uint32_t MakeBGRA(uint32_t b, uint32_t g, uint32_t r, uint32_t a) {
return (((a) << 24) | ((r) << 16) | ((g) << 8) | (b));
}
@@ -353,7 +354,7 @@
// By default, render from the dispatch thread.
workers_ = new ThreadPool(num_threads_);
PSEventSetFilter(PSE_ALL);
- ps_context_ = PSContext2DAllocate();
+ ps_context_ = PSContext2DAllocate(PP_IMAGEDATAFORMAT_BGRA_PREMUL);
}
Planet::~Planet() {
@@ -382,7 +383,7 @@
void Planet::wRenderPixelSpan(int x0, int x1, int y) {
if (!base_tex_ || !night_tex_)
return;
- const int kColorBlack = MakeRGBA(0, 0, 0, 0xFF);
+ const int kColorBlack = MakeBGRA(0, 0, 0, 0xFF);
float width = ps_context_->width;
float height = ps_context_->height;
float min_dim = width < height ? width : height;
@@ -495,7 +496,7 @@
unsigned int ig = Clamp255(pg * tg + ng * ipg);
unsigned int ib = Clamp255(pb * tb + nb * ipb);
- unsigned int color = MakeRGBA(ir, ig, ib, 0xFF);
+ unsigned int color = MakeBGRA(ib, ig, ir, 0xFF);
*pixels = color;
++pixels;
« no previous file with comments | « no previous file | native_client_sdk/src/examples/demo/flock/flock.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698