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

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

Issue 255713008: Change glimage to accept a type. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 7 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
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "android_webview/browser/gpu_memory_buffer_factory_impl.h" 5 #include "android_webview/browser/gpu_memory_buffer_factory_impl.h"
6 6
7 #include "android_webview/public/browser/draw_gl.h" 7 #include "android_webview/public/browser/draw_gl.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "ui/gfx/gpu_memory_buffer.h" 9 #include "ui/gfx/gpu_memory_buffer.h"
10 #include "ui/gfx/size.h" 10 #include "ui/gfx/size.h"
(...skipping 13 matching lines...) Expand all
24 size_(size), 24 size_(size),
25 mapped_(false) { 25 mapped_(false) {
26 DCHECK(buffer_id_); 26 DCHECK(buffer_id_);
27 } 27 }
28 28
29 virtual ~GpuMemoryBufferImpl() { 29 virtual ~GpuMemoryBufferImpl() {
30 g_gl_draw_functions->release_graphic_buffer(buffer_id_); 30 g_gl_draw_functions->release_graphic_buffer(buffer_id_);
31 } 31 }
32 32
33 // Overridden from gfx::GpuMemoryBuffer: 33 // Overridden from gfx::GpuMemoryBuffer:
34 virtual void* Map(gfx::GpuMemoryBuffer::AccessMode mode) OVERRIDE { 34 virtual void* Map() OVERRIDE {
35 AwMapMode map_mode = MAP_READ_ONLY;
36 switch (mode) {
37 case GpuMemoryBuffer::READ_ONLY:
38 map_mode = MAP_READ_ONLY;
39 break;
40 case GpuMemoryBuffer::WRITE_ONLY:
41 map_mode = MAP_WRITE_ONLY;
42 break;
43 case GpuMemoryBuffer::READ_WRITE:
44 map_mode = MAP_READ_WRITE;
45 break;
46 default:
47 LOG(DFATAL) << "Unknown map mode: " << mode;
48 }
49 void* vaddr = NULL; 35 void* vaddr = NULL;
50 int err = g_gl_draw_functions->map(buffer_id_, map_mode, &vaddr); 36 int err = g_gl_draw_functions->map(buffer_id_, MAP_READ_WRITE, &vaddr);
51 DCHECK(!err); 37 DCHECK(!err);
52 mapped_ = true; 38 mapped_ = true;
53 return vaddr; 39 return vaddr;
54 } 40 }
55 virtual void Unmap() OVERRIDE { 41 virtual void Unmap() OVERRIDE {
56 int err = g_gl_draw_functions->unmap(buffer_id_); 42 int err = g_gl_draw_functions->unmap(buffer_id_);
57 DCHECK(!err); 43 DCHECK(!err);
58 mapped_ = false; 44 mapped_ = false;
59 } 45 }
60 virtual bool IsMapped() const OVERRIDE { return mapped_; } 46 virtual bool IsMapped() const OVERRIDE { return mapped_; }
(...skipping 19 matching lines...) Expand all
80 66
81 GpuMemoryBufferFactoryImpl::GpuMemoryBufferFactoryImpl() { 67 GpuMemoryBufferFactoryImpl::GpuMemoryBufferFactoryImpl() {
82 } 68 }
83 69
84 GpuMemoryBufferFactoryImpl::~GpuMemoryBufferFactoryImpl() { 70 GpuMemoryBufferFactoryImpl::~GpuMemoryBufferFactoryImpl() {
85 } 71 }
86 72
87 gfx::GpuMemoryBuffer* GpuMemoryBufferFactoryImpl::CreateGpuMemoryBuffer( 73 gfx::GpuMemoryBuffer* GpuMemoryBufferFactoryImpl::CreateGpuMemoryBuffer(
88 size_t width, 74 size_t width,
89 size_t height, 75 size_t height,
90 unsigned internalformat) { 76 unsigned internalformat,
77 unsigned usage) {
91 // For Android WebView we assume the |internalformat| will always be 78 // For Android WebView we assume the |internalformat| will always be
92 // GL_RGBA8_OES. 79 // GL_RGBA8_OES.
93 CHECK_EQ(static_cast<GLenum>(GL_RGBA8_OES), internalformat); 80 CHECK_EQ(static_cast<GLenum>(GL_RGBA8_OES), internalformat);
94 CHECK(g_gl_draw_functions); 81 CHECK(g_gl_draw_functions);
95 long buffer_id = g_gl_draw_functions->create_graphic_buffer(width, height); 82 long buffer_id = g_gl_draw_functions->create_graphic_buffer(width, height);
96 if (!buffer_id) 83 if (!buffer_id)
97 return NULL; 84 return NULL;
98 85
99 return new GpuMemoryBufferImpl(buffer_id, gfx::Size(width, height)); 86 return new GpuMemoryBufferImpl(buffer_id, gfx::Size(width, height));
100 } 87 }
101 88
102 // static 89 // static
103 void GpuMemoryBufferFactoryImpl::SetAwDrawGLFunctionTable( 90 void GpuMemoryBufferFactoryImpl::SetAwDrawGLFunctionTable(
104 AwDrawGLFunctionTable* table) { 91 AwDrawGLFunctionTable* table) {
105 g_gl_draw_functions = table; 92 g_gl_draw_functions = table;
106 } 93 }
107 94
108 } // namespace android_webview 95 } // namespace android_webview
OLDNEW
« no previous file with comments | « android_webview/browser/gpu_memory_buffer_factory_impl.h ('k') | cc/resources/raster_worker_pool_perftest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698