OLD | NEW |
---|---|
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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
75 // static | 75 // static |
76 GpuMemoryBufferImpl* GpuMemoryBufferImpl::FromClientBuffer( | 76 GpuMemoryBufferImpl* GpuMemoryBufferImpl::FromClientBuffer( |
77 ClientBuffer buffer) { | 77 ClientBuffer buffer) { |
78 return reinterpret_cast<GpuMemoryBufferImpl*>(buffer); | 78 return reinterpret_cast<GpuMemoryBufferImpl*>(buffer); |
79 } | 79 } |
80 | 80 |
81 // static | 81 // static |
82 size_t GpuMemoryBufferImpl::NumberOfPlanesForGpuMemoryBufferFormat( | 82 size_t GpuMemoryBufferImpl::NumberOfPlanesForGpuMemoryBufferFormat( |
83 Format format) { | 83 Format format) { |
84 switch (format) { | 84 switch (format) { |
85 case ASTC: | |
85 case ATC: | 86 case ATC: |
86 case ATCIA: | 87 case ATCIA: |
87 case DXT1: | 88 case DXT1: |
88 case DXT5: | 89 case DXT5: |
89 case ETC1: | 90 case ETC1: |
90 case R_8: | 91 case R_8: |
91 case RGBA_4444: | 92 case RGBA_4444: |
92 case RGBA_8888: | 93 case RGBA_8888: |
93 case RGBX_8888: | 94 case RGBX_8888: |
94 case BGRA_8888: | 95 case BGRA_8888: |
95 return 1; | 96 return 1; |
96 case YUV_420: | 97 case YUV_420: |
97 return 3; | 98 return 3; |
98 } | 99 } |
99 NOTREACHED(); | 100 NOTREACHED(); |
100 return 0; | 101 return 0; |
101 } | 102 } |
102 | 103 |
103 // static | 104 // static |
104 size_t GpuMemoryBufferImpl::SubsamplingFactor(Format format, int plane) { | 105 size_t GpuMemoryBufferImpl::SubsamplingFactor(Format format, int plane) { |
105 switch (format) { | 106 switch (format) { |
107 case ASTC: | |
106 case ATC: | 108 case ATC: |
107 case ATCIA: | 109 case ATCIA: |
108 case DXT1: | 110 case DXT1: |
109 case DXT5: | 111 case DXT5: |
110 case ETC1: | 112 case ETC1: |
111 case R_8: | 113 case R_8: |
112 case RGBA_4444: | 114 case RGBA_4444: |
113 case RGBA_8888: | 115 case RGBA_8888: |
114 case RGBX_8888: | 116 case RGBX_8888: |
115 case BGRA_8888: | 117 case BGRA_8888: |
(...skipping 13 matching lines...) Expand all Loading... | |
129 Format format, | 131 Format format, |
130 int plane, | 132 int plane, |
131 size_t* size_in_bytes) { | 133 size_t* size_in_bytes) { |
132 base::CheckedNumeric<size_t> checked_size = width; | 134 base::CheckedNumeric<size_t> checked_size = width; |
133 switch (format) { | 135 switch (format) { |
134 case ATCIA: | 136 case ATCIA: |
135 case DXT5: | 137 case DXT5: |
136 DCHECK_EQ(plane, 0); | 138 DCHECK_EQ(plane, 0); |
137 *size_in_bytes = width; | 139 *size_in_bytes = width; |
138 return true; | 140 return true; |
141 case ASTC: | |
139 case ATC: | 142 case ATC: |
140 case DXT1: | 143 case DXT1: |
141 case ETC1: | 144 case ETC1: |
142 DCHECK_EQ(plane, 0); | 145 DCHECK_EQ(plane, 0); |
143 DCHECK_EQ(width % 2, 0u); | 146 DCHECK_EQ(width % 2, 0u); |
144 *size_in_bytes = width / 2; | 147 *size_in_bytes = width / 2; |
piman
2015/08/17 23:00:20
For ASTC (4x4), you need width%4 == 0, and size_in
| |
145 return true; | 148 return true; |
146 case R_8: | 149 case R_8: |
147 checked_size += 3; | 150 checked_size += 3; |
148 if (!checked_size.IsValid()) | 151 if (!checked_size.IsValid()) |
149 return false; | 152 return false; |
150 *size_in_bytes = checked_size.ValueOrDie() & ~0x3; | 153 *size_in_bytes = checked_size.ValueOrDie() & ~0x3; |
151 return true; | 154 return true; |
152 case RGBA_4444: | 155 case RGBA_4444: |
153 checked_size *= 2; | 156 checked_size *= 2; |
154 if (!checked_size.IsValid()) | 157 if (!checked_size.IsValid()) |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
203 | 206 |
204 gfx::GpuMemoryBufferId GpuMemoryBufferImpl::GetId() const { | 207 gfx::GpuMemoryBufferId GpuMemoryBufferImpl::GetId() const { |
205 return id_; | 208 return id_; |
206 } | 209 } |
207 | 210 |
208 ClientBuffer GpuMemoryBufferImpl::AsClientBuffer() { | 211 ClientBuffer GpuMemoryBufferImpl::AsClientBuffer() { |
209 return reinterpret_cast<ClientBuffer>(this); | 212 return reinterpret_cast<ClientBuffer>(this); |
210 } | 213 } |
211 | 214 |
212 } // namespace content | 215 } // namespace content |
OLD | NEW |