| 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/blink/skcanvas_video_renderer.h" | 5 #include "media/blink/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" |
| 11 #include "media/base/yuv_convert.h" | 11 #include "media/base/yuv_convert.h" |
| 12 #include "skia/ext/refptr.h" | 12 #include "skia/ext/refptr.h" |
| 13 #include "third_party/libyuv/include/libyuv.h" | 13 #include "third_party/libyuv/include/libyuv.h" |
| 14 #include "third_party/skia/include/core/SkCanvas.h" | 14 #include "third_party/skia/include/core/SkCanvas.h" |
| 15 #include "third_party/skia/include/core/SkImage.h" | 15 #include "third_party/skia/include/core/SkImage.h" |
| 16 #include "third_party/skia/include/core/SkImageGenerator.h" | 16 #include "third_party/skia/include/core/SkImageGenerator.h" |
| 17 #include "third_party/skia/include/gpu/GrContext.h" | 17 #include "third_party/skia/include/gpu/GrContext.h" |
| 18 #include "third_party/skia/include/gpu/GrPaint.h" | 18 #include "third_party/skia/include/gpu/GrPaint.h" |
| 19 #include "third_party/skia/include/gpu/GrTexture.h" | 19 #include "third_party/skia/include/gpu/GrTexture.h" |
| 20 #include "third_party/skia/include/gpu/GrTextureProvider.h" | 20 #include "third_party/skia/include/gpu/GrTextureProvider.h" |
| 21 #include "third_party/skia/include/gpu/SkGr.h" | 21 #include "third_party/skia/include/gpu/SkGr.h" |
| 22 #include "ui/gfx/geometry/rect_f.h" | 22 #include "ui/gfx/geometry/rect_f.h" |
| 23 | 23 |
| 24 // Skia internal format depends on a platform. On Android it is ABGR, on others | 24 // Skia internal format depends on a platform. On Android it is ABGR, on others |
| 25 // it is ARGB. | 25 // it is ARGB. |
| 26 #if SK_B32_SHIFT == 0 && SK_G32_SHIFT == 8 && SK_R32_SHIFT == 16 && \ | 26 #if SK_B32_SHIFT == 0 && SK_G32_SHIFT == 8 && SK_R32_SHIFT == 16 && \ |
| 27 SK_A32_SHIFT == 24 | 27 SK_A32_SHIFT == 24 |
| 28 #define LIBYUV_I420_TO_ARGB libyuv::I420ToARGB | 28 #define LIBYUV_I420_TO_ARGB libyuv::I420ToARGB |
| 29 #define LIBYUV_I422_TO_ARGB libyuv::I422ToARGB | 29 #define LIBYUV_I422_TO_ARGB libyuv::I422ToARGB |
| 30 #define LIBYUV_I444_TO_ARGB libyuv::I444ToARGB |
| 30 #define LIBYUV_I420ALPHA_TO_ARGB libyuv::I420AlphaToARGB | 31 #define LIBYUV_I420ALPHA_TO_ARGB libyuv::I420AlphaToARGB |
| 31 #define LIBYUV_J420_TO_ARGB libyuv::J420ToARGB | 32 #define LIBYUV_J420_TO_ARGB libyuv::J420ToARGB |
| 32 #define LIBYUV_H420_TO_ARGB libyuv::H420ToARGB | 33 #define LIBYUV_H420_TO_ARGB libyuv::H420ToARGB |
| 33 #elif SK_R32_SHIFT == 0 && SK_G32_SHIFT == 8 && SK_B32_SHIFT == 16 && \ | 34 #elif SK_R32_SHIFT == 0 && SK_G32_SHIFT == 8 && SK_B32_SHIFT == 16 && \ |
| 34 SK_A32_SHIFT == 24 | 35 SK_A32_SHIFT == 24 |
| 35 #define LIBYUV_I420_TO_ARGB libyuv::I420ToABGR | 36 #define LIBYUV_I420_TO_ARGB libyuv::I420ToABGR |
| 36 #define LIBYUV_I422_TO_ARGB libyuv::I422ToABGR | 37 #define LIBYUV_I422_TO_ARGB libyuv::I422ToABGR |
| 38 #define LIBYUV_I444_TO_ARGB libyuv::I444ToABGR |
| 37 #define LIBYUV_I420ALPHA_TO_ARGB libyuv::I420AlphaToABGR | 39 #define LIBYUV_I420ALPHA_TO_ARGB libyuv::I420AlphaToABGR |
| 38 #define LIBYUV_J420_TO_ARGB libyuv::J420ToABGR | 40 #define LIBYUV_J420_TO_ARGB libyuv::J420ToABGR |
| 39 #define LIBYUV_H420_TO_ARGB libyuv::H420ToABGR | 41 #define LIBYUV_H420_TO_ARGB libyuv::H420ToABGR |
| 40 #else | 42 #else |
| 41 #error Unexpected Skia ARGB_8888 layout! | 43 #error Unexpected Skia ARGB_8888 layout! |
| 42 #endif | 44 #endif |
| 43 | 45 |
| 44 namespace media { | 46 namespace media { |
| 45 | 47 |
| 46 namespace { | 48 namespace { |
| (...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 video_frame->stride(VideoFrame::kVPlane), | 507 video_frame->stride(VideoFrame::kVPlane), |
| 506 video_frame->visible_data(VideoFrame::kAPlane), | 508 video_frame->visible_data(VideoFrame::kAPlane), |
| 507 video_frame->stride(VideoFrame::kAPlane), | 509 video_frame->stride(VideoFrame::kAPlane), |
| 508 static_cast<uint8*>(rgb_pixels), | 510 static_cast<uint8*>(rgb_pixels), |
| 509 row_bytes, | 511 row_bytes, |
| 510 video_frame->visible_rect().width(), | 512 video_frame->visible_rect().width(), |
| 511 video_frame->visible_rect().height()); | 513 video_frame->visible_rect().height()); |
| 512 break; | 514 break; |
| 513 | 515 |
| 514 case PIXEL_FORMAT_YV24: | 516 case PIXEL_FORMAT_YV24: |
| 515 libyuv::I444ToARGB( | 517 LIBYUV_I444_TO_ARGB( |
| 516 video_frame->visible_data(VideoFrame::kYPlane), | 518 video_frame->visible_data(VideoFrame::kYPlane), |
| 517 video_frame->stride(VideoFrame::kYPlane), | 519 video_frame->stride(VideoFrame::kYPlane), |
| 518 video_frame->visible_data(VideoFrame::kUPlane), | 520 video_frame->visible_data(VideoFrame::kUPlane), |
| 519 video_frame->stride(VideoFrame::kUPlane), | 521 video_frame->stride(VideoFrame::kUPlane), |
| 520 video_frame->visible_data(VideoFrame::kVPlane), | 522 video_frame->visible_data(VideoFrame::kVPlane), |
| 521 video_frame->stride(VideoFrame::kVPlane), | 523 video_frame->stride(VideoFrame::kVPlane), |
| 522 static_cast<uint8*>(rgb_pixels), | 524 static_cast<uint8*>(rgb_pixels), |
| 523 row_bytes, | 525 row_bytes, |
| 524 video_frame->visible_rect().width(), | 526 video_frame->visible_rect().width(), |
| 525 video_frame->visible_rect().height()); | 527 video_frame->visible_rect().height()); |
| 526 #if SK_R32_SHIFT == 0 && SK_G32_SHIFT == 8 && SK_B32_SHIFT == 16 && \ | |
| 527 SK_A32_SHIFT == 24 | |
| 528 libyuv::ARGBToABGR(static_cast<uint8*>(rgb_pixels), | |
| 529 row_bytes, | |
| 530 static_cast<uint8*>(rgb_pixels), | |
| 531 row_bytes, | |
| 532 video_frame->visible_rect().width(), | |
| 533 video_frame->visible_rect().height()); | |
| 534 #endif | |
| 535 break; | 528 break; |
| 536 case PIXEL_FORMAT_NV12: | 529 case PIXEL_FORMAT_NV12: |
| 537 case PIXEL_FORMAT_NV21: | 530 case PIXEL_FORMAT_NV21: |
| 538 case PIXEL_FORMAT_UYVY: | 531 case PIXEL_FORMAT_UYVY: |
| 539 case PIXEL_FORMAT_YUY2: | 532 case PIXEL_FORMAT_YUY2: |
| 540 case PIXEL_FORMAT_ARGB: | 533 case PIXEL_FORMAT_ARGB: |
| 541 case PIXEL_FORMAT_XRGB: | 534 case PIXEL_FORMAT_XRGB: |
| 542 case PIXEL_FORMAT_RGB24: | 535 case PIXEL_FORMAT_RGB24: |
| 543 case PIXEL_FORMAT_RGB32: | 536 case PIXEL_FORMAT_RGB32: |
| 544 case PIXEL_FORMAT_MJPEG: | 537 case PIXEL_FORMAT_MJPEG: |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 video_frame->UpdateReleaseSyncPoint(&client); | 581 video_frame->UpdateReleaseSyncPoint(&client); |
| 589 } | 582 } |
| 590 | 583 |
| 591 void SkCanvasVideoRenderer::ResetCache() { | 584 void SkCanvasVideoRenderer::ResetCache() { |
| 592 // Clear cached values. | 585 // Clear cached values. |
| 593 last_image_ = nullptr; | 586 last_image_ = nullptr; |
| 594 last_timestamp_ = kNoTimestamp(); | 587 last_timestamp_ = kNoTimestamp(); |
| 595 } | 588 } |
| 596 | 589 |
| 597 } // namespace media | 590 } // namespace media |
| OLD | NEW |