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
3 // found in the LICENSE file.
5 #include "cc/output/software_output_device.h"
7 #include "base/logging.h"
8 #include "cc/output/software_frame_data.h"
9 #include "third_party/skia/include/core/SkCanvas.h"
10 #include "ui/gfx/skia_util.h"
11 #include "ui/gfx/vsync_provider.h"
15 SoftwareOutputDevice::SoftwareOutputDevice() {}
17 SoftwareOutputDevice::~SoftwareOutputDevice() {}
19 void SoftwareOutputDevice::Resize(const gfx::Size& viewport_size) {
20 if (viewport_size_ == viewport_size)
23 SkImageInfo info = SkImageInfo::MakeN32(
24 viewport_size.width(), viewport_size.height(), kOpaque_SkAlphaType);
25 viewport_size_ = viewport_size;
26 canvas_ = skia::AdoptRef(SkCanvas::NewRaster(info));
29 SkCanvas* SoftwareOutputDevice::BeginPaint(const gfx::Rect& damage_rect) {
31 damage_rect_ = damage_rect;
35 void SoftwareOutputDevice::EndPaint(SoftwareFrameData* frame_data) {
38 frame_data->size = viewport_size_;
39 frame_data->damage_rect = damage_rect_;
42 void SoftwareOutputDevice::CopyToPixels(const gfx::Rect& rect, void* pixels) {
44 SkImageInfo info = SkImageInfo::MakeN32Premul(rect.width(), rect.height());
45 canvas_->readPixels(info, pixels, info.minRowBytes(), rect.x(), rect.y());
48 void SoftwareOutputDevice::Scroll(const gfx::Vector2d& delta,
49 const gfx::Rect& clip_rect) {
53 void SoftwareOutputDevice::ReclaimSoftwareFrame(unsigned id) {
57 gfx::VSyncProvider* SoftwareOutputDevice::GetVSyncProvider() {
58 return vsync_provider_.get();