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

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

Issue 1024113003: Add multi-planar functions to GpuMemoryBuffer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: reveman@ comments. Created 5 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
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 "base/logging.h" 7 #include "base/logging.h"
8 #include "base/numerics/safe_math.h" 8 #include "base/numerics/safe_math.h"
9 #include "content/common/gpu/client/gpu_memory_buffer_impl_shared_memory.h" 9 #include "content/common/gpu/client/gpu_memory_buffer_impl_shared_memory.h"
10 #include "ui/gl/gl_bindings.h" 10 #include "ui/gl/gl_bindings.h"
(...skipping 12 matching lines...) Expand all
23 23
24 namespace content { 24 namespace content {
25 25
26 GpuMemoryBufferImpl::GpuMemoryBufferImpl(gfx::GpuMemoryBufferId id, 26 GpuMemoryBufferImpl::GpuMemoryBufferImpl(gfx::GpuMemoryBufferId id,
27 const gfx::Size& size, 27 const gfx::Size& size,
28 Format format, 28 Format format,
29 const DestructionCallback& callback) 29 const DestructionCallback& callback)
30 : id_(id), 30 : id_(id),
31 size_(size), 31 size_(size),
32 format_(format), 32 format_(format),
33 num_planes_(NumberOfPlanesForGpuMemoryBufferFormat(format)),
33 callback_(callback), 34 callback_(callback),
34 mapped_(false), 35 mapped_(false),
35 destruction_sync_point_(0) { 36 destruction_sync_point_(0) {
36 } 37 }
37 38
38 GpuMemoryBufferImpl::~GpuMemoryBufferImpl() { 39 GpuMemoryBufferImpl::~GpuMemoryBufferImpl() {
39 callback_.Run(destruction_sync_point_); 40 callback_.Run(destruction_sync_point_);
40 } 41 }
41 42
42 // static 43 // static
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 return false; 105 return false;
105 106
106 *stride_in_bytes = s.ValueOrDie(); 107 *stride_in_bytes = s.ValueOrDie();
107 return true; 108 return true;
108 } 109 }
109 110
110 NOTREACHED(); 111 NOTREACHED();
111 return false; 112 return false;
112 } 113 }
113 114
115 size_t GpuMemoryBufferImpl::GetNumberOfPlanes() const {
116 return num_planes_;
117 }
118
114 gfx::GpuMemoryBuffer::Format GpuMemoryBufferImpl::GetFormat() const { 119 gfx::GpuMemoryBuffer::Format GpuMemoryBufferImpl::GetFormat() const {
115 return format_; 120 return format_;
116 } 121 }
117 122
118 bool GpuMemoryBufferImpl::IsMapped() const { 123 bool GpuMemoryBufferImpl::IsMapped() const {
119 return mapped_; 124 return mapped_;
120 } 125 }
121 126
122 ClientBuffer GpuMemoryBufferImpl::AsClientBuffer() { 127 ClientBuffer GpuMemoryBufferImpl::AsClientBuffer() {
123 return reinterpret_cast<ClientBuffer>(this); 128 return reinterpret_cast<ClientBuffer>(this);
124 } 129 }
125 130
131 // static
132 size_t GpuMemoryBufferImpl::NumberOfPlanesForGpuMemoryBufferFormat(
133 gfx::GpuMemoryBuffer::Format format) {
134 switch (format) {
135 case gfx::GpuMemoryBuffer::Format::ATC:
136 case gfx::GpuMemoryBuffer::Format::ATCIA:
137 case gfx::GpuMemoryBuffer::Format::DXT1:
138 case gfx::GpuMemoryBuffer::Format::DXT5:
139 case gfx::GpuMemoryBuffer::Format::ETC1:
140 case gfx::GpuMemoryBuffer::Format::RGBA_8888:
141 case gfx::GpuMemoryBuffer::Format::RGBX_8888:
142 case gfx::GpuMemoryBuffer::Format::BGRA_8888:
143 return 1;
144 default:
145 NOTREACHED();
146 return 0;
147 }
148 }
149
126 } // namespace content 150 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698