Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(328)

Side by Side Diff: cc/paint/paint_canvas.cc

Issue 2739533003: Revert of Make cc/paint have concrete types (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/paint/paint_canvas.h ('k') | cc/paint/paint_flags.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/memory/ptr_util.h"
8 #include "cc/paint/paint_record.h"
9 #include "cc/paint/paint_recorder.h"
10 #include "third_party/skia/include/core/SkAnnotation.h"
11 #include "third_party/skia/include/core/SkMetaData.h" 7 #include "third_party/skia/include/core/SkMetaData.h"
12 #include "third_party/skia/include/utils/SkNWayCanvas.h"
13 8
14 #if defined(OS_MACOSX) 9 #if defined(OS_MACOSX)
15 namespace { 10 namespace {
16 const char kIsPreviewMetafileKey[] = "CrIsPreviewMetafile"; 11 const char kIsPreviewMetafileKey[] = "CrIsPreviewMetafile";
17 } 12 }
18 #endif 13 #endif
19 14
20 namespace cc { 15 namespace cc {
21 16
22 PaintCanvas::PaintCanvas(SkCanvas* canvas) : canvas_(canvas) {} 17 PaintCanvasPassThrough::PaintCanvasPassThrough(SkCanvas* canvas)
18 : SkNWayCanvas(canvas->getBaseLayerSize().width(),
19 canvas->getBaseLayerSize().height()) {
20 SkIRect raster_bounds;
21 canvas->getDeviceClipBounds(&raster_bounds);
22 clipRect(SkRect::MakeFromIRect(raster_bounds));
23 setMatrix(canvas->getTotalMatrix());
24 addCanvas(canvas);
25 }
23 26
24 PaintCanvas::PaintCanvas(const SkBitmap& bitmap) 27 PaintCanvasPassThrough::PaintCanvasPassThrough(int width, int height)
25 : canvas_(new SkCanvas(bitmap)), owned_(canvas_) {} 28 : SkNWayCanvas(width, height) {}
26 29
27 PaintCanvas::PaintCanvas(const SkBitmap& bitmap, const SkSurfaceProps& props) 30 PaintCanvasPassThrough::~PaintCanvasPassThrough() = default;
28 : canvas_(new SkCanvas(bitmap, props)), owned_(canvas_) {}
29
30 PaintCanvas::~PaintCanvas() = default;
31 31
32 bool ToPixmap(PaintCanvas* canvas, SkPixmap* output) { 32 bool ToPixmap(PaintCanvas* canvas, SkPixmap* output) {
33 SkImageInfo info; 33 SkImageInfo info;
34 size_t row_bytes; 34 size_t row_bytes;
35 void* pixels = canvas->canvas_->accessTopLayerPixels(&info, &row_bytes); 35 void* pixels = canvas->accessTopLayerPixels(&info, &row_bytes);
36 if (!pixels) { 36 if (!pixels) {
37 output->reset(); 37 output->reset();
38 return false; 38 return false;
39 } 39 }
40 40
41 output->reset(info, pixels, row_bytes); 41 output->reset(info, pixels, row_bytes);
42 return true; 42 return true;
43 } 43 }
44 44
45 #if defined(OS_MACOSX) 45 #if defined(OS_MACOSX)
46 void SetIsPreviewMetafile(PaintCanvas* canvas, bool is_preview) { 46 void SetIsPreviewMetafile(PaintCanvas* canvas, bool is_preview) {
47 SkMetaData& meta = canvas->getMetaData(); 47 SkMetaData& meta = canvas->getMetaData();
48 meta.setBool(kIsPreviewMetafileKey, is_preview); 48 meta.setBool(kIsPreviewMetafileKey, is_preview);
49 } 49 }
50 50
51 bool IsPreviewMetafile(PaintCanvas* canvas) { 51 bool IsPreviewMetafile(PaintCanvas* canvas) {
52 bool value; 52 bool value;
53 SkMetaData& meta = canvas->getMetaData(); 53 SkMetaData& meta = canvas->getMetaData();
54 if (!meta.findBool(kIsPreviewMetafileKey, &value)) 54 if (!meta.findBool(kIsPreviewMetafileKey, &value))
55 value = false; 55 value = false;
56 return value; 56 return value;
57 } 57 }
58 #endif 58 #endif
59 59
60 void PaintCanvasAnnotateRectWithURL(PaintCanvas* canvas,
61 const SkRect& rect,
62 SkData* data) {
63 SkAnnotateRectWithURL(canvas->canvas_, rect, data);
64 }
65
66 void PaintCanvasAnnotateNamedDestination(PaintCanvas* canvas,
67 const SkPoint& point,
68 SkData* data) {
69 SkAnnotateNamedDestination(canvas->canvas_, point, data);
70 }
71
72 void PaintCanvasAnnotateLinkToDestination(PaintCanvas* canvas,
73 const SkRect& rect,
74 SkData* data) {
75 SkAnnotateLinkToDestination(canvas->canvas_, rect, data);
76 }
77
78 } // namespace cc 60 } // namespace cc
OLDNEW
« no previous file with comments | « cc/paint/paint_canvas.h ('k') | cc/paint/paint_flags.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698