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