| 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/renderers/skcanvas_video_renderer.h" | 5 #include "media/renderers/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 #include "ui/gfx/skia_util.h" |
| 23 | 24 |
| 24 // Skia internal format depends on a platform. On Android it is ABGR, on others | 25 // Skia internal format depends on a platform. On Android it is ABGR, on others |
| 25 // it is ARGB. | 26 // it is ARGB. |
| 26 #if SK_B32_SHIFT == 0 && SK_G32_SHIFT == 8 && SK_R32_SHIFT == 16 && \ | 27 #if SK_B32_SHIFT == 0 && SK_G32_SHIFT == 8 && SK_R32_SHIFT == 16 && \ |
| 27 SK_A32_SHIFT == 24 | 28 SK_A32_SHIFT == 24 |
| 28 #define LIBYUV_I420_TO_ARGB libyuv::I420ToARGB | 29 #define LIBYUV_I420_TO_ARGB libyuv::I420ToARGB |
| 29 #define LIBYUV_I422_TO_ARGB libyuv::I422ToARGB | 30 #define LIBYUV_I422_TO_ARGB libyuv::I422ToARGB |
| 30 #define LIBYUV_I444_TO_ARGB libyuv::I444ToARGB | 31 #define LIBYUV_I444_TO_ARGB libyuv::I444ToARGB |
| 31 #define LIBYUV_I420ALPHA_TO_ARGB libyuv::I420AlphaToARGB | 32 #define LIBYUV_I420ALPHA_TO_ARGB libyuv::I420AlphaToARGB |
| 32 #define LIBYUV_J420_TO_ARGB libyuv::J420ToARGB | 33 #define LIBYUV_J420_TO_ARGB libyuv::J420ToARGB |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 } | 344 } |
| 344 if (!last_image_) // Couldn't create the SkImage. | 345 if (!last_image_) // Couldn't create the SkImage. |
| 345 return; | 346 return; |
| 346 last_timestamp_ = video_frame->timestamp(); | 347 last_timestamp_ = video_frame->timestamp(); |
| 347 } | 348 } |
| 348 last_image_deleting_timer_.Reset(); | 349 last_image_deleting_timer_.Reset(); |
| 349 | 350 |
| 350 paint.setXfermodeMode(mode); | 351 paint.setXfermodeMode(mode); |
| 351 paint.setFilterQuality(kLow_SkFilterQuality); | 352 paint.setFilterQuality(kLow_SkFilterQuality); |
| 352 | 353 |
| 353 const bool need_transform = | 354 const bool need_rotation = video_rotation != VIDEO_ROTATION_0; |
| 354 video_rotation != VIDEO_ROTATION_0 || | 355 const bool need_scaling = |
| 355 dest_rect.size() != gfx::SizeF(video_frame->visible_rect().size()) || | 356 dest_rect.size() != |
| 356 !dest_rect.origin().IsOrigin(); | 357 gfx::SizeF(gfx::SkISizeToSize(last_image_->dimensions())); |
| 358 const bool need_translation = !dest_rect.origin().IsOrigin(); |
| 359 bool need_transform = need_rotation || need_scaling || need_translation; |
| 357 if (need_transform) { | 360 if (need_transform) { |
| 358 canvas->save(); | 361 canvas->save(); |
| 359 canvas->translate( | 362 canvas->translate( |
| 360 SkFloatToScalar(dest_rect.x() + (dest_rect.width() * 0.5f)), | 363 SkFloatToScalar(dest_rect.x() + (dest_rect.width() * 0.5f)), |
| 361 SkFloatToScalar(dest_rect.y() + (dest_rect.height() * 0.5f))); | 364 SkFloatToScalar(dest_rect.y() + (dest_rect.height() * 0.5f))); |
| 362 SkScalar angle = SkFloatToScalar(0.0f); | 365 SkScalar angle = SkFloatToScalar(0.0f); |
| 363 switch (video_rotation) { | 366 switch (video_rotation) { |
| 364 case VIDEO_ROTATION_0: | 367 case VIDEO_ROTATION_0: |
| 365 break; | 368 break; |
| 366 case VIDEO_ROTATION_90: | 369 case VIDEO_ROTATION_90: |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 572 video_frame->UpdateReleaseSyncPoint(&client); | 575 video_frame->UpdateReleaseSyncPoint(&client); |
| 573 } | 576 } |
| 574 | 577 |
| 575 void SkCanvasVideoRenderer::ResetCache() { | 578 void SkCanvasVideoRenderer::ResetCache() { |
| 576 // Clear cached values. | 579 // Clear cached values. |
| 577 last_image_ = nullptr; | 580 last_image_ = nullptr; |
| 578 last_timestamp_ = kNoTimestamp(); | 581 last_timestamp_ = kNoTimestamp(); |
| 579 } | 582 } |
| 580 | 583 |
| 581 } // namespace media | 584 } // namespace media |
| OLD | NEW |