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

Unified Diff: native_client_sdk/src/examples/pong/view.cc

Issue 9383038: Build cleanups (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 10 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 | « native_client_sdk/src/examples/dlopen/dlopen.cc ('k') | native_client_sdk/src/tools/oshelpers.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: native_client_sdk/src/examples/pong/view.cc
===================================================================
--- native_client_sdk/src/examples/pong/view.cc (revision 121652)
+++ native_client_sdk/src/examples/pong/view.cc (working copy)
@@ -75,6 +75,7 @@
// Clear the buffer
const int32_t height = pixel_buffer_->size().height();
const int32_t width = pixel_buffer_->size().width();
+ const float radius2 = (ball_rect_.width() / 2) * (ball_rect_.width() / 2);
for (int32_t py = 0; py < height; ++py) {
for (int32_t px = 0; px < width; ++px) {
const int32_t pos = px + py * width;
@@ -85,13 +86,11 @@
color |= kWhiteMask;
} else {
pp::Point center_point = ball_rect_.CenterPoint();
- float radius = ball_rect_.width() / 2;
float distance_x = px - center_point.x();
float distance_y = py - center_point.y();
- float distance =
- sqrt(distance_x * distance_x + distance_y * distance_y);
+ float distance2 = distance_x * distance_x + distance_y * distance_y;
// Draw the ball
- if (distance <= radius)
+ if (distance2 <= radius2)
color |= kWhiteMask;
}
pixels[pos] = color;
« no previous file with comments | « native_client_sdk/src/examples/dlopen/dlopen.cc ('k') | native_client_sdk/src/tools/oshelpers.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698