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

Side by Side Diff: content/common/gpu/client/gpu_memory_buffer_impl_foobar.cc

Issue 186123006: zero copy - NOT FOR REVIEW Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: minus ui-map-image and ui-impl-side setting, plus tiled mode Created 6 years, 9 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
« no previous file with comments | « content/common/gpu/client/gpu_memory_buffer_impl_foobar.h ('k') | content/content_browser.gypi » ('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 "base/debug/trace_event.h"
6
7 #include "content/common/gpu/client/gpu_memory_buffer_impl_foobar.h"
8
9 #include "ui/gl/gl_bindings.h"
10
11 extern "C" {
12 #include <libdrm/intel_bufmgr.h>
13 }
14
15 char GetZCopy() {
16 // 0 off, 't' tiled, 'u' untiled
17 static char mode;
18 static char done = 0;
19 if (!done) {
20 done = 1;
21 mode = 0;
22 char *e = getenv("ZCOPY");
23 if (e) {
24 if (e[0] == 't') {
25 mode = 't';
26 TRACE_EVENT_INSTANT0("zcopy", "zero copy enabled - tiled mode",
27 TRACE_EVENT_SCOPE_THREAD);
28 } else if (e[0] == 'u') {
29 mode = 'u';
30 TRACE_EVENT_INSTANT0("zcopy", "zero copy enabled - untiled mode",
31 TRACE_EVENT_SCOPE_THREAD);
32 }
33 }
34 if (!mode) {
35 TRACE_EVENT_INSTANT0("zcopy", "zero copy disabled",
36 TRACE_EVENT_SCOPE_THREAD);
37 }
38 }
39 return mode;
40 }
41
42 namespace content {
43
44 GpuMemoryBufferImplFoobar::GpuMemoryBufferImplFoobar(
45 gfx::Size size, unsigned internalformat)
46 : GpuMemoryBufferImpl(size, internalformat), _prime_fd(-1) {
47 }
48
49 GpuMemoryBufferImplFoobar::~GpuMemoryBufferImplFoobar() {
50 if (_prime_fd >= 0) {
51 close(_prime_fd);
52 }
53 drm_intel_bo_unreference(foobar_object);
54 }
55
56 int GpuMemoryBufferImplFoobar::prime_fd() const {
57 if (_prime_fd < 0) {
58 TRACE_EVENT0("zcopy", "export");
59 DCHECK(foobar_object);
60 drm_intel_bo_gem_export_to_prime(foobar_object, &_prime_fd);
61 }
62 return _prime_fd;
63 }
64
65 // static
66 bool GpuMemoryBufferImplFoobar::IsFormatSupported(unsigned internalformat) {
67 return GetZCopy() && internalformat == GL_BGRA8_EXT;
68 }
69
70 bool GpuMemoryBufferImplFoobar::InitializeFromFoobarObject(
71 void *foobar_object) {
72 this->foobar_object = (drm_intel_bo *) foobar_object;
73 return true;
74 }
75
76 void GpuMemoryBufferImplFoobar::Map(AccessMode mode, void** vaddr) {
77 DCHECK(!mapped_);
78 TRACE_EVENT0("zcopy", "map");
79 if (GetZCopy() == 'u')
80 drm_intel_bo_map(foobar_object, 1);
81 else
82 drm_intel_gem_bo_map_gtt(foobar_object);
83 *vaddr = foobar_object->virt;
84 mapped_ = true;
85 }
86
87 void GpuMemoryBufferImplFoobar::Unmap() {
88 DCHECK(mapped_);
89 drm_intel_bo_unmap(foobar_object);
90 mapped_ = false;
91 }
92
93 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplFoobar::GetHandle() const {
94 gfx::GpuMemoryBufferHandle handle;
95 handle.type = gfx::FOOBAR_BUFFER;
96 handle.handle.fd = prime_fd();
97 return handle;
98 }
99
100 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/client/gpu_memory_buffer_impl_foobar.h ('k') | content/content_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698