Home | History | Annotate | Download | only in browser
      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/gpu_memory_handle_impl.h"
      6 
      7 #include "android_webview/public/browser/draw_gl.h"
      8 #include "base/basictypes.h"
      9 
     10 namespace android_webview {
     11 
     12 namespace {
     13 
     14 // Provides hardware rendering functions from the Android glue layer.
     15 AwDrawGLFunctionTable* g_gl_draw_functions = NULL;
     16 }
     17 
     18 GpuMemoryHandleImpl::GpuMemoryHandleImpl(int buffer_id)
     19     : buffer_id_(buffer_id) {
     20 }
     21 
     22 GpuMemoryHandleImpl::~GpuMemoryHandleImpl() {
     23   g_gl_draw_functions->release_graphic_buffer(buffer_id_);
     24 }
     25 
     26 void* GpuMemoryHandleImpl::GetNativeHandle() const {
     27   return g_gl_draw_functions->get_native_buffer(buffer_id_);
     28 }
     29 
     30 int GpuMemoryHandleImpl::GetBufferId() const {
     31   return buffer_id_;
     32 }
     33 
     34 // static
     35 void GpuMemoryHandleImpl::SetAwDrawGLFunctionTable(
     36     AwDrawGLFunctionTable* table) {
     37   g_gl_draw_functions = table;
     38 }
     39 
     40 }  // namespace android_webview
     41