// Copyright 2013 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "cc/software_output_device.h" #include "base/logging.h" #include "cc/software_frame_data.h" #include "third_party/skia/include/core/SkCanvas.h" #include "third_party/skia/include/core/SkDevice.h" namespace cc { SoftwareOutputDevice::SoftwareOutputDevice() {} SoftwareOutputDevice::~SoftwareOutputDevice() {} void SoftwareOutputDevice::Resize(const gfx::Size& viewport_size) { if (viewport_size_ == viewport_size) return; viewport_size_ = viewport_size; device_ = skia::AdoptRef(new SkDevice(SkBitmap::kARGB_8888_Config, viewport_size.width(), viewport_size.height(), true)); canvas_ = skia::AdoptRef(new SkCanvas(device_.get())); } SkCanvas* SoftwareOutputDevice::BeginPaint(const gfx::Rect& damage_rect) { DCHECK(device_); damage_rect_ = damage_rect; return canvas_.get(); } void SoftwareOutputDevice::EndPaint(SoftwareFrameData* frame_data) { DCHECK(device_); if (frame_data) { frame_data->damage_rect = damage_rect_; frame_data->content_dib = TransportDIB::DefaultHandleValue(); } } void SoftwareOutputDevice::CopyToBitmap( const gfx::Rect& rect, SkBitmap* output) { DCHECK(device_); SkIRect invertRect = SkIRect::MakeXYWH( rect.x(), viewport_size_.height() - rect.bottom(), rect.width(), rect.height()); const SkBitmap& bitmap = device_->accessBitmap(false); bitmap.extractSubset(output, invertRect); } void SoftwareOutputDevice::Scroll( const gfx::Vector2d& delta, const gfx::Rect& clip_rect) { NOTIMPLEMENTED(); } void SoftwareOutputDevice::ReclaimDIB(TransportDIB::Handle handle) { NOTIMPLEMENTED(); } } // namespace cc