OLD | NEW |
---|---|
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/paint/paint_canvas.h" | 5 #include "cc/paint/paint_canvas.h" |
6 | 6 |
7 namespace cc { | 7 namespace cc { |
8 | 8 |
9 PaintCanvasPassThrough::PaintCanvasPassThrough(SkCanvas* canvas) | 9 PaintCanvasPassThrough::PaintCanvasPassThrough(SkCanvas* canvas) |
10 : SkNWayCanvas(canvas->getBaseLayerSize().width(), | 10 : SkNWayCanvas(canvas->getBaseLayerSize().width(), |
11 canvas->getBaseLayerSize().height()) { | 11 canvas->getBaseLayerSize().height()) { |
12 SkIRect raster_bounds; | 12 SkIRect raster_bounds; |
13 canvas->getDeviceClipBounds(&raster_bounds); | 13 canvas->getDeviceClipBounds(&raster_bounds); |
14 clipRect(SkRect::MakeFromIRect(raster_bounds)); | 14 clipRect(SkRect::MakeFromIRect(raster_bounds)); |
15 setMatrix(canvas->getTotalMatrix()); | 15 setMatrix(canvas->getTotalMatrix()); |
16 addCanvas(canvas); | 16 addCanvas(canvas); |
17 } | 17 } |
18 | 18 |
19 PaintCanvasPassThrough::PaintCanvasPassThrough(int width, int height) | 19 PaintCanvasPassThrough::PaintCanvasPassThrough(int width, int height) |
20 : SkNWayCanvas(width, height) {} | 20 : SkNWayCanvas(width, height) {} |
21 | 21 |
22 PaintCanvasPassThrough::~PaintCanvasPassThrough() = default; | 22 PaintCanvasPassThrough::~PaintCanvasPassThrough() = default; |
23 | 23 |
24 bool ToPixmap(PaintCanvas* canvas, SkPixmap* output) { | |
25 if (!canvas || !output) { | |
danakj
2017/02/09 23:13:50
ಠ_ಠ
is needed?
danakj
2017/02/09 23:23:58
I can't see why this would be needed, so LGTM with
| |
26 return false; | |
27 } | |
28 | |
29 SkImageInfo info; | |
30 size_t row_bytes; | |
31 void* pixels = canvas->accessTopLayerPixels(&info, &row_bytes); | |
32 if (!pixels) { | |
33 output->reset(); | |
34 return false; | |
35 } | |
36 | |
37 output->reset(info, pixels, row_bytes); | |
38 return true; | |
39 } | |
40 | |
24 } // namespace cc | 41 } // namespace cc |
OLD | NEW |