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

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

Issue 13135004: android_webview: changes to support Android GraphicBuffers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add GetStride() API on the GraphicBuffer 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
OLDNEW
(Empty)
1 // Copyright (c) 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/graphic_buffer_impl.h"
6
7 #include "android_webview/browser/graphic_buffer_factory_impl.h"
8 #include "android_webview/common/graphic_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 "cc/resources/graphic_buffer.h"
13 #include "ui/gfx/size.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 GraphicBufferImpl::GraphicBufferImpl(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 GraphicBufferImpl::~GraphicBufferImpl() {
27 DCHECK(buffer_id_ != 0);
28 g_gl_draw_functions->release_graphic_buffer(buffer_id_);
29 buffer_id_ = 0;
30 }
31
32 bool GraphicBufferImpl::LockForRead(void** vaddr) {
33 DCHECK(buffer_id_ != 0);
34 return g_gl_draw_functions->lock_for_read(buffer_id_, vaddr) == 0;
35 }
36
37 bool GraphicBufferImpl::LockForWrite(void** vaddr) {
38 DCHECK(buffer_id_ != 0);
39 return g_gl_draw_functions->lock_for_write(buffer_id_, vaddr) == 0;
40 }
41
42 bool GraphicBufferImpl::Unlock() {
43 DCHECK(buffer_id_ != 0);
44 return g_gl_draw_functions->unlock(buffer_id_) == 0;
45 }
46
47 gfx::Size GraphicBufferImpl::GetSize() {
48 return size_;
49 }
50
51 void* GraphicBufferImpl::GetNativeBuffer() {
52 DCHECK(buffer_id_ != 0);
53 return g_gl_draw_functions->get_native_buffer(buffer_id_);
54 }
55
56 uint32 GraphicBufferImpl::GetStride() {
57 DCHECK(buffer_id_ != 0);
58 return g_gl_draw_functions->get_stride(buffer_id_);
59 }
60
61 // static
62 void GraphicBufferImpl::SetAwDrawGLFunctionTable(
63 AwDrawGLFunctionTable* table) {
64 g_gl_draw_functions = table;
65 SetGraphicBufferFactoryProxy(base::Bind(&CreateGraphicBuffer));
66 }
67
68 } // namespace android_webview
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698