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

Side by Side Diff: webkit/media/webmediaplayer_impl.cc

Issue 8786013: Replace media::Limits struct with media::limits namespace and update documentation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix logic Created 9 years 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 | Annotate | Revision Log
« no previous file with comments | « webkit/media/audio_decoder.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
502 // Return positive infinity if the resource is unbounded.
503 // http://www.whatwg.org/specs/web-apps/current-work/multipage/video.html#dom- media-duration
504 if (duration == media::kInfiniteDuration)
502 return std::numeric_limits<float>::infinity(); 505 return std::numeric_limits<float>::infinity();
506
503 return static_cast<float>(duration.InSecondsF()); 507 return static_cast<float>(duration.InSecondsF());
504 } 508 }
505 509
506 float WebMediaPlayerImpl::currentTime() const { 510 float WebMediaPlayerImpl::currentTime() const {
507 DCHECK_EQ(main_loop_, MessageLoop::current()); 511 DCHECK_EQ(main_loop_, MessageLoop::current());
508 if (paused_) 512 if (paused_)
509 return static_cast<float>(paused_time_.InSecondsF()); 513 return static_cast<float>(paused_time_.InSecondsF());
510 return static_cast<float>(pipeline_->GetCurrentTime().InSecondsF()); 514 return static_cast<float>(pipeline_->GetCurrentTime().InSecondsF());
511 } 515 }
512 516
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 CGAffineTransform mat = CGContextGetCTM(canvas); 585 CGAffineTransform mat = CGContextGetCTM(canvas);
582 float scale_x = sqrt(mat.a * mat.a + mat.b * mat.b); 586 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); 587 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; 588 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; 589 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)); 590 int scaled_width = static_cast<int>(rect.width * fabs(scale_x));
587 int scaled_height = static_cast<int>(rect.height * fabs(scale_y)); 591 int scaled_height = static_cast<int>(rect.height * fabs(scale_y));
588 592
589 // Make sure we don't create a huge canvas. 593 // Make sure we don't create a huge canvas.
590 // TODO(hclam): Respect the aspect ratio. 594 // TODO(hclam): Respect the aspect ratio.
591 if (scaled_width > static_cast<int>(media::Limits::kMaxCanvas)) 595 if (scaled_width > static_cast<int>(media::limits::kMaxCanvas))
592 scaled_width = media::Limits::kMaxCanvas; 596 scaled_width = media::limits::kMaxCanvas;
593 if (scaled_height > static_cast<int>(media::Limits::kMaxCanvas)) 597 if (scaled_height > static_cast<int>(media::limits::kMaxCanvas))
594 scaled_height = media::Limits::kMaxCanvas; 598 scaled_height = media::limits::kMaxCanvas;
595 599
596 // If there is no preexisting platform canvas, or if the size has 600 // If there is no preexisting platform canvas, or if the size has
597 // changed, recreate the canvas. This is to avoid recreating the bitmap 601 // changed, recreate the canvas. This is to avoid recreating the bitmap
598 // buffer over and over for each frame of video. 602 // buffer over and over for each frame of video.
599 if (!skia_canvas_.get() || 603 if (!skia_canvas_.get() ||
600 skia_canvas_->getDevice()->width() != scaled_width || 604 skia_canvas_->getDevice()->width() != scaled_width ||
601 skia_canvas_->getDevice()->height() != scaled_height) { 605 skia_canvas_->getDevice()->height() != scaled_height) {
602 skia_canvas_.reset( 606 skia_canvas_.reset(
603 new skia::PlatformCanvas(scaled_width, scaled_height, true)); 607 new skia::PlatformCanvas(scaled_width, scaled_height, true));
604 } 608 }
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
913 return client_; 917 return client_;
914 } 918 }
915 919
916 void WebMediaPlayerImpl::IncrementExternallyAllocatedMemory() { 920 void WebMediaPlayerImpl::IncrementExternallyAllocatedMemory() {
917 DCHECK_EQ(main_loop_, MessageLoop::current()); 921 DCHECK_EQ(main_loop_, MessageLoop::current());
918 incremented_externally_allocated_memory_ = true; 922 incremented_externally_allocated_memory_ = true;
919 v8::V8::AdjustAmountOfExternalAllocatedMemory(kPlayerExtraMemory); 923 v8::V8::AdjustAmountOfExternalAllocatedMemory(kPlayerExtraMemory);
920 } 924 }
921 925
922 } // namespace webkit_media 926 } // namespace webkit_media
OLDNEW
« no previous file with comments | « webkit/media/audio_decoder.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698