Chromium Code Reviews| 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.h" | |
| 6 | |
| 7 #include "base/logging.h" | |
| 8 #include "cc/software_frame_data.h" | |
| 9 #include "third_party/skia/include/core/SkCanvas.h" | |
| 10 #include "third_party/skia/include/core/SkDevice.h" | |
| 11 | |
| 12 namespace cc { | |
| 13 | |
| 14 SoftwareOutputDevice::SoftwareOutputDevice() {} | |
| 15 | |
| 16 SoftwareOutputDevice::~SoftwareOutputDevice() {} | |
| 17 | |
| 18 void SoftwareOutputDevice::Resize(const gfx::Size& viewport_size) { | |
| 19 if (viewport_size_ == viewport_size) | |
| 20 return; | |
| 21 | |
| 22 viewport_size_ = viewport_size; | |
| 23 device_ = skia::AdoptRef(new SkDevice(SkBitmap::kARGB_8888_Config, | |
| 24 viewport_size.width(), viewport_size.height(), true)); | |
| 25 canvas_ = skia::AdoptRef(new SkCanvas(device_.get())); | |
| 26 } | |
| 27 | |
| 28 SkCanvas* SoftwareOutputDevice::BeginPaint(const gfx::Rect& damage_rect) { | |
| 29 DCHECK(device_); | |
| 30 damage_rect_ = damage_rect; | |
| 31 return canvas_.get(); | |
| 32 } | |
| 33 | |
| 34 void SoftwareOutputDevice::EndPaint(SoftwareFrameData* frame_data) { | |
| 35 DCHECK(device_); | |
| 36 if (frame_data) { | |
| 37 frame_data->damage_rect = damage_rect_; | |
| 38 frame_data->content_dib = TransportDIB::DefaultHandleValue(); | |
| 39 } | |
| 40 } | |
| 41 | |
| 42 void SoftwareOutputDevice::CopyToBitmap( | |
| 43 const gfx::Rect& rect, SkBitmap* output) { | |
| 44 DCHECK(device_); | |
| 45 SkIRect invertRect = SkIRect::MakeXYWH( | |
| 46 rect.x(), viewport_size_.height() - rect.bottom(), | |
| 47 rect.width(), rect.height()); | |
| 48 const SkBitmap& bitmap = device_->accessBitmap(false); | |
| 49 bitmap.extractSubset(output, invertRect); | |
| 50 } | |
| 51 | |
| 52 void SoftwareOutputDevice::Scroll( | |
| 53 const gfx::Vector2d& delta, const gfx::Rect& clip_rect) { | |
| 54 NOTIMPLEMENTED(); | |
|
Ken Russell (switch to Gerrit)
2013/03/01 23:17:09
Should there be some way to inform callers that th
| |
| 55 } | |
| 56 | |
| 57 void SoftwareOutputDevice::ReclaimDIB(TransportDIB::Handle handle) { | |
| 58 NOTIMPLEMENTED(); | |
| 59 } | |
| 60 | |
| 61 } // namespace cc | |
| OLD | NEW |