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

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

Issue 7633040: CL removing inheritance of SkDevice from PlatformDevice. Flavours of PlatformDevice classes now ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Add mac changes. Created 9 years, 4 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 | Annotate | Revision Log
OLDNEW
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 "skia/ext/platform_device.h" 5 #include "skia/ext/platform_device.h"
6 6
7 #include "third_party/skia/include/core/SkMetaData.h" 7 #include "third_party/skia/include/core/SkMetaData.h"
8 8
9 namespace skia { 9 namespace skia {
10 10
11 namespace { 11 namespace {
12
12 const char* kDevicePlatformBehaviour = "CrDevicePlatformBehaviour"; 13 const char* kDevicePlatformBehaviour = "CrDevicePlatformBehaviour";
14
15 void* PlatformDevicePtrProc(void* ptr, bool doRef) {
16 SkASSERT(ptr);
17 PlatformDevice* platform_device = reinterpret_cast<PlatformDevice*>(ptr);
18
19 if (!doRef) {
20 delete platform_device;
21 return NULL;
22 }
23
24 return ptr;
13 } 25 }
14 26
15 void SetPlatformDevice(SkDevice* device, PlatformDevice* platform_behaviour) { 27 }
28
29 void SetPlatformDevice(SkDevice* device, PlatformDevice* platform_behaviour,
30 bool transfer_ownership) {
16 SkMetaData& meta_data = device->getMetaData(); 31 SkMetaData& meta_data = device->getMetaData();
17 meta_data.setPtr(kDevicePlatformBehaviour, platform_behaviour); 32
33 if (transfer_ownership) {
34 meta_data.setPtr(kDevicePlatformBehaviour, platform_behaviour,
35 PlatformDevicePtrProc);
36 } else {
37 meta_data.setPtr(kDevicePlatformBehaviour, platform_behaviour);
38 }
18 } 39 }
19 40
20 PlatformDevice* GetPlatformDevice(SkDevice* device) { 41 PlatformDevice* GetPlatformDevice(SkDevice* device) {
21 SkMetaData& meta_data = device->getMetaData(); 42 SkMetaData& meta_data = device->getMetaData();
22 PlatformDevice* device_behaviour = NULL; 43 PlatformDevice* device_behaviour = NULL;
23 if (meta_data.findPtr(kDevicePlatformBehaviour, 44 if (meta_data.findPtr(kDevicePlatformBehaviour,
24 reinterpret_cast<void**>(&device_behaviour))) 45 reinterpret_cast<void**>(&device_behaviour)))
25 return device_behaviour; 46 return device_behaviour;
26 47
27 return NULL; 48 return NULL;
28 } 49 }
29 50
30 } // namespace skia 51 } // namespace skia
31 52
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698