1 // Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights 2 // reserved. Use of this source code is governed by a BSD-style license 3 // that can be found in the LICENSE file. 4 5 #ifndef CEF_TESTS_CEFCLIENT_BROWSER_OSR_RENDERER_H_ 6 #define CEF_TESTS_CEFCLIENT_BROWSER_OSR_RENDERER_H_ 7 #pragma once 8 9 #include "include/cef_browser.h" 10 #include "include/cef_render_handler.h" 11 #include "tests/cefclient/browser/osr_renderer_settings.h" 12 13 namespace client { 14 15 class OsrRenderer { 16 public: 17 explicit OsrRenderer(const OsrRendererSettings& settings); 18 ~OsrRenderer(); 19 20 // Initialize the OpenGL environment. 21 void Initialize(); 22 23 // Clean up the OpenGL environment. 24 void Cleanup(); 25 26 // Render to the screen. 27 void Render(); 28 29 // Forwarded from CefRenderHandler callbacks. 30 void OnPopupShow(CefRefPtr<CefBrowser> browser, bool show); 31 // |rect| must be in pixel coordinates. 32 void OnPopupSize(CefRefPtr<CefBrowser> browser, const CefRect& rect); 33 void OnPaint(CefRefPtr<CefBrowser> browser, 34 CefRenderHandler::PaintElementType type, 35 const CefRenderHandler::RectList& dirtyRects, 36 const void* buffer, 37 int width, 38 int height); 39 40 // Apply spin. 41 void SetSpin(float spinX, float spinY); 42 void IncrementSpin(float spinDX, float spinDY); 43 GetViewWidth()44 int GetViewWidth() const { return view_width_; } GetViewHeight()45 int GetViewHeight() const { return view_height_; } 46 popup_rect()47 CefRect popup_rect() const { return popup_rect_; } original_popup_rect()48 CefRect original_popup_rect() const { return original_popup_rect_; } 49 50 void ClearPopupRects(); 51 52 private: 53 CefRect GetPopupRectInWebView(const CefRect& original_rect); 54 IsTransparent()55 inline bool IsTransparent() const { 56 return CefColorGetA(settings_.background_color) == 0; 57 } 58 59 const OsrRendererSettings settings_; 60 bool initialized_; 61 unsigned int texture_id_; 62 int view_width_; 63 int view_height_; 64 CefRect popup_rect_; 65 CefRect original_popup_rect_; 66 float spin_x_; 67 float spin_y_; 68 CefRect update_rect_; 69 70 DISALLOW_COPY_AND_ASSIGN(OsrRenderer); 71 }; 72 73 } // namespace client 74 75 #endif // CEF_TESTS_CEFCLIENT_BROWSER_OSR_RENDERER_H_ 76