Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / cc / output / software_output_device.cc
blob07129387ad05417f00433ff7be1d25d66e5390c5
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 "third_party/skia/include/core/SkCanvas.h"
9 #include "ui/gfx/vsync_provider.h"
11 namespace cc {
13 SoftwareOutputDevice::SoftwareOutputDevice() : scale_factor_(1.f) {
16 SoftwareOutputDevice::~SoftwareOutputDevice() {}
18 void SoftwareOutputDevice::Resize(const gfx::Size& viewport_pixel_size,
19 float scale_factor) {
20 scale_factor_ = scale_factor;
22 if (viewport_pixel_size_ == viewport_pixel_size)
23 return;
25 SkImageInfo info = SkImageInfo::MakeN32(viewport_pixel_size.width(),
26 viewport_pixel_size.height(),
27 kOpaque_SkAlphaType);
28 viewport_pixel_size_ = viewport_pixel_size;
29 surface_ = skia::AdoptRef(SkSurface::NewRaster(info));
32 SkCanvas* SoftwareOutputDevice::BeginPaint(const gfx::Rect& damage_rect) {
33 damage_rect_ = damage_rect;
34 return surface_ ? surface_->getCanvas() : nullptr;
37 void SoftwareOutputDevice::EndPaint() {}
39 gfx::VSyncProvider* SoftwareOutputDevice::GetVSyncProvider() {
40 return vsync_provider_.get();
43 } // namespace cc