Exemplo n.º 1
0
void ClientOSRenderer::OnPaint(CefRefPtr<CefBrowser> browser,
                               CefRenderHandler::PaintElementType type,
                               const CefRenderHandler::RectList& dirtyRects,
                               const void* buffer, int width, int height) {
  if (!initialized_)
    Initialize();

  if (transparent_) {
    // Enable alpha blending.
    glEnable(GL_BLEND); VERIFY_NO_ERROR;
  }

  // Enable 2D textures.
  glEnable(GL_TEXTURE_2D); VERIFY_NO_ERROR;

  DCHECK_NE(texture_id_, 0U);
  glBindTexture(GL_TEXTURE_2D, texture_id_); VERIFY_NO_ERROR;

  if (type == PET_VIEW) {
    int old_width = view_width_;
    int old_height = view_height_;

    view_width_ = width;
	view_height_ = height;

	{
		int linebyte = (((width << 5) + 31) >> 5) << 2;

		int lineInval = 4 - ((width << 5) >> 3) & 3;
	}

    if (show_update_rect_)
      update_rect_ = dirtyRects[0];

    glPixelStorei(GL_UNPACK_ROW_LENGTH, view_width_); VERIFY_NO_ERROR;

    if (old_width != view_width_ || old_height != view_height_ ||
        (dirtyRects.size() == 1 &&
         dirtyRects[0] == CefRect(0, 0, view_width_, view_height_))) {
      // Update/resize the whole texture.
      glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0); VERIFY_NO_ERROR;
      glPixelStorei(GL_UNPACK_SKIP_ROWS, 0); VERIFY_NO_ERROR;	
	  test32Bmp(buffer, width, height);
      glTexImage2D(
          GL_TEXTURE_2D, 0, GL_RGBA, view_width_, view_height_, 0,
          GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, buffer); VERIFY_NO_ERROR;
    } else {
      // Update just the dirty rectangles.
      CefRenderHandler::RectList::const_iterator i = dirtyRects.begin();
      for (; i != dirtyRects.end(); ++i) {
        const CefRect& rect = *i;
        glPixelStorei(GL_UNPACK_SKIP_PIXELS, rect.x); VERIFY_NO_ERROR;
        glPixelStorei(GL_UNPACK_SKIP_ROWS, rect.y); VERIFY_NO_ERROR;
		test32Bmp(buffer, width, height);
        glTexSubImage2D(GL_TEXTURE_2D, 0, rect.x, rect.y, rect.width,
                        rect.height, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
                        buffer); VERIFY_NO_ERROR;
      }
    }
  } else if (type == PET_POPUP && popup_rect_.width > 0 &&
Exemplo n.º 2
0
bool ClientHandler::GetRootScreenRect(CefRefPtr<CefBrowser> browser, CefRect &rect)
{
	auto client = getClient(browser);
	if (!client)
		return false;
	rect = CefRect(0, 0, client->getWidth(), client->getHeight());
	return true;
}
Exemplo n.º 3
0
bool RenderHandler::GetViewRect(CefRefPtr<CefBrowser> browser, CefRect &rect)
{
    rect = CefRect(0, 0, m_texture->getWidth(), m_texture->getHeight());
    return true;
}
Exemplo n.º 4
0
bool RenderHandler::GetViewRect(CefRefPtr<CefBrowser> browser, CefRect &rect)
{
	rect = CefRect(0, 0, Width, Height);
	return true;
}
Exemplo n.º 5
0
bool ClientHandler::GetViewRect(CefRefPtr<CefBrowser> browser, CefRect &rect) {
    rect = CefRect(0, 0, renderTexture->getWidth(), renderTexture->getHeight());
    return true;
}
Exemplo n.º 6
0
 bool GetViewRect(CefRefPtr<CefBrowser> browser, CefRect &rect) {
     int width = 1280;
     int height = 720;
     rect = CefRect(0, 0, width, height);
     return true;
 }
Exemplo n.º 7
0
 bool GetViewRect(CefRefPtr<CefBrowser> browser, CefRect &rect)
 {
     rect = CefRect(0, 0, 1024, 768);
     return true;
 }
Exemplo n.º 8
0
int main(int argc, char* argv[]) {
  CefMainArgs main_args(argc, argv);

  g_appStartupTime = time(NULL);

  gtk_init(&argc, &argv);
  CefRefPtr<ClientApp> app(new ClientApp);

  // Execute the secondary process, if any.
  int exit_code = CefExecuteProcess(main_args, app.get(), NULL);
  if (exit_code >= 0)
    return exit_code;

  //Retrieve the current working directory
  if (!getcwd(szWorkingDir, sizeof (szWorkingDir)))
    return -1;

  // Parse command line arguments.
  AppInitCommandLine(argc, argv);

  // Install xlib error handlers so that the application won't be terminated
  // on non-fatal errors.
  XSetErrorHandler(XErrorHandlerImpl);
  XSetIOErrorHandler(XIOErrorHandlerImpl);

  CefSettings settings;

  // Populate the settings based on command line arguments.
  AppGetSettings(settings, app);

  settings.no_sandbox = TRUE;

  // Check cache_path setting
  if (CefString(&settings.cache_path).length() == 0) {
    CefString(&settings.cache_path) = AppGetCachePath();
  }

  CefRefPtr<CefCommandLine> cmdLine = AppGetCommandLine();

  if (cmdLine->HasSwitch(cefclient::kStartupPath)) {
    szInitialUrl = cmdLine->GetSwitchValue(cefclient::kStartupPath);
  } else {
    szInitialUrl = AppGetRunningDirectory();
    szInitialUrl.append("/dev/src/index.html");

    if (!FileExists(szInitialUrl)) {
      szInitialUrl = AppGetRunningDirectory();
      szInitialUrl.append("/www/index.html");

      if (!FileExists(szInitialUrl)) {
        if (GetInitialUrl() < 0)
          return 0;
      }
    }
  }

  // Start the node server process
  startNodeProcess();

  // Initialize CEF.
  CefInitialize(main_args, settings, app.get(), NULL);

  // Set window icon
  std::vector<std::string> icons(APPICONS, APPICONS + sizeof (APPICONS) / sizeof (APPICONS[0]));
  GList *list = NULL;
  for (int i = 0; i < icons.size(); ++i) {
    std::string path = icons[i];

    GdkPixbuf *icon = gdk_pixbuf_new_from_file(path.c_str(), NULL);
    if (!icon)
      continue;

    list = g_list_append(list, icon);
  }

  GtkWidget* window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_window_set_default_size(GTK_WINDOW(window), DEFAULT_SIZE_WIDTH, DEFAULT_SIZE_HEIGHT);

  gtk_window_set_icon_list(GTK_WINDOW(window), list);

  // Free icon list
  g_list_foreach(list, (GFunc) g_object_unref, NULL);
  g_list_free(list);

  GtkWidget* vbox = gtk_vbox_new(FALSE, 0);
  g_signal_connect(vbox, "size-allocate",
          G_CALLBACK(VboxSizeAllocated), NULL);
  gtk_container_add(GTK_CONTAINER(window), vbox);

  GtkWidget* menuBar = gtk_menu_bar_new();
  // GtkWidget* debug_menu = CreateMenu(menuBar, "Tests");
  // AddMenuEntry(debug_menu, "Hello World Menu",
  //              G_CALLBACK(GetSourceActivated));

  gtk_box_pack_start(GTK_BOX(vbox), menuBar, FALSE, FALSE, 0);

  // setup all event listener to handle focus, resizing, destruction
  g_signal_connect(G_OBJECT(window), "configure-event",
          G_CALLBACK(WindowConfigure), NULL);
  g_signal_connect(G_OBJECT(window), "focus-in-event",
          G_CALLBACK(WindowFocusIn), NULL);
  g_signal_connect(G_OBJECT(window), "delete_event",
          G_CALLBACK(HandleQuit), NULL);
  g_signal_connect(G_OBJECT(window), "destroy",
          G_CALLBACK(destroy), window);
  
//  add_handler_id = g_signal_connect(G_OBJECT(window), "add",
//          G_CALLBACK(HandleAdd), NULL);

  // Create the handler.
  g_handler = new ClientHandler();
  g_handler->SetMainHwnd(vbox);
//  g_handler->SetMainHwnd(window);

  // Create the browser view.
  CefWindowInfo window_info;
  CefBrowserSettings browserSettings;

  browserSettings.web_security = STATE_DISABLED;

  // show the window
  gtk_widget_show_all(GTK_WIDGET(window));

  window_info.SetAsChild(GDK_WINDOW_XID(gtk_widget_get_window(window)),
          CefRect(0, 0, DEFAULT_SIZE_WIDTH, DEFAULT_SIZE_HEIGHT));

  // Create the browser window
  CefBrowserHost::CreateBrowser(
          window_info,
          g_handler.get(),
          "file://" + szInitialUrl, browserSettings, NULL);

  // Install an signal handler so we clean up after ourselves.
  signal(SIGINT, TerminationSignalHandler);
  signal(SIGTERM, TerminationSignalHandler);

  CefRunMessageLoop();

  CefShutdown();

  return 0;
}
Exemplo n.º 9
0
 bool GetViewRect(CefRefPtr<CefBrowser> browser, CefRect &rect)
 {
     rect = CefRect(0, 0, m_renderTexture->getWidth(), m_renderTexture->getHeight());
     return true;
 }