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

Side by Side Diff: third_party/WebKit/Source/modules/webaudio/AudioParam.cpp

Issue 2789883002: setValueCurveAtTime takes sequence<float> for curve (Closed)
Patch Set: Rebaseline test results Created 3 years, 8 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google 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 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 ExceptionState& exception_state) { 462 ExceptionState& exception_state) {
463 WarnIfOutsideRange("setTargetAtTime value", target); 463 WarnIfOutsideRange("setTargetAtTime value", target);
464 Handler().Timeline().SetTargetAtTime(target, time, time_constant, 464 Handler().Timeline().SetTargetAtTime(target, time, time_constant,
465 exception_state); 465 exception_state);
466 466
467 // Don't update the histogram here. It's not clear in normal usage if the 467 // Don't update the histogram here. It's not clear in normal usage if the
468 // parameter value will actually reach |target|. 468 // parameter value will actually reach |target|.
469 return this; 469 return this;
470 } 470 }
471 471
472 AudioParam* AudioParam::setValueCurveAtTime(NotShared<DOMFloat32Array> curve, 472 AudioParam* AudioParam::setValueCurveAtTime(const Vector<float>& curve,
473 double time, 473 double time,
474 double duration, 474 double duration,
475 ExceptionState& exception_state) { 475 ExceptionState& exception_state) {
476 float* curve_data = curve.View()->Data();
477 float min = minValue(); 476 float min = minValue();
478 float max = maxValue(); 477 float max = maxValue();
479 478
480 // First, find any non-finite value in the curve and throw an exception if 479 // Find the first value in the curve (if any) that is outside the
481 // there are any. 480 // nominal range. It's probably not necessary to produce a warning
482 for (unsigned k = 0; k < curve.View()->length(); ++k) { 481 // on every value outside the nominal range.
483 float value = curve_data[k]; 482 for (unsigned k = 0; k < curve.size(); ++k) {
484 483 float value = curve[k];
485 if (!std::isfinite(value)) {
486 exception_state.ThrowDOMException(
487 kV8TypeError, "The provided float value for the curve at element " +
488 String::Number(k) +
489 " is non-finite: " + String::Number(value));
490 return nullptr;
491 }
492 }
493
494 // Second, find the first value in the curve (if any) that is outside the
495 // nominal range. It's probably not necessary to produce a warning on every
496 // value outside the nominal range.
497 for (unsigned k = 0; k < curve.View()->length(); ++k) {
498 float value = curve_data[k];
499 484
500 if (value < min || value > max) { 485 if (value < min || value > max) {
501 WarnIfOutsideRange("setValueCurveAtTime value", value); 486 WarnIfOutsideRange("setValueCurveAtTime value", value);
502 break; 487 break;
503 } 488 }
504 } 489 }
505 490
506 Handler().Timeline().SetValueCurveAtTime(curve.View(), time, duration, 491 Handler().Timeline().SetValueCurveAtTime(curve, time, duration,
507 exception_state); 492 exception_state);
508 493
509 // We could update the histogram with every value in the curve, due to 494 // We could update the histogram with every value in the curve, due to
510 // interpolation, we'll probably be missing many values. So we don't update 495 // interpolation, we'll probably be missing many values. So we don't update
511 // the histogram. setValueCurveAtTime is probably a fairly rare method 496 // the histogram. setValueCurveAtTime is probably a fairly rare method
512 // anyway. 497 // anyway.
513 return this; 498 return this;
514 } 499 }
515 500
516 AudioParam* AudioParam::cancelScheduledValues(double start_time, 501 AudioParam* AudioParam::cancelScheduledValues(double start_time,
517 ExceptionState& exception_state) { 502 ExceptionState& exception_state) {
518 Handler().Timeline().CancelScheduledValues(start_time, exception_state); 503 Handler().Timeline().CancelScheduledValues(start_time, exception_state);
519 return this; 504 return this;
520 } 505 }
521 506
522 AudioParam* AudioParam::cancelAndHoldAtTime(double start_time, 507 AudioParam* AudioParam::cancelAndHoldAtTime(double start_time,
523 ExceptionState& exception_state) { 508 ExceptionState& exception_state) {
524 Handler().Timeline().CancelAndHoldAtTime(start_time, exception_state); 509 Handler().Timeline().CancelAndHoldAtTime(start_time, exception_state);
525 return this; 510 return this;
526 } 511 }
527 512
528 } // namespace blink 513 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/webaudio/AudioParam.h ('k') | third_party/WebKit/Source/modules/webaudio/AudioParam.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698