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

Unified Diff: trunk/src/media/filters/skcanvas_video_renderer_unittest.cc

Issue 183003011: Revert 254567 "don't create SkDevice directly, use SkBitmap or (..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: trunk/src/media/filters/skcanvas_video_renderer_unittest.cc
===================================================================
--- trunk/src/media/filters/skcanvas_video_renderer_unittest.cc (revision 254711)
+++ trunk/src/media/filters/skcanvas_video_renderer_unittest.cc (working copy)
@@ -5,6 +5,7 @@
#include "media/base/video_frame.h"
#include "media/base/video_util.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "third_party/skia/include/core/SkBitmapDevice.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "media/filters/skcanvas_video_renderer.h"
@@ -18,17 +19,19 @@
// Helper for filling a |canvas| with a solid |color|.
void FillCanvas(SkCanvas* canvas, SkColor color) {
- canvas->clear(color);
+ const SkBitmap& bitmap = canvas->getDevice()->accessBitmap(true);
+ bitmap.lockPixels();
+ bitmap.eraseColor(color);
+ bitmap.unlockPixels();
}
// Helper for returning the color of a solid |canvas|.
SkColor GetColorAt(SkCanvas* canvas, int x, int y) {
- SkBitmap bitmap;
- if (!bitmap.allocN32Pixels(1, 1))
- return 0;
- if (!canvas->readPixels(&bitmap, x, y))
- return 0;
- return bitmap.getColor(0, 0);
+ const SkBitmap& bitmap = canvas->getDevice()->accessBitmap(false);
+ bitmap.lockPixels();
+ SkColor c = bitmap.getColor(x, y);
+ bitmap.unlockPixels();
+ return c;
}
SkColor GetColor(SkCanvas* canvas) {
@@ -72,20 +75,14 @@
scoped_refptr<VideoFrame> smaller_frame_;
scoped_refptr<VideoFrame> cropped_frame_;
+ SkBitmapDevice fast_path_device_;
SkCanvas fast_path_canvas_;
+ SkBitmapDevice slow_path_device_;
SkCanvas slow_path_canvas_;
DISALLOW_COPY_AND_ASSIGN(SkCanvasVideoRendererTest);
};
-static SkBitmap alloc_bitmap(int width, int height, bool isOpaque) {
- SkAlphaType alphaType = isOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType;
- SkBitmap bitmap;
-
- bitmap.allocPixels(SkImageInfo::MakeN32(width, height, alphaType));
- return bitmap;
-}
-
SkCanvasVideoRendererTest::SkCanvasVideoRendererTest()
: natural_frame_(VideoFrame::CreateBlackFrame(gfx::Size(kWidth, kHeight))),
larger_frame_(VideoFrame::CreateBlackFrame(
@@ -98,8 +95,10 @@
gfx::Rect(6, 6, 8, 6),
gfx::Size(8, 6),
base::TimeDelta::FromMilliseconds(4))),
- fast_path_canvas_(alloc_bitmap(kWidth, kHeight, true)),
- slow_path_canvas_(alloc_bitmap(kWidth, kHeight, false)) {
+ fast_path_device_(SkBitmap::kARGB_8888_Config, kWidth, kHeight, true),
+ fast_path_canvas_(&fast_path_device_),
+ slow_path_device_(SkBitmap::kARGB_8888_Config, kWidth, kHeight, false),
+ slow_path_canvas_(&slow_path_device_) {
// Give each frame a unique timestamp.
natural_frame_->SetTimestamp(base::TimeDelta::FromMilliseconds(1));
larger_frame_->SetTimestamp(base::TimeDelta::FromMilliseconds(2));
« no previous file with comments | « trunk/src/content/renderer/skia_benchmarking_extension.cc ('k') | trunk/src/skia/ext/benchmarking_canvas.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698