summaryrefslogtreecommitdiffstats
path: root/skia/ext/platform_device.cc
blob: b6748fc636d0c50ff4688fe5601522fe8db8f848 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "base/logging.h"
#include "skia/ext/platform_device.h"

#include "third_party/skia/include/core/SkMetaData.h"

namespace {

const char kDevicePlatformBehaviour[] = "CrDevicePlatformBehaviour";

}  // namespace

namespace skia {

void SetPlatformDevice(SkBaseDevice* device, PlatformDevice* platform_behaviour) {
  SkMetaData& meta_data = device->getMetaData();
  meta_data.setPtr(kDevicePlatformBehaviour, platform_behaviour);
}

PlatformDevice* GetPlatformDevice(SkBaseDevice* device) {
  if (device) {
    SkMetaData& meta_data = device->getMetaData();
    PlatformDevice* device_behaviour = NULL;
    if (meta_data.findPtr(kDevicePlatformBehaviour,
                          reinterpret_cast<void**>(&device_behaviour)))
      return device_behaviour;
  }
  return NULL;
}

}  // namespace skia