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

Side by Side Diff: skia/ext/platform_device.cc

Issue 2011713003: Roll skia to 8cc209111876b7c78b5ec577c9221d8ed5e21024 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 7 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 | « skia/ext/platform_device.h ('k') | skia/ext/platform_device_linux.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 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 "base/logging.h"
6 #include "skia/ext/platform_device.h"
7
8 #include "third_party/skia/include/core/SkMetaData.h"
9
10 namespace skia {
11
12 namespace {
13
14 const char* kDevicePlatformBehaviour = "CrDevicePlatformBehaviour";
15 const char* kDraftModeKey = "CrDraftMode";
16
17 #if defined(OS_MACOSX) || defined(OS_WIN)
18 const char* kIsPreviewMetafileKey = "CrIsPreviewMetafile";
19 #endif
20
21 void SetBoolMetaData(const SkCanvas& canvas, const char* key, bool value) {
22 SkMetaData& meta = skia::getMetaData(canvas);
23 meta.setBool(key, value);
24 }
25
26 bool GetBoolMetaData(const SkCanvas& canvas, const char* key) {
27 bool value;
28 SkMetaData& meta = skia::getMetaData(canvas);
29 if (!meta.findBool(key, &value))
30 value = false;
31 return value;
32 }
33
34 } // namespace
35
36 void SetPlatformDevice(SkBaseDevice* device, PlatformDevice* platform_behaviour) {
37 SkMetaData& meta_data = device->getMetaData();
38 meta_data.setPtr(kDevicePlatformBehaviour, platform_behaviour);
39 }
40
41 PlatformDevice* GetPlatformDevice(SkBaseDevice* device) {
42 if (device) {
43 SkMetaData& meta_data = device->getMetaData();
44 PlatformDevice* device_behaviour = NULL;
45 if (meta_data.findPtr(kDevicePlatformBehaviour,
46 reinterpret_cast<void**>(&device_behaviour)))
47 return device_behaviour;
48 }
49 return NULL;
50 }
51
52 SkMetaData& getMetaData(const SkCanvas& canvas) {
53 SkBaseDevice* device = canvas.getDevice();
54 DCHECK(device != NULL);
55 return device->getMetaData();
56 }
57
58 void SetIsDraftMode(const SkCanvas& canvas, bool draft_mode) {
59 SetBoolMetaData(canvas, kDraftModeKey, draft_mode);
60 }
61
62 bool IsDraftMode(const SkCanvas& canvas) {
63 return GetBoolMetaData(canvas, kDraftModeKey);
64 }
65
66 #if defined(OS_MACOSX) || defined(OS_WIN)
67 void SetIsPreviewMetafile(const SkCanvas& canvas, bool is_preview) {
68 SetBoolMetaData(canvas, kIsPreviewMetafileKey, is_preview);
69 }
70
71 bool IsPreviewMetafile(const SkCanvas& canvas) {
72 return GetBoolMetaData(canvas, kIsPreviewMetafileKey);
73 }
74 #endif
75
76 // For platforms without "platform_device_*" specific files,
77 // include default behaviors for necessary methods to compile.
78 #if defined(OS_NACL)
79 PlatformSurface PlatformDevice::BeginPlatformPaint() {
80 return NULL;
81 }
82
83 void PlatformDevice::EndPlatformPaint() {
84 // By default, do nothing here.
85 }
86 #endif
87
88 bool PlatformDevice::SupportsPlatformPaint() {
89 return true;
90 }
91
92 } // namespace skia
OLDNEW
« no previous file with comments | « skia/ext/platform_device.h ('k') | skia/ext/platform_device_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698