OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "webkit/media/webmediaplayer_impl.h" | 5 #include "webkit/media/webmediaplayer_impl.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
491 if (ready_state_ == WebKit::WebMediaPlayer::HaveNothing) | 491 if (ready_state_ == WebKit::WebMediaPlayer::HaveNothing) |
492 return false; | 492 return false; |
493 | 493 |
494 return seeking_; | 494 return seeking_; |
495 } | 495 } |
496 | 496 |
497 float WebMediaPlayerImpl::duration() const { | 497 float WebMediaPlayerImpl::duration() const { |
498 DCHECK_EQ(main_loop_, MessageLoop::current()); | 498 DCHECK_EQ(main_loop_, MessageLoop::current()); |
499 | 499 |
500 base::TimeDelta duration = pipeline_->GetMediaDuration(); | 500 base::TimeDelta duration = pipeline_->GetMediaDuration(); |
501 if (duration.InMicroseconds() == media::Limits::kMaxTimeInMicroseconds) | 501 if (duration.InMicroseconds() == media::limits::kMaxTimeInMicroseconds) |
Ami GONE FROM CHROMIUM
2011/12/03 02:11:38
I *think* this is the only place that cares about
scherkus (not reviewing)
2011/12/06 02:05:57
we use infinity to represent an unbounded stream/d
| |
502 return std::numeric_limits<float>::infinity(); | 502 return std::numeric_limits<float>::infinity(); |
503 return static_cast<float>(duration.InSecondsF()); | 503 return static_cast<float>(duration.InSecondsF()); |
504 } | 504 } |
505 | 505 |
506 float WebMediaPlayerImpl::currentTime() const { | 506 float WebMediaPlayerImpl::currentTime() const { |
507 DCHECK_EQ(main_loop_, MessageLoop::current()); | 507 DCHECK_EQ(main_loop_, MessageLoop::current()); |
508 if (paused_) | 508 if (paused_) |
509 return static_cast<float>(paused_time_.InSecondsF()); | 509 return static_cast<float>(paused_time_.InSecondsF()); |
510 return static_cast<float>(pipeline_->GetCurrentTime().InSecondsF()); | 510 return static_cast<float>(pipeline_->GetCurrentTime().InSecondsF()); |
511 } | 511 } |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
581 CGAffineTransform mat = CGContextGetCTM(canvas); | 581 CGAffineTransform mat = CGContextGetCTM(canvas); |
582 float scale_x = sqrt(mat.a * mat.a + mat.b * mat.b); | 582 float scale_x = sqrt(mat.a * mat.a + mat.b * mat.b); |
583 float scale_y = sqrt(mat.c * mat.c + mat.d * mat.d); | 583 float scale_y = sqrt(mat.c * mat.c + mat.d * mat.d); |
584 float inverse_scale_x = SkScalarNearlyZero(scale_x) ? 0.0f : 1.0f / scale_x; | 584 float inverse_scale_x = SkScalarNearlyZero(scale_x) ? 0.0f : 1.0f / scale_x; |
585 float inverse_scale_y = SkScalarNearlyZero(scale_y) ? 0.0f : 1.0f / scale_y; | 585 float inverse_scale_y = SkScalarNearlyZero(scale_y) ? 0.0f : 1.0f / scale_y; |
586 int scaled_width = static_cast<int>(rect.width * fabs(scale_x)); | 586 int scaled_width = static_cast<int>(rect.width * fabs(scale_x)); |
587 int scaled_height = static_cast<int>(rect.height * fabs(scale_y)); | 587 int scaled_height = static_cast<int>(rect.height * fabs(scale_y)); |
588 | 588 |
589 // Make sure we don't create a huge canvas. | 589 // Make sure we don't create a huge canvas. |
590 // TODO(hclam): Respect the aspect ratio. | 590 // TODO(hclam): Respect the aspect ratio. |
591 if (scaled_width > static_cast<int>(media::Limits::kMaxCanvas)) | 591 if (scaled_width > static_cast<int>(media::limits::kMaxCanvas)) |
592 scaled_width = media::Limits::kMaxCanvas; | 592 scaled_width = media::limits::kMaxCanvas; |
593 if (scaled_height > static_cast<int>(media::Limits::kMaxCanvas)) | 593 if (scaled_height > static_cast<int>(media::limits::kMaxCanvas)) |
594 scaled_height = media::Limits::kMaxCanvas; | 594 scaled_height = media::limits::kMaxCanvas; |
595 | 595 |
596 // If there is no preexisting platform canvas, or if the size has | 596 // If there is no preexisting platform canvas, or if the size has |
597 // changed, recreate the canvas. This is to avoid recreating the bitmap | 597 // changed, recreate the canvas. This is to avoid recreating the bitmap |
598 // buffer over and over for each frame of video. | 598 // buffer over and over for each frame of video. |
599 if (!skia_canvas_.get() || | 599 if (!skia_canvas_.get() || |
600 skia_canvas_->getDevice()->width() != scaled_width || | 600 skia_canvas_->getDevice()->width() != scaled_width || |
601 skia_canvas_->getDevice()->height() != scaled_height) { | 601 skia_canvas_->getDevice()->height() != scaled_height) { |
602 skia_canvas_.reset( | 602 skia_canvas_.reset( |
603 new skia::PlatformCanvas(scaled_width, scaled_height, true)); | 603 new skia::PlatformCanvas(scaled_width, scaled_height, true)); |
604 } | 604 } |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
913 return client_; | 913 return client_; |
914 } | 914 } |
915 | 915 |
916 void WebMediaPlayerImpl::IncrementExternallyAllocatedMemory() { | 916 void WebMediaPlayerImpl::IncrementExternallyAllocatedMemory() { |
917 DCHECK_EQ(main_loop_, MessageLoop::current()); | 917 DCHECK_EQ(main_loop_, MessageLoop::current()); |
918 incremented_externally_allocated_memory_ = true; | 918 incremented_externally_allocated_memory_ = true; |
919 v8::V8::AdjustAmountOfExternalAllocatedMemory(kPlayerExtraMemory); | 919 v8::V8::AdjustAmountOfExternalAllocatedMemory(kPlayerExtraMemory); |
920 } | 920 } |
921 | 921 |
922 } // namespace webkit_media | 922 } // namespace webkit_media |
OLD | NEW |