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

Side by Side Diff: media/blink/skcanvas_video_renderer.cc

Issue 1321023006: J420ToABGR for 1 step Android J420 conversion (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: deps roll pushed. this cl is just the skcanvas call for j420 now Created 5 years, 3 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
« no previous file with comments | « no previous file | 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) 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 "ui/gfx/geometry/rect_f.h" 21 #include "ui/gfx/geometry/rect_f.h"
22 22
23 // Skia internal format depends on a platform. On Android it is ABGR, on others 23 // Skia internal format depends on a platform. On Android it is ABGR, on others
24 // it is ARGB. 24 // it is ARGB.
25 #if SK_B32_SHIFT == 0 && SK_G32_SHIFT == 8 && SK_R32_SHIFT == 16 && \ 25 #if SK_B32_SHIFT == 0 && SK_G32_SHIFT == 8 && SK_R32_SHIFT == 16 && \
26 SK_A32_SHIFT == 24 26 SK_A32_SHIFT == 24
27 #define LIBYUV_I420_TO_ARGB libyuv::I420ToARGB 27 #define LIBYUV_I420_TO_ARGB libyuv::I420ToARGB
28 #define LIBYUV_I422_TO_ARGB libyuv::I422ToARGB 28 #define LIBYUV_I422_TO_ARGB libyuv::I422ToARGB
29 #define LIBYUV_I420ALPHA_TO_ARGB libyuv::I420AlphaToARGB 29 #define LIBYUV_I420ALPHA_TO_ARGB libyuv::I420AlphaToARGB
30 #define LIBYUV_J420_TO_ARGB libyuv::J420ToARGB
30 #elif SK_R32_SHIFT == 0 && SK_G32_SHIFT == 8 && SK_B32_SHIFT == 16 && \ 31 #elif SK_R32_SHIFT == 0 && SK_G32_SHIFT == 8 && SK_B32_SHIFT == 16 && \
31 SK_A32_SHIFT == 24 32 SK_A32_SHIFT == 24
32 #define LIBYUV_I420_TO_ARGB libyuv::I420ToABGR 33 #define LIBYUV_I420_TO_ARGB libyuv::I420ToABGR
33 #define LIBYUV_I422_TO_ARGB libyuv::I422ToABGR 34 #define LIBYUV_I422_TO_ARGB libyuv::I422ToABGR
34 #define LIBYUV_I420ALPHA_TO_ARGB libyuv::I420AlphaToABGR 35 #define LIBYUV_I420ALPHA_TO_ARGB libyuv::I420AlphaToABGR
36 #define LIBYUV_J420_TO_ARGB libyuv::J420ToABGR
35 #else 37 #else
36 #error Unexpected Skia ARGB_8888 layout! 38 #error Unexpected Skia ARGB_8888 layout!
37 #endif 39 #endif
38 40
39 namespace media { 41 namespace media {
40 42
41 namespace { 43 namespace {
42 44
43 // This class keeps the last image drawn. 45 // This class keeps the last image drawn.
44 // We delete the temporary resource if it is not used for 3 seconds. 46 // We delete the temporary resource if it is not used for 3 seconds.
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 NOTREACHED() << "Non YUV formats are not supported"; 415 NOTREACHED() << "Non YUV formats are not supported";
414 return; 416 return;
415 } 417 }
416 DCHECK_EQ(video_frame->stride(VideoFrame::kUPlane), 418 DCHECK_EQ(video_frame->stride(VideoFrame::kUPlane),
417 video_frame->stride(VideoFrame::kVPlane)); 419 video_frame->stride(VideoFrame::kVPlane));
418 420
419 switch (video_frame->format()) { 421 switch (video_frame->format()) {
420 case PIXEL_FORMAT_YV12: 422 case PIXEL_FORMAT_YV12:
421 case PIXEL_FORMAT_I420: 423 case PIXEL_FORMAT_I420:
422 if (CheckColorSpace(video_frame, COLOR_SPACE_JPEG)) { 424 if (CheckColorSpace(video_frame, COLOR_SPACE_JPEG)) {
423 libyuv::J420ToARGB( 425 LIBYUV_J420_TO_ARGB(
424 video_frame->visible_data(VideoFrame::kYPlane), 426 video_frame->visible_data(VideoFrame::kYPlane),
425 video_frame->stride(VideoFrame::kYPlane), 427 video_frame->stride(VideoFrame::kYPlane),
426 video_frame->visible_data(VideoFrame::kUPlane), 428 video_frame->visible_data(VideoFrame::kUPlane),
427 video_frame->stride(VideoFrame::kUPlane), 429 video_frame->stride(VideoFrame::kUPlane),
428 video_frame->visible_data(VideoFrame::kVPlane), 430 video_frame->visible_data(VideoFrame::kVPlane),
429 video_frame->stride(VideoFrame::kVPlane), 431 video_frame->stride(VideoFrame::kVPlane),
430 static_cast<uint8*>(rgb_pixels), 432 static_cast<uint8*>(rgb_pixels),
431 row_bytes, 433 row_bytes,
432 video_frame->visible_rect().width(), 434 video_frame->visible_rect().width(),
433 video_frame->visible_rect().height()); 435 video_frame->visible_rect().height());
434 #if SK_R32_SHIFT == 0 && SK_G32_SHIFT == 8 && SK_B32_SHIFT == 16 && \
435 SK_A32_SHIFT == 24
436 libyuv::ARGBToABGR(static_cast<uint8*>(rgb_pixels),
437 row_bytes,
438 static_cast<uint8*>(rgb_pixels),
439 row_bytes,
440 video_frame->visible_rect().width(),
441 video_frame->visible_rect().height());
442 #endif
443 } else if (CheckColorSpace(video_frame, COLOR_SPACE_HD_REC709)) { 436 } else if (CheckColorSpace(video_frame, COLOR_SPACE_HD_REC709)) {
444 ConvertYUVToRGB32(video_frame->visible_data(VideoFrame::kYPlane), 437 ConvertYUVToRGB32(video_frame->visible_data(VideoFrame::kYPlane),
445 video_frame->visible_data(VideoFrame::kUPlane), 438 video_frame->visible_data(VideoFrame::kUPlane),
446 video_frame->visible_data(VideoFrame::kVPlane), 439 video_frame->visible_data(VideoFrame::kVPlane),
447 static_cast<uint8*>(rgb_pixels), 440 static_cast<uint8*>(rgb_pixels),
448 video_frame->visible_rect().width(), 441 video_frame->visible_rect().width(),
449 video_frame->visible_rect().height(), 442 video_frame->visible_rect().height(),
450 video_frame->stride(VideoFrame::kYPlane), 443 video_frame->stride(VideoFrame::kYPlane),
451 video_frame->stride(VideoFrame::kUPlane), row_bytes, 444 video_frame->stride(VideoFrame::kUPlane), row_bytes,
452 YV12HD); 445 YV12HD);
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 video_frame->UpdateReleaseSyncPoint(&client); 563 video_frame->UpdateReleaseSyncPoint(&client);
571 } 564 }
572 565
573 void SkCanvasVideoRenderer::ResetCache() { 566 void SkCanvasVideoRenderer::ResetCache() {
574 // Clear cached values. 567 // Clear cached values.
575 last_image_ = nullptr; 568 last_image_ = nullptr;
576 last_timestamp_ = kNoTimestamp(); 569 last_timestamp_ = kNoTimestamp();
577 } 570 }
578 571
579 } // namespace media 572 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698