summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorskaslev@chromium.org <skaslev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-24 15:13:22 +0000
committerskaslev@chromium.org <skaslev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-24 15:13:22 +0000
commit4dd72d3ca99f6b1234854cfddd88bb0e6e943fc0 (patch)
tree4b2f5937a963b5c1ee9d00cbf47198030958c2f2
parent687931247aecb1c2eab7928f37d6877ce60c2978 (diff)
downloadchromium_src-4dd72d3ca99f6b1234854cfddd88bb0e6e943fc0.zip
chromium_src-4dd72d3ca99f6b1234854cfddd88bb0e6e943fc0.tar.gz
chromium_src-4dd72d3ca99f6b1234854cfddd88bb0e6e943fc0.tar.bz2
Moved SkCanvasVideoRenderer to media/filters.
SkCanvasVideoRenderer will be used for rendering YUV video streams by the software compositor. To avoid circular dependencies cc/ cannot depend on webkit/ hence the move. Also changed the interface of SkCanvasVideoRenderer::Paint to accept gfx::RectF instead of gfx::Rect. The gfx::Rect was converted to a floating point SkRect anyway and we actually use the floating point version from the software compositor. BUG=150016 Review URL: https://chromiumcodereview.appspot.com/11234071 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@163829 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--build/android/gtest_filter/content_unittests_disabled2
-rw-r--r--build/android/gtest_filter/media_unittests_disabled3
-rw-r--r--content/content_tests.gypi1
-rw-r--r--media/filters/skcanvas_video_renderer.cc (renamed from webkit/media/skcanvas_video_renderer.cc)28
-rw-r--r--media/filters/skcanvas_video_renderer.h (renamed from webkit/media/skcanvas_video_renderer.h)17
-rw-r--r--media/filters/skcanvas_video_renderer_unittest.cc (renamed from webkit/media/skcanvas_video_renderer_unittest.cc)6
-rw-r--r--media/media.gyp6
-rw-r--r--skia/config/win/stdint.h26
-rw-r--r--webkit/media/webkit_media.gypi2
-rw-r--r--webkit/media/webmediaplayer_ms.cc3
-rw-r--r--webkit/media/webmediaplayer_ms.h4
-rw-r--r--webkit/media/webmediaplayer_proxy.h4
12 files changed, 36 insertions, 66 deletions
diff --git a/build/android/gtest_filter/content_unittests_disabled b/build/android/gtest_filter/content_unittests_disabled
index 6ec30f1..49398bf 100644
--- a/build/android/gtest_filter/content_unittests_disabled
+++ b/build/android/gtest_filter/content_unittests_disabled
@@ -12,8 +12,6 @@ AudioRendererHostTest.SimulateErrorAndClose
# crbug.com/104950
DeviceOrientationProviderTest.ObserverNotRemoved
DeviceOrientationProviderTest.StartFailing
-# crbug.com/138930
-SkCanvasVideoRendererTest.*
# crbug.com/139095
RenderWidgetTest.OnMsgPaintAtSize
# crbug.com/147549
diff --git a/build/android/gtest_filter/media_unittests_disabled b/build/android/gtest_filter/media_unittests_disabled
index 96d106b..1759a13 100644
--- a/build/android/gtest_filter/media_unittests_disabled
+++ b/build/android/gtest_filter/media_unittests_disabled
@@ -9,3 +9,6 @@ CompositeFilterDeathTest.*
# http://crbug.com/138833
AesDecryptorTest.*
+
+# crbug.com/138930
+SkCanvasVideoRendererTest.*
diff --git a/content/content_tests.gypi b/content/content_tests.gypi
index 2892eff..8bba0ce 100644
--- a/content/content_tests.gypi
+++ b/content/content_tests.gypi
@@ -449,7 +449,6 @@
'../webkit/media/buffered_resource_loader_unittest.cc',
'../webkit/media/cache_util_unittest.cc',
'../webkit/media/crypto/proxy_decryptor_unittest.cc',
- '../webkit/media/skcanvas_video_renderer_unittest.cc',
'../webkit/media/test_response_generator.cc',
'../webkit/media/test_response_generator.h',
'../webkit/mocks/mock_weburlloader.cc',
diff --git a/webkit/media/skcanvas_video_renderer.cc b/media/filters/skcanvas_video_renderer.cc
index c2231b2..bef015e 100644
--- a/webkit/media/skcanvas_video_renderer.cc
+++ b/media/filters/skcanvas_video_renderer.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "webkit/media/skcanvas_video_renderer.h"
+#include "media/filters/skcanvas_video_renderer.h"
#include "base/logging.h"
#include "media/base/video_frame.h"
@@ -10,7 +10,7 @@
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkDevice.h"
-namespace webkit_media {
+namespace media {
static bool IsEitherYV12OrYV16(media::VideoFrame::Format format) {
return format == media::VideoFrame::YV12 || format == media::VideoFrame::YV16;
@@ -31,8 +31,8 @@ static bool IsEitherYV12OrYV16OrNative(media::VideoFrame::Format format) {
//
// TODO(hclam): The fast paint method should support flipping and mirroring.
// Disable the flipping and mirroring checks once we have it.
-static bool CanFastPaint(SkCanvas* canvas, const gfx::Rect& dest_rect,
- uint8_t alpha, media::VideoFrame::Format format) {
+static bool CanFastPaint(SkCanvas* canvas, uint8_t alpha,
+ media::VideoFrame::Format format) {
if (alpha != 0xFF || !IsEitherYV12OrYV16(format))
return false;
@@ -62,7 +62,7 @@ static bool CanFastPaint(SkCanvas* canvas, const gfx::Rect& dest_rect,
static void FastPaint(
const scoped_refptr<media::VideoFrame>& video_frame,
SkCanvas* canvas,
- const gfx::Rect& dest_rect) {
+ const SkRect& dest_rect) {
DCHECK(IsEitherYV12OrYV16(video_frame->format())) << video_frame->format();
DCHECK_EQ(video_frame->stride(media::VideoFrame::kUPlane),
video_frame->stride(media::VideoFrame::kVPlane));
@@ -72,15 +72,10 @@ static void FastPaint(
media::YV12 : media::YV16;
int y_shift = yuv_type; // 1 for YV12, 0 for YV16.
- // Create a rectangle backed by SkScalar.
- SkRect scalar_dest_rect;
- scalar_dest_rect.iset(dest_rect.x(), dest_rect.y(),
- dest_rect.right(), dest_rect.bottom());
-
// Transform the destination rectangle to local coordinates.
const SkMatrix& local_matrix = canvas->getTotalMatrix();
SkRect local_dest_rect;
- local_matrix.mapRect(&local_dest_rect, scalar_dest_rect);
+ local_matrix.mapRect(&local_dest_rect, dest_rect);
// After projecting the destination rectangle to local coordinates, round
// the projected rectangle to integer values, this will give us pixel values
@@ -219,15 +214,14 @@ SkCanvasVideoRenderer::~SkCanvasVideoRenderer() {}
void SkCanvasVideoRenderer::Paint(media::VideoFrame* video_frame,
SkCanvas* canvas,
- const gfx::Rect& dest_rect,
+ const gfx::RectF& dest_rect,
uint8_t alpha) {
if (alpha == 0) {
return;
}
SkRect dest;
- dest.set(SkIntToScalar(dest_rect.x()), SkIntToScalar(dest_rect.y()),
- SkIntToScalar(dest_rect.right()), SkIntToScalar(dest_rect.bottom()));
+ dest.set(dest_rect.x(), dest_rect.y(), dest_rect.right(), dest_rect.bottom());
SkPaint paint;
paint.setAlpha(alpha);
@@ -240,8 +234,8 @@ void SkCanvasVideoRenderer::Paint(media::VideoFrame* video_frame,
}
// Scale and convert to RGB in one step if we can.
- if (CanFastPaint(canvas, dest_rect, alpha, video_frame->format())) {
- FastPaint(video_frame, canvas, dest_rect);
+ if (CanFastPaint(canvas, alpha, video_frame->format())) {
+ FastPaint(video_frame, canvas, dest);
return;
}
@@ -257,4 +251,4 @@ void SkCanvasVideoRenderer::Paint(media::VideoFrame* video_frame,
canvas->drawBitmapRect(last_frame_, NULL, dest, &paint);
}
-} // namespace webkit_media
+} // namespace media
diff --git a/webkit/media/skcanvas_video_renderer.h b/media/filters/skcanvas_video_renderer.h
index d7d5339..99e9a22 100644
--- a/webkit/media/skcanvas_video_renderer.h
+++ b/media/filters/skcanvas_video_renderer.h
@@ -2,24 +2,23 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef WEBKIT_MEDIA_SKCANVAS_VIDEO_RENDERER_H_
-#define WEBKIT_MEDIA_SKCANVAS_VIDEO_RENDERER_H_
+#ifndef MEDIA_FILTERS_SKCANVAS_VIDEO_RENDERER_H_
+#define MEDIA_FILTERS_SKCANVAS_VIDEO_RENDERER_H_
#include "base/time.h"
+#include "media/base/media_export.h"
#include "ui/gfx/rect.h"
#include "third_party/skia/include/core/SkBitmap.h"
class SkCanvas;
namespace media {
-class VideoFrame;
-}
-namespace webkit_media {
+class VideoFrame;
// Handles rendering of VideoFrames to SkCanvases, doing any necessary YUV
// conversion and caching of resulting RGB bitmaps.
-class SkCanvasVideoRenderer {
+class MEDIA_EXPORT SkCanvasVideoRenderer {
public:
SkCanvasVideoRenderer();
~SkCanvasVideoRenderer();
@@ -30,7 +29,7 @@ class SkCanvasVideoRenderer {
// Black will be painted on |canvas| if |video_frame| is null.
void Paint(media::VideoFrame* video_frame,
SkCanvas* canvas,
- const gfx::Rect& dest_rect,
+ const gfx::RectF& dest_rect,
uint8_t alpha);
private:
@@ -42,6 +41,6 @@ class SkCanvasVideoRenderer {
DISALLOW_COPY_AND_ASSIGN(SkCanvasVideoRenderer);
};
-} // namespace webkit_media
+} // namespace media
-#endif // WEBKIT_MEDIA_SKCANVAS_VIDEO_RENDERER_H_
+#endif // MEDIA_FILTERS_SKCANVAS_VIDEO_RENDERER_H_
diff --git a/webkit/media/skcanvas_video_renderer_unittest.cc b/media/filters/skcanvas_video_renderer_unittest.cc
index f83d75a..a7ac30c 100644
--- a/webkit/media/skcanvas_video_renderer_unittest.cc
+++ b/media/filters/skcanvas_video_renderer_unittest.cc
@@ -7,11 +7,11 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkDevice.h"
-#include "webkit/media/skcanvas_video_renderer.h"
+#include "media/filters/skcanvas_video_renderer.h"
using media::VideoFrame;
-namespace webkit_media {
+namespace media {
static const int kWidth = 320;
static const int kHeight = 240;
@@ -199,4 +199,4 @@ TEST_F(SkCanvasVideoRendererTest, SlowPaint_SameVideoFrame) {
EXPECT_EQ(SK_ColorRED, GetColor(slow_path_canvas()));
}
-} // namespace webkit_media
+} // namespace media
diff --git a/media/media.gyp b/media/media.gyp
index ca6f97b..633914e 100644
--- a/media/media.gyp
+++ b/media/media.gyp
@@ -26,6 +26,7 @@
'../base/base.gyp:base',
'../build/temp_gyp/googleurl.gyp:googleurl',
'../crypto/crypto.gyp:crypto',
+ '../skia/skia.gyp:skia',
'../ui/ui.gyp:ui',
],
'defines': [
@@ -278,6 +279,8 @@
'filters/h264_to_annex_b_bitstream_converter.h',
'filters/in_memory_url_protocol.cc',
'filters/in_memory_url_protocol.h',
+ 'filters/skcanvas_video_renderer.cc',
+ 'filters/skcanvas_video_renderer.h',
'filters/source_buffer_stream.cc',
'filters/source_buffer_stream.h',
'filters/video_frame_generator.cc',
@@ -431,7 +434,6 @@
# A simple WebM encoder for animated avatars on ChromeOS.
['chromeos==1', {
'dependencies': [
- '../skia/skia.gyp:skia',
'../third_party/libvpx/libvpx.gyp:libvpx',
'../third_party/libyuv/libyuv.gyp:libyuv',
],
@@ -586,6 +588,7 @@
'../base/base.gyp:base',
'../base/base.gyp:base_i18n',
'../base/base.gyp:test_support_base',
+ '../skia/skia.gyp:skia',
'../testing/gmock.gyp:gmock',
'../testing/gtest.gyp:gtest',
'../ui/ui.gyp:ui',
@@ -657,6 +660,7 @@
'filters/h264_to_annex_b_bitstream_converter_unittest.cc',
'filters/pipeline_integration_test.cc',
'filters/pipeline_integration_test_base.cc',
+ 'filters/skcanvas_video_renderer_unittest.cc',
'filters/source_buffer_stream_unittest.cc',
'filters/video_renderer_base_unittest.cc',
'video/capture/video_capture_device_unittest.cc',
diff --git a/skia/config/win/stdint.h b/skia/config/win/stdint.h
deleted file mode 100644
index a37ac78..0000000
--- a/skia/config/win/stdint.h
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// skia is written in C99 and requires <stdint.h> and <inttypes.h>.
-// Since MSVC doesn't include these headers, we have to write our own version
-// to provide a compatibility layer between MSVC and skia
-
-#ifndef SKIA_CONFIG_WIN_STDINT_H_
-#define SKIA_CONFIG_WIN_STDINT_H_
-
-#if !defined(_MSC_VER)
-#error This file should only be included when compiling with MSVC.
-#endif
-
-// Define C99 equivalent types.
-typedef signed char int8_t;
-typedef signed short int16_t;
-typedef signed int int32_t;
-typedef signed long long int64_t;
-typedef unsigned char uint8_t;
-typedef unsigned short uint16_t;
-typedef unsigned int uint32_t;
-typedef unsigned long long uint64_t;
-
-#endif // SKIA_CONFIG_WIN_STDINT_H_
diff --git a/webkit/media/webkit_media.gypi b/webkit/media/webkit_media.gypi
index ba24b41..3c26152 100644
--- a/webkit/media/webkit_media.gypi
+++ b/webkit/media/webkit_media.gypi
@@ -66,8 +66,6 @@
'preload.h',
'simple_video_frame_provider.cc',
'simple_video_frame_provider.h',
- 'skcanvas_video_renderer.cc',
- 'skcanvas_video_renderer.h',
'video_frame_provider.cc',
'video_frame_provider.h',
'webmediaplayer_delegate.h',
diff --git a/webkit/media/webmediaplayer_ms.cc b/webkit/media/webmediaplayer_ms.cc
index b634323..740b5ea 100644
--- a/webkit/media/webmediaplayer_ms.cc
+++ b/webkit/media/webmediaplayer_ms.cc
@@ -273,7 +273,8 @@ void WebMediaPlayerMS::paint(WebCanvas* canvas,
DVLOG(3) << "WebMediaPlayerMS::paint";
DCHECK(thread_checker_.CalledOnValidThread());
- video_renderer_.Paint(current_frame_, canvas, rect, alpha);
+ gfx::RectF dest_rect(rect.x, rect.y, rect.width, rect.height);
+ video_renderer_.Paint(current_frame_, canvas, dest_rect, alpha);
}
bool WebMediaPlayerMS::hasSingleSecurityOrigin() const {
diff --git a/webkit/media/webmediaplayer_ms.h b/webkit/media/webmediaplayer_ms.h
index e49adc0..a4d4be0 100644
--- a/webkit/media/webmediaplayer_ms.h
+++ b/webkit/media/webmediaplayer_ms.h
@@ -9,9 +9,9 @@
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "googleurl/src/gurl.h"
+#include "media/filters/skcanvas_video_renderer.h"
#include "skia/ext/platform_canvas.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayer.h"
-#include "webkit/media/skcanvas_video_renderer.h"
namespace WebKit {
class WebFrame;
@@ -158,7 +158,7 @@ class WebMediaPlayerMS
base::TimeDelta start_time_;
unsigned total_frame_count_;
unsigned dropped_frame_count_;
- SkCanvasVideoRenderer video_renderer_;
+ media::SkCanvasVideoRenderer video_renderer_;
scoped_refptr<media::MediaLog> media_log_;
diff --git a/webkit/media/webmediaplayer_proxy.h b/webkit/media/webmediaplayer_proxy.h
index b80a4a0..35d5630 100644
--- a/webkit/media/webmediaplayer_proxy.h
+++ b/webkit/media/webmediaplayer_proxy.h
@@ -15,8 +15,8 @@
#include "media/base/pipeline.h"
#include "media/filters/chunk_demuxer.h"
#include "media/filters/ffmpeg_video_decoder.h"
+#include "media/filters/skcanvas_video_renderer.h"
#include "webkit/media/buffered_data_source.h"
-#include "webkit/media/skcanvas_video_renderer.h"
class SkCanvas;
@@ -124,7 +124,7 @@ class WebMediaPlayerProxy
scoped_refptr<BufferedDataSource> data_source_;
scoped_refptr<media::VideoRendererBase> frame_provider_;
- SkCanvasVideoRenderer video_renderer_;
+ media::SkCanvasVideoRenderer video_renderer_;
base::Lock lock_;
int outstanding_repaints_;