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

Side by Side Diff: cc/output/software_output_device.cc

Issue 791753002: SkCanvas::NewRaster is deprecated, create a surface instead (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "cc/output/software_output_device.h" 5 #include "cc/output/software_output_device.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "cc/output/software_frame_data.h" 8 #include "cc/output/software_frame_data.h"
9 #include "third_party/skia/include/core/SkCanvas.h" 9 #include "third_party/skia/include/core/SkCanvas.h"
bungeman-skia 2014/12/09 21:39:54 Looks like SkCanvas can be left forward declared a
10 #include "ui/gfx/vsync_provider.h" 10 #include "ui/gfx/vsync_provider.h"
11 11
12 namespace cc { 12 namespace cc {
13 13
14 SoftwareOutputDevice::SoftwareOutputDevice() : scale_factor_(1.f) { 14 SoftwareOutputDevice::SoftwareOutputDevice() : scale_factor_(1.f) {
15 } 15 }
16 16
17 SoftwareOutputDevice::~SoftwareOutputDevice() {} 17 SoftwareOutputDevice::~SoftwareOutputDevice() {}
18 18
19 void SoftwareOutputDevice::Resize(const gfx::Size& viewport_pixel_size, 19 void SoftwareOutputDevice::Resize(const gfx::Size& viewport_pixel_size,
20 float scale_factor) { 20 float scale_factor) {
21 scale_factor_ = scale_factor; 21 scale_factor_ = scale_factor;
22 22
23 if (viewport_pixel_size_ == viewport_pixel_size) 23 if (viewport_pixel_size_ == viewport_pixel_size)
24 return; 24 return;
25 25
26 SkImageInfo info = SkImageInfo::MakeN32(viewport_pixel_size.width(), 26 SkImageInfo info = SkImageInfo::MakeN32(viewport_pixel_size.width(),
27 viewport_pixel_size.height(), 27 viewport_pixel_size.height(),
28 kOpaque_SkAlphaType); 28 kOpaque_SkAlphaType);
29 viewport_pixel_size_ = viewport_pixel_size; 29 viewport_pixel_size_ = viewport_pixel_size;
30 canvas_ = skia::AdoptRef(SkCanvas::NewRaster(info)); 30 surface_ = skia::AdoptRef(SkSurface::NewRaster(info));
31 } 31 }
32 32
33 SkCanvas* SoftwareOutputDevice::BeginPaint(const gfx::Rect& damage_rect) { 33 SkCanvas* SoftwareOutputDevice::BeginPaint(const gfx::Rect& damage_rect) {
34 DCHECK(canvas_); 34 DCHECK(surface_);
35 damage_rect_ = damage_rect; 35 damage_rect_ = damage_rect;
36 return canvas_.get(); 36 return surface_->getCanvas();
37 } 37 }
38 38
39 void SoftwareOutputDevice::EndPaint(SoftwareFrameData* frame_data) { 39 void SoftwareOutputDevice::EndPaint(SoftwareFrameData* frame_data) {
40 DCHECK(frame_data); 40 DCHECK(frame_data);
41 frame_data->id = 0; 41 frame_data->id = 0;
42 frame_data->size = viewport_pixel_size_; 42 frame_data->size = viewport_pixel_size_;
43 frame_data->damage_rect = damage_rect_; 43 frame_data->damage_rect = damage_rect_;
44 } 44 }
45 45
46 void SoftwareOutputDevice::CopyToPixels(const gfx::Rect& rect, void* pixels) { 46 void SoftwareOutputDevice::CopyToPixels(const gfx::Rect& rect, void* pixels) {
47 DCHECK(canvas_); 47 DCHECK(surface_);
48 SkImageInfo info = SkImageInfo::MakeN32Premul(rect.width(), rect.height()); 48 SkImageInfo info = SkImageInfo::MakeN32Premul(rect.width(), rect.height());
49 canvas_->readPixels(info, pixels, info.minRowBytes(), rect.x(), rect.y()); 49 surface_->getCanvas()->readPixels(info, pixels, info.minRowBytes(), rect.x(),
50 rect.y());
50 } 51 }
51 52
52 void SoftwareOutputDevice::Scroll(const gfx::Vector2d& delta, 53 void SoftwareOutputDevice::Scroll(const gfx::Vector2d& delta,
53 const gfx::Rect& clip_rect) { 54 const gfx::Rect& clip_rect) {
54 NOTIMPLEMENTED(); 55 NOTIMPLEMENTED();
55 } 56 }
56 57
57 void SoftwareOutputDevice::ReclaimSoftwareFrame(unsigned id) { 58 void SoftwareOutputDevice::ReclaimSoftwareFrame(unsigned id) {
58 NOTIMPLEMENTED(); 59 NOTIMPLEMENTED();
59 } 60 }
60 61
61 gfx::VSyncProvider* SoftwareOutputDevice::GetVSyncProvider() { 62 gfx::VSyncProvider* SoftwareOutputDevice::GetVSyncProvider() {
62 return vsync_provider_.get(); 63 return vsync_provider_.get();
63 } 64 }
64 65
65 } // namespace cc 66 } // namespace cc
OLDNEW
« cc/output/software_output_device.h ('K') | « cc/output/software_output_device.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698