Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 "base/logging.h" | 5 #include "base/logging.h" |
| 6 #include "skia/ext/platform_device.h" | 6 #include "skia/ext/platform_device.h" |
| 7 | 7 |
| 8 #include "third_party/skia/include/core/SkMetaData.h" | 8 #include "third_party/skia/include/core/SkMetaData.h" |
| 9 | 9 |
| 10 namespace skia { | 10 namespace skia { |
| 11 | 11 |
| 12 namespace { | 12 namespace { |
| 13 | 13 |
| 14 const char* kDevicePlatformBehaviour = "CrDevicePlatformBehaviour"; | 14 const char* kDevicePlatformBehaviour = "CrDevicePlatformBehaviour"; |
|
Lei Zhang
2015/11/18 20:19:35
BTW, these should be const char kFoo[];
Right now
| |
| 15 const char* kDraftModeKey = "CrDraftMode"; | 15 const char* kDraftModeKey = "CrDraftMode"; |
|
Lei Zhang
2015/11/18 20:19:35
Remove as well?
| |
| 16 | 16 |
| 17 #if defined(OS_MACOSX) || defined(OS_WIN) | 17 #if defined(OS_MACOSX) || defined(OS_WIN) |
|
Lei Zhang
2015/11/18 20:19:35
Also Mac-only?
| |
| 18 const char* kIsPreviewMetafileKey = "CrIsPreviewMetafile"; | 18 const char* kIsPreviewMetafileKey = "CrIsPreviewMetafile"; |
| 19 #endif | 19 #endif |
| 20 | 20 |
| 21 void SetBoolMetaData(const SkCanvas& canvas, const char* key, bool value) { | 21 void SetBoolMetaData(const SkCanvas& canvas, const char* key, bool value) { |
| 22 SkMetaData& meta = skia::getMetaData(canvas); | 22 SkMetaData& meta = skia::getMetaData(canvas); |
| 23 meta.setBool(key, value); | 23 meta.setBool(key, value); |
| 24 } | 24 } |
| 25 | 25 |
| 26 bool GetBoolMetaData(const SkCanvas& canvas, const char* key) { | 26 bool GetBoolMetaData(const SkCanvas& canvas, const char* key) { |
| 27 bool value; | 27 bool value; |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 48 } | 48 } |
| 49 return NULL; | 49 return NULL; |
| 50 } | 50 } |
| 51 | 51 |
| 52 SkMetaData& getMetaData(const SkCanvas& canvas) { | 52 SkMetaData& getMetaData(const SkCanvas& canvas) { |
| 53 SkBaseDevice* device = canvas.getDevice(); | 53 SkBaseDevice* device = canvas.getDevice(); |
| 54 DCHECK(device != NULL); | 54 DCHECK(device != NULL); |
| 55 return device->getMetaData(); | 55 return device->getMetaData(); |
| 56 } | 56 } |
| 57 | 57 |
| 58 void SetIsDraftMode(const SkCanvas& canvas, bool draft_mode) { | 58 #if defined(OS_MACOSX) |
| 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) { | 59 void SetIsPreviewMetafile(const SkCanvas& canvas, bool is_preview) { |
| 68 SetBoolMetaData(canvas, kIsPreviewMetafileKey, is_preview); | 60 SetBoolMetaData(canvas, kIsPreviewMetafileKey, is_preview); |
| 69 } | 61 } |
| 70 | 62 |
| 71 bool IsPreviewMetafile(const SkCanvas& canvas) { | 63 bool IsPreviewMetafile(const SkCanvas& canvas) { |
| 72 return GetBoolMetaData(canvas, kIsPreviewMetafileKey); | 64 return GetBoolMetaData(canvas, kIsPreviewMetafileKey); |
| 73 } | 65 } |
| 74 #endif | 66 #endif |
| 75 | 67 |
| 76 bool PlatformDevice::SupportsPlatformPaint() { | 68 bool PlatformDevice::SupportsPlatformPaint() { |
| 77 return true; | 69 return true; |
| 78 } | 70 } |
| 79 | 71 |
| 80 } // namespace skia | 72 } // namespace skia |
| OLD | NEW |