Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "media/filters/skcanvas_video_renderer.h" | 5 #include "media/filters/skcanvas_video_renderer.h" |
| 6 | 6 |
| 7 #include "gpu/GLES2/gl2extchromium.h" | 7 #include "gpu/GLES2/gl2extchromium.h" |
| 8 #include "gpu/command_buffer/client/gles2_interface.h" | 8 #include "gpu/command_buffer/client/gles2_interface.h" |
| 9 #include "gpu/command_buffer/common/mailbox_holder.h" | 9 #include "gpu/command_buffer/common/mailbox_holder.h" |
| 10 #include "media/base/video_frame.h" | 10 #include "media/base/video_frame.h" |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 422 canvas->drawRect(dest, paint); | 422 canvas->drawRect(dest, paint); |
| 423 canvas->flush(); | 423 canvas->flush(); |
| 424 return; | 424 return; |
| 425 } | 425 } |
| 426 | 426 |
| 427 SkBitmap* target_frame = nullptr; | 427 SkBitmap* target_frame = nullptr; |
| 428 if (canvas->getGrContext()) { | 428 if (canvas->getGrContext()) { |
| 429 if (accelerated_last_frame_.isNull() || | 429 if (accelerated_last_frame_.isNull() || |
| 430 video_frame->timestamp() != accelerated_last_frame_timestamp_) { | 430 video_frame->timestamp() != accelerated_last_frame_timestamp_) { |
| 431 if (video_frame->format() == VideoFrame::NATIVE_TEXTURE) { | 431 if (video_frame->format() == VideoFrame::NATIVE_TEXTURE) { |
| 432 // Draw HW Video on HW Canvas. | |
| 432 DCHECK(context_3d.gl); | 433 DCHECK(context_3d.gl); |
| 433 DCHECK(context_3d.gr_context); | 434 DCHECK(context_3d.gr_context); |
| 434 // Draw HW Video on HW Canvas. | 435 if (accelerated_generator_) { |
| 435 DCHECK(!accelerated_generator_); | 436 // Reset SkBitmap used in SWVideo-to-HWCanvas path. |
| 437 accelerated_last_frame_.reset(); | |
| 438 accelerated_generator_ = nullptr; | |
| 439 } | |
| 436 if (!CopyVideoFrameTextureToSkBitmapTexture( | 440 if (!CopyVideoFrameTextureToSkBitmapTexture( |
| 437 video_frame.get(), &accelerated_last_frame_, context_3d)) { | 441 video_frame.get(), &accelerated_last_frame_, context_3d)) { |
| 438 NOTREACHED(); | 442 NOTREACHED(); |
| 439 return; | 443 return; |
| 440 } | 444 } |
| 441 } else { | 445 } else { |
| 442 // Draw SW Video on HW Canvas. | 446 // Draw SW Video on HW Canvas. |
| 447 if (!accelerated_generator_ && !accelerated_last_frame_.isNull()) { | |
| 448 // Reset SkBitmap used in HWVideo-to-HWCanvas path. | |
| 449 accelerated_last_frame_.reset(); | |
|
DaleCurtis
2015/01/12 20:47:01
Can you explain why you need these conditionals? I
dshwang
2015/01/13 08:38:22
That's good question. It's because allocating acce
| |
| 450 } | |
| 443 accelerated_generator_ = new VideoImageGenerator(video_frame); | 451 accelerated_generator_ = new VideoImageGenerator(video_frame); |
| 444 | 452 |
| 445 // Note: This takes ownership of |accelerated_generator_|. | 453 // Note: This takes ownership of |accelerated_generator_|. |
| 446 if (!SkInstallDiscardablePixelRef(accelerated_generator_, | 454 if (!SkInstallDiscardablePixelRef(accelerated_generator_, |
| 447 &accelerated_last_frame_)) { | 455 &accelerated_last_frame_)) { |
| 448 NOTREACHED(); | 456 NOTREACHED(); |
| 449 return; | 457 return; |
| 450 } | 458 } |
| 451 } | 459 } |
| 452 DCHECK(video_frame->visible_rect().width() == | 460 DCHECK(video_frame->visible_rect().width() == |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 583 last_frame_timestamp_ = media::kNoTimestamp(); | 591 last_frame_timestamp_ = media::kNoTimestamp(); |
| 584 } | 592 } |
| 585 | 593 |
| 586 void SkCanvasVideoRenderer::ResetAcceleratedLastFrame() { | 594 void SkCanvasVideoRenderer::ResetAcceleratedLastFrame() { |
| 587 accelerated_last_frame_.reset(); | 595 accelerated_last_frame_.reset(); |
| 588 accelerated_generator_ = nullptr; | 596 accelerated_generator_ = nullptr; |
| 589 accelerated_last_frame_timestamp_ = media::kNoTimestamp(); | 597 accelerated_last_frame_timestamp_ = media::kNoTimestamp(); |
| 590 } | 598 } |
| 591 | 599 |
| 592 } // namespace media | 600 } // namespace media |
| OLD | NEW |