Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(210)

Side by Side Diff: android_webview/browser/gpu_memory_buffer_impl.cc

Issue 13135004: android_webview: changes to support Android GraphicBuffers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove unnecessary OVERRIDE in gpu_memory_buffer_factory_impl Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « android_webview/browser/gpu_memory_buffer_impl.h ('k') | android_webview/common/DEPS » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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_buffer_impl.h"
6
7 #include "android_webview/browser/gpu_memory_buffer_factory_impl.h"
8 #include "android_webview/common/gpu_memory_buffer_factory_proxy.h"
9 #include "android_webview/public/browser/draw_gl.h"
10 #include "base/bind.h"
11 #include "base/logging.h"
12 #include "ui/gfx/size.h"
13 #include "ui/gl/gpu_memory_buffer.h"
14
15 namespace android_webview {
16
17 // Provides hardware rendering functions from the Android glue layer.
18 AwDrawGLFunctionTable* g_gl_draw_functions = NULL;
19
20 GpuMemoryBufferImpl::GpuMemoryBufferImpl(const gfx::Size& size)
21 : buffer_id_(g_gl_draw_functions->create_graphic_buffer(
22 size.width(), size.height())),
23 size_(size) {
24 }
25
26 GpuMemoryBufferImpl::~GpuMemoryBufferImpl() {
27 DCHECK(buffer_id_ != 0);
28 g_gl_draw_functions->release_graphic_buffer(buffer_id_);
29 buffer_id_ = 0;
30 }
31
32 void GpuMemoryBufferImpl::MapForWrite(void** vaddr) {
33 DCHECK(buffer_id_ != 0);
34 int err = g_gl_draw_functions->lock_for_write(buffer_id_, vaddr);
35 DCHECK(err == 0);
36 }
37
38 void GpuMemoryBufferImpl::Unmap() {
39 DCHECK(buffer_id_ != 0);
40 int err = g_gl_draw_functions->unlock(buffer_id_);
41 DCHECK(err == 0);
42 }
43
44 void* GpuMemoryBufferImpl::GetNativeBuffer() {
45 DCHECK(buffer_id_ != 0);
46 return g_gl_draw_functions->get_native_buffer(buffer_id_);
47 }
48
49 uint32 GpuMemoryBufferImpl::GetStride() {
50 DCHECK(buffer_id_ != 0);
51 return g_gl_draw_functions->get_stride(buffer_id_);
52 }
53
54 // static
55 void GpuMemoryBufferImpl::SetAwDrawGLFunctionTable(
56 AwDrawGLFunctionTable* table) {
57 g_gl_draw_functions = table;
58 SetGpuMemoryBufferFactoryProxy(base::Bind(&CreateGpuMemoryBuffer));
59 }
60
61 } // namespace android_webview
OLDNEW
« no previous file with comments | « android_webview/browser/gpu_memory_buffer_impl.h ('k') | android_webview/common/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698