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

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

Issue 634083002: gpu: Compositor management of GpuMemoryBuffer instances. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cc-pre-chromium-image-refactor
Patch Set: rebase Created 6 years, 2 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
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 "content/common/gpu/client/gpu_memory_buffer_impl.h" 5 #include "content/common/gpu/client/gpu_memory_buffer_impl.h"
6 6
7 #include "ui/gl/gl_bindings.h" 7 #include "ui/gl/gl_bindings.h"
8 8
9 namespace content { 9 namespace content {
10 10
11 GpuMemoryBufferImpl::GpuMemoryBufferImpl(const gfx::Size& size, 11 GpuMemoryBufferImpl::GpuMemoryBufferImpl(const gfx::Size& size,
12 unsigned internalformat, 12 Format format,
13 const DestructionCallback& callback) 13 const DestructionCallback& callback)
14 : size_(size), 14 : size_(size), format_(format), callback_(callback), mapped_(false) {
15 internalformat_(internalformat),
16 callback_(callback),
17 mapped_(false) {
18 DCHECK(IsFormatValid(internalformat));
19 } 15 }
20 16
21 GpuMemoryBufferImpl::~GpuMemoryBufferImpl() { 17 GpuMemoryBufferImpl::~GpuMemoryBufferImpl() {
22 callback_.Run(); 18 callback_.Run();
23 } 19 }
24 20
25 // static 21 // static
26 bool GpuMemoryBufferImpl::IsFormatValid(unsigned internalformat) { 22 GpuMemoryBufferImpl* GpuMemoryBufferImpl::FromClientBuffer(
27 switch (internalformat) { 23 ClientBuffer buffer) {
28 case GL_BGRA8_EXT: 24 return reinterpret_cast<GpuMemoryBufferImpl*>(buffer);
29 case GL_RGBA8_OES:
30 case GL_RGB8_OES:
31 return true;
32 default:
33 return false;
34 }
35 } 25 }
36 26
37 // static 27 // static
38 bool GpuMemoryBufferImpl::IsUsageValid(unsigned usage) { 28 size_t GpuMemoryBufferImpl::BytesPerPixel(Format format) {
39 switch (usage) { 29 switch (format) {
40 case GL_IMAGE_MAP_CHROMIUM: 30 case RGBA_8888:
41 case GL_IMAGE_SCANOUT_CHROMIUM: 31 case RGBX_8888:
42 return true; 32 case BGRA_8888:
43 default: 33 return 4;
44 return false;
45 } 34 }
35
36 NOTREACHED();
37 return 0;
46 } 38 }
47 39
48 // static 40 gfx::GpuMemoryBuffer::Format GpuMemoryBufferImpl::GetFormat() const {
49 size_t GpuMemoryBufferImpl::BytesPerPixel(unsigned internalformat) { 41 return format_;
50 switch (internalformat) {
51 case GL_BGRA8_EXT:
52 case GL_RGBA8_OES:
53 case GL_RGB8_OES:
54 return 4;
55 default:
56 NOTREACHED();
57 return 0;
58 }
59 } 42 }
60 43
61 bool GpuMemoryBufferImpl::IsMapped() const { return mapped_; } 44 bool GpuMemoryBufferImpl::IsMapped() const {
45 return mapped_;
46 }
47
48 ClientBuffer GpuMemoryBufferImpl::AsClientBuffer() {
49 return reinterpret_cast<ClientBuffer>(this);
50 }
62 51
63 } // namespace content 52 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/client/gpu_memory_buffer_impl.h ('k') | content/common/gpu/client/gpu_memory_buffer_impl_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698