| OLD | NEW |
| (Empty) | |
| 1 # Copyright (c) 2013 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 class GPUDevice(object): |
| 6 """Provides information about an individual GPU device. |
| 7 |
| 8 On platforms which support them, the vendor_id and device_id are |
| 9 PCI IDs. On other platforms, the vendor_string and device_string |
| 10 are platform-dependent strings. |
| 11 """ |
| 12 |
| 13 def __init__(self, vendor_id, device_id, vendor_string, device_string): |
| 14 self._vendor_id = vendor_id |
| 15 self._device_id = device_id |
| 16 self._vendor_string = vendor_string |
| 17 self._device_string = device_string |
| 18 |
| 19 @classmethod |
| 20 def FromDict(cls, attrs): |
| 21 """Constructs a GPUDevice from a dictionary. Requires the |
| 22 following attributes to be present in the dictionary: |
| 23 |
| 24 vendor_id |
| 25 device_id |
| 26 vendor_string |
| 27 device_string |
| 28 |
| 29 Raises an exception if any attributes are missing. |
| 30 """ |
| 31 return cls(attrs["vendor_id"], attrs["device_id"], |
| 32 attrs["vendor_string"], attrs["device_string"]) |
| 33 |
| 34 @property |
| 35 def vendor_id(self): |
| 36 """The GPU vendor's PCI ID as a number, or 0 if not available. |
| 37 |
| 38 Most desktop machines supply this information rather than the |
| 39 vendor and device strings.""" |
| 40 return self._vendor_id |
| 41 |
| 42 @property |
| 43 def device_id(self): |
| 44 """The GPU device's PCI ID as a number, or 0 if not available. |
| 45 |
| 46 Most desktop machines supply this information rather than the |
| 47 vendor and device strings.""" |
| 48 return self._device_id |
| 49 |
| 50 @property |
| 51 def vendor_string(self): |
| 52 """The GPU vendor's name as a string, or the empty string if not |
| 53 available. |
| 54 |
| 55 Most mobile devices supply this information rather than the PCI |
| 56 IDs.""" |
| 57 return self._vendor_string |
| 58 |
| 59 @property |
| 60 def device_string(self): |
| 61 """The GPU device's name as a string, or the empty string if not |
| 62 available. |
| 63 |
| 64 Most mobile devices supply this information rather than the PCI |
| 65 IDs.""" |
| 66 return self._device_string |
| OLD | NEW |