OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 16 matching lines...) Expand all Loading... |
27 | 27 |
28 #include <stdio.h> | 28 #include <stdio.h> |
29 #include <cmath> | 29 #include <cmath> |
30 #include <limits> | 30 #include <limits> |
31 #include <string> | 31 #include <string> |
32 | 32 |
33 #if defined(INDEPENDENT_PLUGIN) | 33 #if defined(INDEPENDENT_PLUGIN) |
34 #define CHECK(x) | 34 #define CHECK(x) |
35 #else | 35 #else |
36 #include "base/logging.h" | 36 #include "base/logging.h" |
| 37 #include "build/build_config.h" |
37 #include "gpu/command_buffer/client/gles2_demo_cc.h" | 38 #include "gpu/command_buffer/client/gles2_demo_cc.h" |
38 #include "gpu/command_buffer/common/GLES2/gl2.h" | 39 #include <GLES2/gl2.h> // NOLINT |
39 #include "third_party/skia/include/core/SkBitmap.h" | 40 #include "third_party/skia/include/core/SkBitmap.h" |
40 #include "third_party/skia/include/core/SkCanvas.h" | 41 #include "third_party/skia/include/core/SkCanvas.h" |
41 #include "third_party/skia/include/effects/SkGradientShader.h" | 42 #include "third_party/skia/include/effects/SkGradientShader.h" |
42 #endif | 43 #endif |
43 #include "webkit/tools/pepper_test_plugin/event_handler.h" | 44 #include "webkit/tools/pepper_test_plugin/event_handler.h" |
44 #include "webkit/tools/pepper_test_plugin/test_object.h" | 45 #include "webkit/tools/pepper_test_plugin/test_object.h" |
45 | 46 |
46 NPNetscapeFuncs* browser; | 47 NPNetscapeFuncs* browser; |
47 | 48 |
48 namespace { | 49 namespace { |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 device2d_(NULL), | 302 device2d_(NULL), |
302 device3d_(NULL), | 303 device3d_(NULL), |
303 #if !defined(INDEPENDENT_PLUGIN) | 304 #if !defined(INDEPENDENT_PLUGIN) |
304 pgl_context_(NULL), | 305 pgl_context_(NULL), |
305 #endif | 306 #endif |
306 deviceaudio_(NULL) { | 307 deviceaudio_(NULL) { |
307 memset(&context_audio_, 0, sizeof(context_audio_)); | 308 memset(&context_audio_, 0, sizeof(context_audio_)); |
308 } | 309 } |
309 | 310 |
310 PluginObject::~PluginObject() { | 311 PluginObject::~PluginObject() { |
| 312 // TODO(kbr): add audio portion of test |
| 313 #if !defined(OS_MACOSX) |
311 deviceaudio_->destroyContext(npp_, &context_audio_); | 314 deviceaudio_->destroyContext(npp_, &context_audio_); |
| 315 #endif |
312 // FIXME(brettw) destroy the context. | 316 // FIXME(brettw) destroy the context. |
313 browser->releaseobject(test_object_); | 317 browser->releaseobject(test_object_); |
314 } | 318 } |
315 | 319 |
316 // static | 320 // static |
317 NPClass* PluginObject::GetPluginClass() { | 321 NPClass* PluginObject::GetPluginClass() { |
318 return &plugin_class; | 322 return &plugin_class; |
319 } | 323 } |
320 | 324 |
321 namespace { | 325 namespace { |
(...skipping 18 matching lines...) Expand all Loading... |
340 browser->getvalue(npp_, NPNVPepperExtensions, | 344 browser->getvalue(npp_, NPNVPepperExtensions, |
341 reinterpret_cast<void*>(&extensions)); | 345 reinterpret_cast<void*>(&extensions)); |
342 CHECK(extensions); | 346 CHECK(extensions); |
343 } | 347 } |
344 device2d_ = extensions->acquireDevice(npp_, NPPepper2DDevice); | 348 device2d_ = extensions->acquireDevice(npp_, NPPepper2DDevice); |
345 CHECK(device2d_); | 349 CHECK(device2d_); |
346 | 350 |
347 device3d_ = extensions->acquireDevice(npp_, NPPepper3DDevice); | 351 device3d_ = extensions->acquireDevice(npp_, NPPepper3DDevice); |
348 CHECK(device3d_); | 352 CHECK(device3d_); |
349 | 353 |
| 354 // TODO(kbr): add audio portion of test |
| 355 #if !defined(OS_MACOSX) |
350 deviceaudio_ = extensions->acquireDevice(npp_, NPPepperAudioDevice); | 356 deviceaudio_ = extensions->acquireDevice(npp_, NPPepperAudioDevice); |
351 CHECK(deviceaudio_); | 357 CHECK(deviceaudio_); |
| 358 #endif |
352 } | 359 } |
353 | 360 |
354 void PluginObject::SetWindow(const NPWindow& window) { | 361 void PluginObject::SetWindow(const NPWindow& window) { |
355 if (dimensions_ == 2) { | 362 if (dimensions_ == 2) { |
356 width_ = window.width; | 363 width_ = window.width; |
357 height_ = window.height; | 364 height_ = window.height; |
358 | 365 |
359 NPDeviceContext2DConfig config; | 366 NPDeviceContext2DConfig config; |
360 NPDeviceContext2D context; | 367 NPDeviceContext2D context; |
361 device2d_->initializeContext(npp_, &config, &context); | 368 device2d_->initializeContext(npp_, &config, &context); |
(...skipping 20 matching lines...) Expand all Loading... |
382 // Reset the viewport to new window size. | 389 // Reset the viewport to new window size. |
383 pglMakeCurrent(pgl_context_); | 390 pglMakeCurrent(pgl_context_); |
384 glViewport(0, 0, window.width, window.height); | 391 glViewport(0, 0, window.width, window.height); |
385 pglMakeCurrent(NULL); | 392 pglMakeCurrent(NULL); |
386 | 393 |
387 // Schedule the first call to Draw. | 394 // Schedule the first call to Draw. |
388 browser->pluginthreadasynccall(npp_, Draw3DCallback, this); | 395 browser->pluginthreadasynccall(npp_, Draw3DCallback, this); |
389 #endif | 396 #endif |
390 } | 397 } |
391 | 398 |
| 399 // TODO(kbr): put back in audio portion of test |
| 400 #if !defined(OS_MACOSX) |
392 // testing any field would do | 401 // testing any field would do |
393 if (!context_audio_.config.callback) { | 402 if (!context_audio_.config.callback) { |
394 NPDeviceContextAudioConfig cfg; | 403 NPDeviceContextAudioConfig cfg; |
395 cfg.sampleRate = 44100; | 404 cfg.sampleRate = 44100; |
396 cfg.sampleType = NPAudioSampleTypeInt16; | 405 cfg.sampleType = NPAudioSampleTypeInt16; |
397 cfg.outputChannelMap = NPAudioChannelStereo; | 406 cfg.outputChannelMap = NPAudioChannelStereo; |
398 cfg.inputChannelMap = NPAudioChannelNone; | 407 cfg.inputChannelMap = NPAudioChannelNone; |
399 cfg.sampleFrameCount = 2048; | 408 cfg.sampleFrameCount = 2048; |
400 cfg.flags = 0; | 409 cfg.flags = 0; |
401 cfg.callback = &SineWaveCallback<200, int16>; | 410 cfg.callback = &SineWaveCallback<200, int16>; |
402 deviceaudio_->initializeContext(npp_, &cfg, &context_audio_); | 411 deviceaudio_->initializeContext(npp_, &cfg, &context_audio_); |
403 } | 412 } |
| 413 #endif |
404 } | 414 } |
405 | 415 |
406 void PluginObject::Draw3D() { | 416 void PluginObject::Draw3D() { |
407 #if !defined(INDEPENDENT_PLUGIN) | 417 #if !defined(INDEPENDENT_PLUGIN) |
408 // Render some stuff. | 418 // Render some stuff. |
409 pglMakeCurrent(pgl_context_); | 419 pglMakeCurrent(pgl_context_); |
410 GLFromCPPTestFunction(); | 420 GLFromCPPTestFunction(); |
411 pglSwapBuffers(); | 421 pglSwapBuffers(); |
412 pglMakeCurrent(NULL); | 422 pglMakeCurrent(NULL); |
413 | 423 |
414 // Schedule another call to Draw. | 424 // Schedule another call to Draw. |
415 browser->pluginthreadasynccall(npp_, Draw3DCallback, this); | 425 browser->pluginthreadasynccall(npp_, Draw3DCallback, this); |
416 #endif | 426 #endif |
417 } | 427 } |
OLD | NEW |