OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #include "cc/software_output_device_impl.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 #include "third_party/skia/include/core/SkCanvas.h" |
| 9 #include "third_party/skia/include/core/SkDevice.h" |
| 10 |
| 11 namespace cc { |
| 12 |
| 13 SoftwareOutputDeviceImpl::SoftwareOutputDeviceImpl() {} |
| 14 |
| 15 SoftwareOutputDeviceImpl::~SoftwareOutputDeviceImpl() {} |
| 16 |
| 17 SkCanvas* SoftwareOutputDeviceImpl::BeginPaint() { |
| 18 DCHECK(device_); |
| 19 return canvas_.get(); |
| 20 } |
| 21 |
| 22 void SoftwareOutputDeviceImpl::EndPaint(const gfx::Rect& damage_rect) { |
| 23 DCHECK(device_); |
| 24 } |
| 25 |
| 26 void SoftwareOutputDeviceImpl::Resize(const gfx::Size& viewport_size) { |
| 27 if (viewport_size_ == viewport_size) |
| 28 return; |
| 29 |
| 30 viewport_size_ = viewport_size; |
| 31 device_ = skia::AdoptRef(new SkDevice(SkBitmap::kARGB_8888_Config, |
| 32 viewport_size.width(), viewport_size.height(), true)); |
| 33 canvas_ = skia::AdoptRef(new SkCanvas(device_.get())); |
| 34 } |
| 35 |
| 36 void SoftwareOutputDeviceImpl::CopyToBitmap( |
| 37 const gfx::Rect& rect, SkBitmap* output) { |
| 38 DCHECK(device_); |
| 39 SkIRect invertRect = SkIRect::MakeXYWH( |
| 40 rect.x(), viewport_size_.height() - rect.bottom(), |
| 41 rect.width(), rect.height()); |
| 42 const SkBitmap& bitmap = device_->accessBitmap(false); |
| 43 bitmap.extractSubset(output, invertRect); |
| 44 } |
| 45 |
| 46 void SoftwareOutputDeviceImpl::Scroll( |
| 47 const gfx::Vector2d& delta, const gfx::Rect& clip_rect) { |
| 48 NOTIMPLEMENTED(); |
| 49 } |
| 50 |
| 51 } // namespace cc |
OLD | NEW |