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 #include "third_party/skia/include/core/SkMetaData.h" |
| 8 |
| 9 #if defined(OS_MACOSX) |
| 10 namespace { |
| 11 const char kIsPreviewMetafileKey[] = "CrIsPreviewMetafile"; |
| 12 } |
| 13 #endif |
| 14 |
7 namespace cc { | 15 namespace cc { |
8 | 16 |
9 PaintCanvasPassThrough::PaintCanvasPassThrough(SkCanvas* canvas) | 17 PaintCanvasPassThrough::PaintCanvasPassThrough(SkCanvas* canvas) |
10 : SkNWayCanvas(canvas->getBaseLayerSize().width(), | 18 : SkNWayCanvas(canvas->getBaseLayerSize().width(), |
11 canvas->getBaseLayerSize().height()) { | 19 canvas->getBaseLayerSize().height()) { |
12 SkIRect raster_bounds; | 20 SkIRect raster_bounds; |
13 canvas->getDeviceClipBounds(&raster_bounds); | 21 canvas->getDeviceClipBounds(&raster_bounds); |
14 clipRect(SkRect::MakeFromIRect(raster_bounds)); | 22 clipRect(SkRect::MakeFromIRect(raster_bounds)); |
15 setMatrix(canvas->getTotalMatrix()); | 23 setMatrix(canvas->getTotalMatrix()); |
16 addCanvas(canvas); | 24 addCanvas(canvas); |
(...skipping 10 matching lines...) Expand all Loading... |
27 void* pixels = canvas->accessTopLayerPixels(&info, &row_bytes); | 35 void* pixels = canvas->accessTopLayerPixels(&info, &row_bytes); |
28 if (!pixels) { | 36 if (!pixels) { |
29 output->reset(); | 37 output->reset(); |
30 return false; | 38 return false; |
31 } | 39 } |
32 | 40 |
33 output->reset(info, pixels, row_bytes); | 41 output->reset(info, pixels, row_bytes); |
34 return true; | 42 return true; |
35 } | 43 } |
36 | 44 |
| 45 #if defined(OS_MACOSX) |
| 46 void SetIsPreviewMetafile(PaintCanvas* canvas, bool is_preview) { |
| 47 SkMetaData& meta = canvas->getMetaData(); |
| 48 meta.setBool(kIsPreviewMetafileKey, is_preview); |
| 49 } |
| 50 |
| 51 bool IsPreviewMetafile(PaintCanvas* canvas) { |
| 52 bool value; |
| 53 SkMetaData& meta = canvas->getMetaData(); |
| 54 if (!meta.findBool(kIsPreviewMetafileKey, &value)) |
| 55 value = false; |
| 56 return value; |
| 57 } |
| 58 #endif |
| 59 |
37 } // namespace cc | 60 } // namespace cc |
OLD | NEW |