1 // Copyright 2013 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 "android_webview/browser/gfx/aw_gl_surface.h"
6 
7 #include <utility>
8 
9 #include "android_webview/browser/gfx/scoped_app_gl_state_restore.h"
10 
11 namespace android_webview {
12 
AwGLSurface()13 AwGLSurface::AwGLSurface() : size_(1, 1) {}
14 
~AwGLSurface()15 AwGLSurface::~AwGLSurface() {}
16 
Destroy()17 void AwGLSurface::Destroy() {
18 }
19 
IsOffscreen()20 bool AwGLSurface::IsOffscreen() {
21   return false;
22 }
23 
GetBackingFramebufferObject()24 unsigned int AwGLSurface::GetBackingFramebufferObject() {
25   return ScopedAppGLStateRestore::Current()->framebuffer_binding_ext();
26 }
27 
SwapBuffers(PresentationCallback callback)28 gfx::SwapResult AwGLSurface::SwapBuffers(PresentationCallback callback) {
29   DCHECK(!pending_presentation_callback_);
30   pending_presentation_callback_ = std::move(callback);
31   return gfx::SwapResult::SWAP_ACK;
32 }
33 
GetSize()34 gfx::Size AwGLSurface::GetSize() {
35   return size_;
36 }
37 
GetHandle()38 void* AwGLSurface::GetHandle() {
39   return NULL;
40 }
41 
GetDisplay()42 void* AwGLSurface::GetDisplay() {
43   return NULL;
44 }
45 
GetFormat()46 gl::GLSurfaceFormat AwGLSurface::GetFormat() {
47   return gl::GLSurfaceFormat();
48 }
49 
Resize(const gfx::Size & size,float scale_factor,const gfx::ColorSpace & color_space,bool has_alpha)50 bool AwGLSurface::Resize(const gfx::Size& size,
51                          float scale_factor,
52                          const gfx::ColorSpace& color_space,
53                          bool has_alpha) {
54   size_ = size;
55   return true;
56 }
57 
SetSize(const gfx::Size & size)58 void AwGLSurface::SetSize(const gfx::Size& size) {
59   size_ = size;
60 }
61 
MaybeDidPresent(gfx::PresentationFeedback feedback)62 void AwGLSurface::MaybeDidPresent(gfx::PresentationFeedback feedback) {
63   if (!pending_presentation_callback_)
64     return;
65   std::move(pending_presentation_callback_).Run(std::move(feedback));
66 }
67 
68 }  // namespace android_webview
69