OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 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 "ppapi/cpp/private/camera_capabilities_private.h" |
| 6 |
| 7 #include "ppapi/c/pp_bool.h" |
| 8 #include "ppapi/c/pp_size.h" |
| 9 #include "ppapi/cpp/instance_handle.h" |
| 10 #include "ppapi/cpp/module_impl.h" |
| 11 |
| 12 namespace pp { |
| 13 |
| 14 namespace { |
| 15 |
| 16 template <> |
| 17 const char* interface_name<PPB_CameraCapabilities_Private_0_1>() { |
| 18 return PPB_CAMERACAPABILITIES_PRIVATE_INTERFACE_0_1; |
| 19 } |
| 20 |
| 21 } // namespace |
| 22 |
| 23 CameraCapabilities_Private::CameraCapabilities_Private() { |
| 24 } |
| 25 |
| 26 CameraCapabilities_Private::CameraCapabilities_Private( |
| 27 const CameraCapabilities_Private& other) |
| 28 : Resource(other) { |
| 29 } |
| 30 |
| 31 CameraCapabilities_Private::CameraCapabilities_Private(const Resource& resource) |
| 32 : Resource(resource) { |
| 33 PP_DCHECK(IsCameraCapabilities(resource)); |
| 34 } |
| 35 |
| 36 CameraCapabilities_Private::CameraCapabilities_Private(PassRef, |
| 37 PP_Resource resource) |
| 38 : Resource(PASS_REF, resource) { |
| 39 } |
| 40 |
| 41 CameraCapabilities_Private::~CameraCapabilities_Private() { |
| 42 } |
| 43 |
| 44 void CameraCapabilities_Private::GetSupportedPreviewSizes( |
| 45 std::vector<Size>* preview_sizes) { |
| 46 if (!has_interface<PPB_CameraCapabilities_Private_0_1>()) { |
| 47 PP_DCHECK(false); |
| 48 return; |
| 49 } |
| 50 |
| 51 int32_t array_size; |
| 52 PP_Size* array; |
| 53 get_interface<PPB_CameraCapabilities_Private_0_1>()->GetSupportedPreviewSizes( |
| 54 pp_resource(), &array_size, &array); |
| 55 preview_sizes->clear(); |
| 56 preview_sizes->reserve(array_size); |
| 57 for (int32_t i = 0; i < array_size; i++) { |
| 58 preview_sizes->push_back(Size(array[i])); |
| 59 } |
| 60 } |
| 61 |
| 62 // static |
| 63 bool CameraCapabilities_Private::IsCameraCapabilities( |
| 64 const Resource& resource) { |
| 65 if (!has_interface<PPB_CameraCapabilities_Private_0_1>()) |
| 66 return false; |
| 67 |
| 68 return PP_ToBool( |
| 69 get_interface<PPB_CameraCapabilities_Private_0_1>()->IsCameraCapabilities( |
| 70 resource.pp_resource())); |
| 71 } |
| 72 |
| 73 } // namespace pp |
OLD | NEW |