// Copyright (c) 2018 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool. If making changes by
// hand only do so within the body of existing method and function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=427e13e94fc15d32ee4586709961e7e26607eadd$
//

#include "libcef_dll/ctocpp/views/display_ctocpp.h"
#include <algorithm>

// STATIC METHODS - Body may be edited by hand.

CefRefPtr<CefDisplay> CefDisplay::GetPrimaryDisplay() {
  // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING

  // Execute
  cef_display_t* _retval = cef_display_get_primary();

  // Return type: refptr_same
  return CefDisplayCToCpp::Wrap(_retval);
}

CefRefPtr<CefDisplay> CefDisplay::GetDisplayNearestPoint(
    const CefPoint& point,
    bool input_pixel_coords) {
  // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING

  // Execute
  cef_display_t* _retval =
      cef_display_get_nearest_point(&point, input_pixel_coords);

  // Return type: refptr_same
  return CefDisplayCToCpp::Wrap(_retval);
}

CefRefPtr<CefDisplay> CefDisplay::GetDisplayMatchingBounds(
    const CefRect& bounds,
    bool input_pixel_coords) {
  // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING

  // Execute
  cef_display_t* _retval =
      cef_display_get_matching_bounds(&bounds, input_pixel_coords);

  // Return type: refptr_same
  return CefDisplayCToCpp::Wrap(_retval);
}

size_t CefDisplay::GetDisplayCount() {
  // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING

  // Execute
  size_t _retval = cef_display_get_count();

  // Return type: simple
  return _retval;
}

void CefDisplay::GetAllDisplays(std::vector<CefRefPtr<CefDisplay>>& displays) {
  // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING

  // Translate param: displays; type: refptr_vec_same_byref
  size_t displaysSize = displays.size();
  size_t displaysCount = std::max(GetDisplayCount(), displaysSize);
  cef_display_t** displaysList = NULL;
  if (displaysCount > 0) {
    displaysList = new cef_display_t*[displaysCount];
    DCHECK(displaysList);
    if (displaysList) {
      memset(displaysList, 0, sizeof(cef_display_t*) * displaysCount);
    }
    if (displaysList && displaysSize > 0) {
      for (size_t i = 0; i < displaysSize; ++i) {
        displaysList[i] = CefDisplayCToCpp::Unwrap(displays[i]);
      }
    }
  }

  // Execute
  cef_display_get_alls(&displaysCount, displaysList);

  // Restore param:displays; type: refptr_vec_same_byref
  displays.clear();
  if (displaysCount > 0 && displaysList) {
    for (size_t i = 0; i < displaysCount; ++i) {
      displays.push_back(CefDisplayCToCpp::Wrap(displaysList[i]));
    }
    delete[] displaysList;
  }
}

// VIRTUAL METHODS - Body may be edited by hand.

int64 CefDisplayCToCpp::GetID() {
  cef_display_t* _struct = GetStruct();
  if (CEF_MEMBER_MISSING(_struct, get_id))
    return 0;

  // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING

  // Execute
  int64 _retval = _struct->get_id(_struct);

  // Return type: simple
  return _retval;
}

float CefDisplayCToCpp::GetDeviceScaleFactor() {
  cef_display_t* _struct = GetStruct();
  if (CEF_MEMBER_MISSING(_struct, get_device_scale_factor))
    return 0;

  // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING

  // Execute
  float _retval = _struct->get_device_scale_factor(_struct);

  // Return type: simple
  return _retval;
}

void CefDisplayCToCpp::ConvertPointToPixels(CefPoint& point) {
  cef_display_t* _struct = GetStruct();
  if (CEF_MEMBER_MISSING(_struct, convert_point_to_pixels))
    return;

  // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING

  // Execute
  _struct->convert_point_to_pixels(_struct, &point);
}

void CefDisplayCToCpp::ConvertPointFromPixels(CefPoint& point) {
  cef_display_t* _struct = GetStruct();
  if (CEF_MEMBER_MISSING(_struct, convert_point_from_pixels))
    return;

  // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING

  // Execute
  _struct->convert_point_from_pixels(_struct, &point);
}

CefRect CefDisplayCToCpp::GetBounds() {
  cef_display_t* _struct = GetStruct();
  if (CEF_MEMBER_MISSING(_struct, get_bounds))
    return CefRect();

  // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING

  // Execute
  cef_rect_t _retval = _struct->get_bounds(_struct);

  // Return type: simple
  return _retval;
}

CefRect CefDisplayCToCpp::GetWorkArea() {
  cef_display_t* _struct = GetStruct();
  if (CEF_MEMBER_MISSING(_struct, get_work_area))
    return CefRect();

  // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING

  // Execute
  cef_rect_t _retval = _struct->get_work_area(_struct);

  // Return type: simple
  return _retval;
}

int CefDisplayCToCpp::GetRotation() {
  cef_display_t* _struct = GetStruct();
  if (CEF_MEMBER_MISSING(_struct, get_rotation))
    return 0;

  // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING

  // Execute
  int _retval = _struct->get_rotation(_struct);

  // Return type: simple
  return _retval;
}

// CONSTRUCTOR - Do not edit by hand.

CefDisplayCToCpp::CefDisplayCToCpp() {}

template <>
cef_display_t*
CefCToCppRefCounted<CefDisplayCToCpp, CefDisplay, cef_display_t>::UnwrapDerived(
    CefWrapperType type,
    CefDisplay* c) {
  NOTREACHED() << "Unexpected class type: " << type;
  return NULL;
}

#if DCHECK_IS_ON()
template <>
base::AtomicRefCount
    CefCToCppRefCounted<CefDisplayCToCpp, CefDisplay, cef_display_t>::DebugObjCt
        ATOMIC_DECLARATION;
#endif

template <>
CefWrapperType CefCToCppRefCounted<CefDisplayCToCpp,
                                   CefDisplay,
                                   cef_display_t>::kWrapperType = WT_DISPLAY;
