| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 // Needed on Windows to get |M_PI| from math.h. | 5 // Needed on Windows to get |M_PI| from math.h. |
| 6 #ifdef _WIN32 | 6 #ifdef _WIN32 |
| 7 #define _USE_MATH_DEFINES | 7 #define _USE_MATH_DEFINES |
| 8 #endif | 8 #endif |
| 9 | 9 |
| 10 #include <math.h> | 10 #include <math.h> |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 { | 344 { |
| 345 // Set the stable texture layer | 345 // Set the stable texture layer |
| 346 if (stable_texture_layer_.is_null()) { | 346 if (stable_texture_layer_.is_null()) { |
| 347 stable_texture_layer_ = compositor_.AddLayer(); | 347 stable_texture_layer_ = compositor_.AddLayer(); |
| 348 assert(!stable_texture_layer_.is_null()); | 348 assert(!stable_texture_layer_.is_null()); |
| 349 GLuint texture = PrepareFramebuffer(); | 349 GLuint texture = PrepareFramebuffer(); |
| 350 cube_->UpdateForTimeDelta(0.02f); | 350 cube_->UpdateForTimeDelta(0.02f); |
| 351 cube_->Draw(); | 351 cube_->Draw(); |
| 352 rv = stable_texture_layer_.SetTexture( | 352 rv = stable_texture_layer_.SetTexture( |
| 353 *context_, | 353 *context_, |
| 354 texture, pp::Size(600, 600), | 354 GL_TEXTURE_2D, |
| 355 texture, |
| 356 pp::Size(600, 600), |
| 355 callback_factory_.NewCallback(&DemoInstance::OnTextureReleased, | 357 callback_factory_.NewCallback(&DemoInstance::OnTextureReleased, |
| 356 texture)); | 358 texture)); |
| 357 assert(rv == PP_OK_COMPLETIONPENDING); | 359 assert(rv == PP_OK_COMPLETIONPENDING); |
| 358 rv = stable_texture_layer_.SetPremultipliedAlpha(PP_FALSE); | 360 rv = stable_texture_layer_.SetPremultipliedAlpha(PP_FALSE); |
| 359 assert(rv == PP_OK); | 361 assert(rv == PP_OK); |
| 360 } | 362 } |
| 361 | 363 |
| 362 int32_t delta = 200 * fabsf(factor_sin); | 364 int32_t delta = 200 * fabsf(factor_sin); |
| 363 if (delta != 0) { | 365 if (delta != 0) { |
| 364 int32_t x_y = 25 + delta; | 366 int32_t x_y = 25 + delta; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 390 0.0f, 0.0f, 1.0f, 0.0f, | 392 0.0f, 0.0f, 1.0f, 0.0f, |
| 391 200.0f, 0.0f, 0.0f, 1.0f, | 393 200.0f, 0.0f, 0.0f, 1.0f, |
| 392 }; | 394 }; |
| 393 rv = texture_layer_.SetTransform(transform); | 395 rv = texture_layer_.SetTransform(transform); |
| 394 assert(rv == PP_OK); | 396 assert(rv == PP_OK); |
| 395 } | 397 } |
| 396 | 398 |
| 397 GLuint texture = PrepareFramebuffer(); | 399 GLuint texture = PrepareFramebuffer(); |
| 398 cube_->UpdateForTimeDelta(0.02f); | 400 cube_->UpdateForTimeDelta(0.02f); |
| 399 cube_->Draw(); | 401 cube_->Draw(); |
| 400 rv = texture_layer_.SetTexture(*context_, texture, pp::Size(400, 400), | 402 rv = texture_layer_.SetTexture( |
| 403 *context_, |
| 404 GL_TEXTURE_2D, |
| 405 texture, |
| 406 pp::Size(400, 400), |
| 401 callback_factory_.NewCallback(&DemoInstance::OnTextureReleased, | 407 callback_factory_.NewCallback(&DemoInstance::OnTextureReleased, |
| 402 texture)); | 408 texture)); |
| 403 assert(rv == PP_OK_COMPLETIONPENDING); | 409 assert(rv == PP_OK_COMPLETIONPENDING); |
| 404 rv = texture_layer_.SetPremultipliedAlpha(PP_FALSE); | 410 rv = texture_layer_.SetPremultipliedAlpha(PP_FALSE); |
| 405 assert(rv == PP_OK); | 411 assert(rv == PP_OK); |
| 406 } | 412 } |
| 407 } | 413 } |
| 408 | 414 |
| 409 void DemoInstance::OnTextureReleased(int32_t result, GLuint texture) { | 415 void DemoInstance::OnTextureReleased(int32_t result, GLuint texture) { |
| 410 if (result == PP_OK) { | 416 if (result == PP_OK) { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 436 }; | 442 }; |
| 437 | 443 |
| 438 } // anonymous namespace | 444 } // anonymous namespace |
| 439 | 445 |
| 440 namespace pp { | 446 namespace pp { |
| 441 // Factory function for your specialization of the Module object. | 447 // Factory function for your specialization of the Module object. |
| 442 Module* CreateModule() { | 448 Module* CreateModule() { |
| 443 return new DemoModule(); | 449 return new DemoModule(); |
| 444 } | 450 } |
| 445 } // namespace pp | 451 } // namespace pp |
| OLD | NEW |