// Copyright (c) 2012 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/base_paths.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/logging.h"
#include "base/native_library.h"
#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_gl_api_implementation.h"
#include "ui/gl/gl_implementation.h"
#include <dlfcn.h>

namespace gfx {

static const char* OpenGLESFrameworkPath =
    "/System/Library/Frameworks/OpenGLES.framework/OpenGLES";

static void* OpenGLESLibraryHandle(void) {
  static void* library_handle = NULL;
  if (library_handle == NULL) {
    library_handle = dlopen(OpenGLESFrameworkPath, RTLD_NOW);
  }
  DCHECK(library_handle);
  return library_handle;
}

static void* OpenGLESGetProcAddress(const char* name) {
  return dlsym(OpenGLESLibraryHandle(), name);
}

void GetAllowedGLImplementations(std::vector<GLImplementation>* impls) {
  impls->push_back(kGLImplementationAppleGL);
}

bool InitializeStaticGLBindings(GLImplementation implementation) {
  DCHECK_EQ(kGLImplementationNone, GetGLImplementation());

  switch (implementation) {
    case kGLImplementationAppleGL:
      SetGLGetProcAddressProc(&OpenGLESGetProcAddress);
      SetGLImplementation(kGLImplementationAppleGL);
      InitializeStaticGLBindingsGL();

      return true;
    default:
      NOTIMPLEMENTED() << "InitializeStaticGLBindings on iOS";
      return false;
  }

  return false;
}

bool InitializeDynamicGLBindings(GLImplementation implementation,
                                 GLContext* context) {
  switch (implementation) {
    case kGLImplementationAppleGL:
      InitializeDynamicGLBindingsGL(context);
      break;
    default:
      NOTREACHED() << "InitializeDynamicGLBindings on iOS";
      return false;
  }
  return true;
}

void InitializeDebugGLBindings() {
  DCHECK(false);
}

void ClearGLBindings() {
  DCHECK(false);
}

bool GetGLWindowSystemBindingInfo(GLWindowSystemBindingInfo* info) {
  DCHECK(false);
  return false;
}

}  // namespace gfx
