Commit e758a237 authored by reed@google.com's avatar reed@google.com

don't create SkDevice directly, use SkBitmap or (better) SkCanvas::NewRaster factory

BUG=skia:2239
TBR=scherkus@chromium.org

Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=254567

reopened (after revewer) to address media_unittest valgrind issue

Review URL: https://codereview.chromium.org/184743002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@255137 0039d316-1c4b-4281-b951-d872f2087c98
parent 864b73c7
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "third_party/skia/include/core/SkBitmap.h" #include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkBitmapDevice.h"
#include "third_party/skia/include/core/SkCanvas.h" #include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkPicture.h" #include "third_party/skia/include/core/SkPicture.h"
#include "ui/gfx/vector2d_conversions.h" #include "ui/gfx/vector2d_conversions.h"
...@@ -441,8 +440,10 @@ void BrowserViewRenderer::FallbackTickFired() { ...@@ -441,8 +440,10 @@ void BrowserViewRenderer::FallbackTickFired() {
void BrowserViewRenderer::ForceFakeCompositeSW() { void BrowserViewRenderer::ForceFakeCompositeSW() {
DCHECK(has_compositor_); DCHECK(has_compositor_);
SkBitmapDevice device(SkBitmap::kARGB_8888_Config, 1, 1); SkBitmap bitmap;
SkCanvas canvas(&device); bitmap.allocN32Pixels(1, 1);
bitmap.eraseColor(0);
SkCanvas canvas(bitmap);
CompositeSW(&canvas); CompositeSW(&canvas);
} }
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include "base/debug/trace_event.h" #include "base/debug/trace_event.h"
#include "jni/JavaBrowserViewRendererHelper_jni.h" #include "jni/JavaBrowserViewRendererHelper_jni.h"
#include "third_party/skia/include/core/SkBitmap.h" #include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkBitmapDevice.h"
#include "third_party/skia/include/utils/SkCanvasStateUtils.h" #include "third_party/skia/include/utils/SkCanvasStateUtils.h"
using base::android::JavaRef; using base::android::JavaRef;
...@@ -156,15 +155,12 @@ bool JavaBrowserViewRendererHelper::RasterizeIntoBitmap( ...@@ -156,15 +155,12 @@ bool JavaBrowserViewRendererHelper::RasterizeIntoBitmap(
bool succeeded; bool succeeded;
{ {
SkImageInfo info =
SkImageInfo::MakeN32Premul(bitmap_info.width, bitmap_info.height);
SkBitmap bitmap; SkBitmap bitmap;
bitmap.setConfig(SkBitmap::kARGB_8888_Config, bitmap.installPixels(info, pixels, bitmap_info.stride);
bitmap_info.width,
bitmap_info.height, SkCanvas canvas(bitmap);
bitmap_info.stride);
bitmap.setPixels(pixels);
SkBitmapDevice device(bitmap);
SkCanvas canvas(&device);
canvas.translate(-scroll_x, -scroll_y); canvas.translate(-scroll_x, -scroll_y);
succeeded = renderer.Run(&canvas); succeeded = renderer.Run(&canvas);
} }
......
...@@ -95,8 +95,7 @@ class OnDemandRasterTaskImpl : public internal::Task { ...@@ -95,8 +95,7 @@ class OnDemandRasterTaskImpl : public internal::Task {
// Overridden from internal::Task: // Overridden from internal::Task:
virtual void RunOnWorkerThread(unsigned thread_index) OVERRIDE { virtual void RunOnWorkerThread(unsigned thread_index) OVERRIDE {
TRACE_EVENT0("cc", "OnDemandRasterTaskImpl::RunOnWorkerThread"); TRACE_EVENT0("cc", "OnDemandRasterTaskImpl::RunOnWorkerThread");
SkBitmapDevice device(*bitmap_); SkCanvas canvas(*bitmap_);
SkCanvas canvas(&device);
picture_pile_->RasterToBitmap( picture_pile_->RasterToBitmap(
&canvas, content_rect_, contents_scale_, NULL); &canvas, content_rect_, contents_scale_, NULL);
} }
......
...@@ -495,9 +495,7 @@ SkCanvas* ResourceProvider::BitmapRasterBuffer::DoLockForWrite() { ...@@ -495,9 +495,7 @@ SkCanvas* ResourceProvider::BitmapRasterBuffer::DoLockForWrite() {
NOTREACHED(); NOTREACHED();
break; break;
} }
skia::RefPtr<SkBitmapDevice> device = raster_canvas_ = skia::AdoptRef(new SkCanvas(raster_bitmap_));
skia::AdoptRef(new SkBitmapDevice(raster_bitmap_));
raster_canvas_ = skia::AdoptRef(new SkCanvas(device.get()));
raster_bitmap_generation_id_ = raster_bitmap_.getGenerationID(); raster_bitmap_generation_id_ = raster_bitmap_.getGenerationID();
return raster_canvas_.get(); return raster_canvas_.get();
} }
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
#include "grit/theme_resources.h" #include "grit/theme_resources.h"
#include "grit/ui_resources.h" #include "grit/ui_resources.h"
#include "third_party/skia/include/core/SkBitmap.h" #include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkBitmapDevice.h"
#include "third_party/skia/include/core/SkCanvas.h" #include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkPaint.h" #include "third_party/skia/include/core/SkPaint.h"
#include "third_party/skia/include/effects/SkGradientShader.h" #include "third_party/skia/include/effects/SkGradientShader.h"
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
// found in the LICENSE file. // found in the LICENSE file.
#include "content/browser/compositor/software_output_device_ozone.h" #include "content/browser/compositor/software_output_device_ozone.h"
#include "third_party/skia/include/core/SkBitmapDevice.h"
#include "third_party/skia/include/core/SkDevice.h" #include "third_party/skia/include/core/SkDevice.h"
#include "ui/compositor/compositor.h" #include "ui/compositor/compositor.h"
#include "ui/gfx/ozone/surface_factory_ozone.h" #include "ui/gfx/ozone/surface_factory_ozone.h"
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
#include "media/filters/skcanvas_video_renderer.h" #include "media/filters/skcanvas_video_renderer.h"
#include "net/base/net_util.h" #include "net/base/net_util.h"
#include "third_party/skia/include/core/SkBitmap.h" #include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkBitmapDevice.h"
#include "third_party/skia/include/core/SkCanvas.h" #include "third_party/skia/include/core/SkCanvas.h"
#include "ui/base/ui_base_switches.h" #include "ui/base/ui_base_switches.h"
#include "ui/gfx/size_conversions.h" #include "ui/gfx/size_conversions.h"
...@@ -582,14 +581,12 @@ class CompositingRenderWidgetHostViewBrowserTestTabCapture ...@@ -582,14 +581,12 @@ class CompositingRenderWidgetHostViewBrowserTestTabCapture
media::SkCanvasVideoRenderer video_renderer; media::SkCanvasVideoRenderer video_renderer;
SkBitmap bitmap; SkBitmap bitmap;
bitmap.setConfig(SkBitmap::kARGB_8888_Config, bitmap.allocPixels(SkImageInfo::Make(video_frame->visible_rect().width(),
video_frame->visible_rect().width(), video_frame->visible_rect().height(),
video_frame->visible_rect().height(), kPMColor_SkColorType,
0, kOpaque_SkAlphaType); kOpaque_SkAlphaType));
bitmap.allocPixels(); bitmap.allocPixels();
SkCanvas canvas(bitmap);
SkBitmapDevice device(bitmap);
SkCanvas canvas(&device);
video_renderer.Paint(video_frame.get(), video_renderer.Paint(video_frame.get(),
&canvas, &canvas,
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#include "third_party/WebKit/public/web/WebArrayBufferConverter.h" #include "third_party/WebKit/public/web/WebArrayBufferConverter.h"
#include "third_party/WebKit/public/web/WebFrame.h" #include "third_party/WebKit/public/web/WebFrame.h"
#include "third_party/WebKit/public/web/WebKit.h" #include "third_party/WebKit/public/web/WebKit.h"
#include "third_party/skia/include/core/SkBitmapDevice.h"
#include "third_party/skia/include/core/SkCanvas.h" #include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkColorPriv.h" #include "third_party/skia/include/core/SkColorPriv.h"
#include "third_party/skia/include/core/SkGraphics.h" #include "third_party/skia/include/core/SkGraphics.h"
...@@ -263,10 +262,9 @@ void SkiaBenchmarking::GetOpTimings(gin::Arguments* args) { ...@@ -263,10 +262,9 @@ void SkiaBenchmarking::GetOpTimings(gin::Arguments* args) {
gfx::Rect bounds = picture->LayerRect(); gfx::Rect bounds = picture->LayerRect();
// Measure the total time by drawing straight into a bitmap-backed canvas. // Measure the total time by drawing straight into a bitmap-backed canvas.
skia::RefPtr<SkBaseDevice> device = skia::AdoptRef(SkNEW_ARGS( SkBitmap bitmap;
SkBitmapDevice, bitmap.allocN32Pixels(bounds.width(), bounds.height());
(SkBitmap::kARGB_8888_Config, bounds.width(), bounds.height()))); SkCanvas bitmap_canvas(bitmap);
SkCanvas bitmap_canvas(device.get());
bitmap_canvas.clear(SK_ColorTRANSPARENT); bitmap_canvas.clear(SK_ColorTRANSPARENT);
base::TimeTicks t0 = base::TimeTicks::HighResNow(); base::TimeTicks t0 = base::TimeTicks::HighResNow();
picture->Replay(&bitmap_canvas); picture->Replay(&bitmap_canvas);
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#include "base/logging.h" #include "base/logging.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "skia/ext/benchmarking_canvas.h" #include "skia/ext/benchmarking_canvas.h"
#include "third_party/skia/include/core/SkBitmapDevice.h"
#include "third_party/skia/include/utils/SkProxyCanvas.h" #include "third_party/skia/include/utils/SkProxyCanvas.h"
namespace skia { namespace skia {
...@@ -25,9 +24,7 @@ class TimingCanvas : public SkProxyCanvas { ...@@ -25,9 +24,7 @@ class TimingCanvas : public SkProxyCanvas {
public: public:
TimingCanvas(int width, int height, const BenchmarkingCanvas* track_canvas) TimingCanvas(int width, int height, const BenchmarkingCanvas* track_canvas)
: tracking_canvas_(track_canvas) { : tracking_canvas_(track_canvas) {
skia::RefPtr<SkBaseDevice> device = skia::AdoptRef( canvas_ = skia::AdoptRef(SkCanvas::NewRasterN32(width, height));
SkNEW_ARGS(SkBitmapDevice, (SkBitmap::kARGB_8888_Config, width, height)));
canvas_ = skia::AdoptRef(SkNEW_ARGS(SkCanvas, (device.get())));
setProxy(canvas_.get()); setProxy(canvas_.get());
} }
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
#include "base/file_util.h" #include "base/file_util.h"
#include "base/logging.h" #include "base/logging.h"
#include "third_party/skia/include/core/SkBitmapDevice.h"
#include "third_party/skia/include/core/SkCanvas.h" #include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkFlattenableSerialization.h" #include "third_party/skia/include/core/SkFlattenableSerialization.h"
#include "third_party/skia/include/core/SkImageFilter.h" #include "third_party/skia/include/core/SkImageFilter.h"
...@@ -74,10 +73,8 @@ int main(int argc, char** argv) { ...@@ -74,10 +73,8 @@ int main(int argc, char** argv) {
int ret = 0; int ret = 0;
SkBitmap bitmap; SkBitmap bitmap;
bitmap.setConfig(SkBitmap::kARGB_8888_Config, BitmapSize, BitmapSize); bitmap.allocN32Pixels(BitmapSize, BitmapSize);
bitmap.allocPixels(); SkCanvas canvas(bitmap);
SkBitmapDevice device(bitmap);
SkCanvas canvas(&device);
canvas.clear(0x00000000); canvas.clear(0x00000000);
for (int i = 1; i < argc; i++) for (int i = 1; i < argc; i++)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment