| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ui/gl/gl_image_memory.h" | 5 #include "ui/gl/gl_image_memory.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/numerics/safe_conversions.h" | |
| 9 #include "base/trace_event/trace_event.h" | 8 #include "base/trace_event/trace_event.h" |
| 10 #include "ui/gfx/buffer_format_util.h" | 9 #include "ui/gfx/buffer_format_util.h" |
| 11 #include "ui/gl/gl_bindings.h" | 10 #include "ui/gl/gl_bindings.h" |
| 12 #include "ui/gl/gl_context.h" | 11 #include "ui/gl/gl_context.h" |
| 13 #include "ui/gl/gl_version_info.h" | 12 #include "ui/gl/gl_version_info.h" |
| 14 | 13 |
| 15 using gfx::BufferFormat; | 14 using gfx::BufferFormat; |
| 16 | 15 |
| 17 namespace gl { | 16 namespace gl { |
| 18 namespace { | 17 namespace { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 case BufferFormat::DXT1: | 64 case BufferFormat::DXT1: |
| 66 case BufferFormat::DXT5: | 65 case BufferFormat::DXT5: |
| 67 case BufferFormat::ETC1: | 66 case BufferFormat::ETC1: |
| 68 return true; | 67 return true; |
| 69 case BufferFormat::R_8: | 68 case BufferFormat::R_8: |
| 70 case BufferFormat::RGBA_4444: | 69 case BufferFormat::RGBA_4444: |
| 71 case BufferFormat::RGBX_8888: | 70 case BufferFormat::RGBX_8888: |
| 72 case BufferFormat::RGBA_8888: | 71 case BufferFormat::RGBA_8888: |
| 73 case BufferFormat::BGRX_8888: | 72 case BufferFormat::BGRX_8888: |
| 74 case BufferFormat::BGRA_8888: | 73 case BufferFormat::BGRA_8888: |
| 75 return false; | |
| 76 case BufferFormat::YUV_420: | 74 case BufferFormat::YUV_420: |
| 77 case BufferFormat::YUV_420_BIPLANAR: | 75 case BufferFormat::YUV_420_BIPLANAR: |
| 78 case BufferFormat::UYVY_422: | 76 case BufferFormat::UYVY_422: |
| 79 NOTREACHED(); | |
| 80 return false; | 77 return false; |
| 81 } | 78 } |
| 82 | 79 |
| 83 NOTREACHED(); | 80 NOTREACHED(); |
| 84 return false; | 81 return false; |
| 85 } | 82 } |
| 86 | 83 |
| 87 GLenum TextureFormat(BufferFormat format) { | 84 GLenum TextureFormat(BufferFormat format) { |
| 88 switch (format) { | 85 switch (format) { |
| 89 case BufferFormat::ATC: | 86 case BufferFormat::ATC: |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 return GL_BGRA_EXT; | 122 return GL_BGRA_EXT; |
| 126 case BufferFormat::RGBA_4444: | 123 case BufferFormat::RGBA_4444: |
| 127 case BufferFormat::RGBA_8888: | 124 case BufferFormat::RGBA_8888: |
| 128 case BufferFormat::BGRA_8888: | 125 case BufferFormat::BGRA_8888: |
| 129 case BufferFormat::R_8: | 126 case BufferFormat::R_8: |
| 130 case BufferFormat::ATC: | 127 case BufferFormat::ATC: |
| 131 case BufferFormat::ATCIA: | 128 case BufferFormat::ATCIA: |
| 132 case BufferFormat::DXT1: | 129 case BufferFormat::DXT1: |
| 133 case BufferFormat::DXT5: | 130 case BufferFormat::DXT5: |
| 134 case BufferFormat::ETC1: | 131 case BufferFormat::ETC1: |
| 135 return TextureFormat(format); | |
| 136 case BufferFormat::YUV_420: | 132 case BufferFormat::YUV_420: |
| 137 case BufferFormat::YUV_420_BIPLANAR: | 133 case BufferFormat::YUV_420_BIPLANAR: |
| 138 case BufferFormat::UYVY_422: | 134 case BufferFormat::UYVY_422: |
| 139 NOTREACHED(); | 135 return TextureFormat(format); |
| 140 return 0; | |
| 141 } | 136 } |
| 142 | 137 |
| 143 NOTREACHED(); | 138 NOTREACHED(); |
| 144 return 0; | 139 return 0; |
| 145 } | 140 } |
| 146 | 141 |
| 147 GLenum DataType(BufferFormat format) { | 142 GLenum DataType(BufferFormat format) { |
| 148 switch (format) { | 143 switch (format) { |
| 149 case BufferFormat::RGBA_4444: | 144 case BufferFormat::RGBA_4444: |
| 150 return GL_UNSIGNED_SHORT_4_4_4_4; | 145 return GL_UNSIGNED_SHORT_4_4_4_4; |
| 151 case BufferFormat::RGBX_8888: | 146 case BufferFormat::RGBX_8888: |
| 152 case BufferFormat::RGBA_8888: | 147 case BufferFormat::RGBA_8888: |
| 153 case BufferFormat::BGRX_8888: | 148 case BufferFormat::BGRX_8888: |
| 154 case BufferFormat::BGRA_8888: | 149 case BufferFormat::BGRA_8888: |
| 155 case BufferFormat::R_8: | 150 case BufferFormat::R_8: |
| 156 return GL_UNSIGNED_BYTE; | 151 return GL_UNSIGNED_BYTE; |
| 157 case BufferFormat::ATC: | 152 case BufferFormat::ATC: |
| 158 case BufferFormat::ATCIA: | 153 case BufferFormat::ATCIA: |
| 159 case BufferFormat::DXT1: | 154 case BufferFormat::DXT1: |
| 160 case BufferFormat::DXT5: | |
| 161 case BufferFormat::ETC1: | |
| 162 case BufferFormat::YUV_420: | |
| 163 case BufferFormat::YUV_420_BIPLANAR: | |
| 164 case BufferFormat::UYVY_422: | |
| 165 NOTREACHED(); | |
| 166 return 0; | |
| 167 } | |
| 168 | |
| 169 NOTREACHED(); | |
| 170 return 0; | |
| 171 } | |
| 172 | |
| 173 GLint DataRowLength(size_t stride, BufferFormat format) { | |
| 174 switch (format) { | |
| 175 case BufferFormat::RGBA_4444: | |
| 176 return base::checked_cast<GLint>(stride) / 2; | |
| 177 case BufferFormat::RGBX_8888: | |
| 178 case BufferFormat::RGBA_8888: | |
| 179 case BufferFormat::BGRX_8888: | |
| 180 case BufferFormat::BGRA_8888: | |
| 181 return base::checked_cast<GLint>(stride) / 4; | |
| 182 case BufferFormat::R_8: | |
| 183 return base::checked_cast<GLint>(stride); | |
| 184 case BufferFormat::ATC: | |
| 185 case BufferFormat::ATCIA: | |
| 186 case BufferFormat::DXT1: | |
| 187 case BufferFormat::DXT5: | 155 case BufferFormat::DXT5: |
| 188 case BufferFormat::ETC1: | 156 case BufferFormat::ETC1: |
| 189 case BufferFormat::YUV_420: | 157 case BufferFormat::YUV_420: |
| 190 case BufferFormat::YUV_420_BIPLANAR: | 158 case BufferFormat::YUV_420_BIPLANAR: |
| 191 case BufferFormat::UYVY_422: | 159 case BufferFormat::UYVY_422: |
| 192 NOTREACHED(); | 160 NOTREACHED(); |
| 193 return 0; | 161 return 0; |
| 194 } | 162 } |
| 195 | 163 |
| 196 NOTREACHED(); | 164 NOTREACHED(); |
| 197 return 0; | 165 return 0; |
| 198 } | 166 } |
| 199 | 167 |
| 200 template <typename F> | 168 template <typename F> |
| 201 scoped_ptr<uint8_t[]> GLES2RGBData(const gfx::Size& size, | 169 scoped_ptr<uint8_t[]> GLES2RGBData(const gfx::Size& size, |
| 202 BufferFormat format, | 170 BufferFormat format, |
| 203 size_t stride, | |
| 204 const uint8_t* data, | 171 const uint8_t* data, |
| 205 F const& data_to_rgb, | 172 F const& data_to_rgb, |
| 206 GLenum* data_format, | 173 GLenum* data_format, |
| 207 GLenum* data_type, | 174 GLenum* data_type) { |
| 208 GLint* data_row_length) { | |
| 209 TRACE_EVENT2("gpu", "GLES2RGBData", "width", size.width(), "height", | 175 TRACE_EVENT2("gpu", "GLES2RGBData", "width", size.width(), "height", |
| 210 size.height()); | 176 size.height()); |
| 211 | 177 |
| 212 // Four-byte row alignment as specified by glPixelStorei with argument | 178 // Four-byte row alignment as specified by glPixelStorei with argument |
| 213 // GL_UNPACK_ALIGNMENT set to 4. | 179 // GL_UNPACK_ALIGNMENT set to 4. |
| 214 size_t gles2_rgb_data_stride = (size.width() * 3 + 3) & ~3; | 180 size_t gles2_rgb_data_stride = (size.width() * 3 + 3) & ~3; |
| 215 scoped_ptr<uint8_t[]> gles2_rgb_data( | 181 scoped_ptr<uint8_t[]> gles2_rgb_data( |
| 216 new uint8_t[gles2_rgb_data_stride * size.height()]); | 182 new uint8_t[gles2_rgb_data_stride * size.height()]); |
| 183 size_t data_stride = RowSizeForBufferFormat(size.width(), format, 0); |
| 217 | 184 |
| 218 for (int y = 0; y < size.height(); ++y) { | 185 for (int y = 0; y < size.height(); ++y) { |
| 219 for (int x = 0; x < size.width(); ++x) { | 186 for (int x = 0; x < size.width(); ++x) { |
| 220 data_to_rgb(&data[y * stride + x * 4], | 187 data_to_rgb(&data[y * data_stride + x * 4], |
| 221 &gles2_rgb_data[y * gles2_rgb_data_stride + x * 3]); | 188 &gles2_rgb_data[y * gles2_rgb_data_stride + x * 3]); |
| 222 } | 189 } |
| 223 } | 190 } |
| 224 | 191 |
| 225 *data_format = GL_RGB; | 192 *data_format = GL_RGB; |
| 226 *data_type = GL_UNSIGNED_BYTE; | 193 *data_type = GL_UNSIGNED_BYTE; |
| 227 *data_row_length = size.width(); | |
| 228 return gles2_rgb_data.Pass(); | 194 return gles2_rgb_data.Pass(); |
| 229 } | 195 } |
| 230 | 196 |
| 231 scoped_ptr<uint8_t[]> GLES2Data(const gfx::Size& size, | 197 scoped_ptr<uint8_t[]> GLES2Data(const gfx::Size& size, |
| 232 BufferFormat format, | 198 BufferFormat format, |
| 233 size_t stride, | |
| 234 const uint8_t* data, | 199 const uint8_t* data, |
| 235 GLenum* data_format, | 200 GLenum* data_format, |
| 236 GLenum* data_type, | 201 GLenum* data_type) { |
| 237 GLint* data_row_length) { | |
| 238 TRACE_EVENT2("gpu", "GLES2Data", "width", size.width(), "height", | |
| 239 size.height()); | |
| 240 | |
| 241 switch (format) { | 202 switch (format) { |
| 242 case BufferFormat::RGBX_8888: | 203 case BufferFormat::RGBX_8888: |
| 243 return GLES2RGBData(size, format, stride, | 204 return GLES2RGBData(size, format, |
| 244 data, [](const uint8_t* src, uint8_t* dst) { | 205 data, [](const uint8_t* src, uint8_t* dst) { |
| 245 dst[0] = src[0]; | 206 dst[0] = src[0]; |
| 246 dst[1] = src[1]; | 207 dst[1] = src[1]; |
| 247 dst[2] = src[2]; | 208 dst[2] = src[2]; |
| 248 }, data_format, data_type, data_row_length); | 209 }, data_format, data_type); |
| 249 case BufferFormat::BGRX_8888: | 210 case BufferFormat::BGRX_8888: |
| 250 return GLES2RGBData(size, format, stride, | 211 return GLES2RGBData(size, format, |
| 251 data, [](const uint8_t* src, uint8_t* dst) { | 212 data, [](const uint8_t* src, uint8_t* dst) { |
| 252 dst[0] = src[2]; | 213 dst[0] = src[2]; |
| 253 dst[1] = src[1]; | 214 dst[1] = src[1]; |
| 254 dst[2] = src[0]; | 215 dst[2] = src[0]; |
| 255 }, data_format, data_type, data_row_length); | 216 }, data_format, data_type); |
| 256 case BufferFormat::RGBA_4444: | 217 case BufferFormat::RGBA_4444: |
| 257 case BufferFormat::RGBA_8888: | 218 case BufferFormat::RGBA_8888: |
| 258 case BufferFormat::BGRA_8888: | 219 case BufferFormat::BGRA_8888: |
| 259 case BufferFormat::R_8: { | 220 case BufferFormat::R_8: |
| 260 size_t gles2_data_stride = | |
| 261 RowSizeForBufferFormat(size.width(), format, 0); | |
| 262 if (stride == gles2_data_stride) | |
| 263 return nullptr; // No data conversion needed | |
| 264 | |
| 265 scoped_ptr<uint8_t[]> gles2_data( | |
| 266 new uint8_t[gles2_data_stride * size.height()]); | |
| 267 for (int y = 0; y < size.height(); ++y) { | |
| 268 memcpy(&gles2_data[y * gles2_data_stride], &data[y * stride], | |
| 269 gles2_data_stride); | |
| 270 } | |
| 271 *data_row_length = size.width(); | |
| 272 return gles2_data.Pass(); | |
| 273 } | |
| 274 case BufferFormat::ATC: | 221 case BufferFormat::ATC: |
| 275 case BufferFormat::ATCIA: | 222 case BufferFormat::ATCIA: |
| 276 case BufferFormat::DXT1: | 223 case BufferFormat::DXT1: |
| 277 case BufferFormat::DXT5: | 224 case BufferFormat::DXT5: |
| 278 case BufferFormat::ETC1: | 225 case BufferFormat::ETC1: |
| 279 return nullptr; // No data conversion needed | |
| 280 case BufferFormat::YUV_420: | 226 case BufferFormat::YUV_420: |
| 281 case BufferFormat::YUV_420_BIPLANAR: | 227 case BufferFormat::YUV_420_BIPLANAR: |
| 282 case BufferFormat::UYVY_422: | 228 case BufferFormat::UYVY_422: |
| 283 NOTREACHED(); | 229 // No data conversion needed. |
| 284 return nullptr; | 230 return nullptr; |
| 285 } | 231 } |
| 286 | 232 |
| 287 NOTREACHED(); | 233 NOTREACHED(); |
| 288 return nullptr; | 234 return 0; |
| 289 } | 235 } |
| 290 | 236 |
| 291 } // namespace | 237 } // namespace |
| 292 | 238 |
| 293 GLImageMemory::GLImageMemory(const gfx::Size& size, unsigned internalformat) | 239 GLImageMemory::GLImageMemory(const gfx::Size& size, unsigned internalformat) |
| 294 : size_(size), | 240 : size_(size), |
| 295 internalformat_(internalformat), | 241 internalformat_(internalformat), |
| 296 memory_(nullptr), | 242 memory_(nullptr), |
| 297 format_(BufferFormat::RGBA_8888), | 243 format_(BufferFormat::RGBA_8888) {} |
| 298 stride_(0) {} | |
| 299 | 244 |
| 300 GLImageMemory::~GLImageMemory() { | 245 GLImageMemory::~GLImageMemory() { |
| 301 DCHECK(!memory_); | 246 DCHECK(!memory_); |
| 302 } | 247 } |
| 303 | 248 |
| 304 bool GLImageMemory::Initialize(const unsigned char* memory, | 249 bool GLImageMemory::Initialize(const unsigned char* memory, |
| 305 BufferFormat format, | 250 BufferFormat format) { |
| 306 size_t stride) { | |
| 307 if (!ValidInternalFormat(internalformat_)) { | 251 if (!ValidInternalFormat(internalformat_)) { |
| 308 LOG(ERROR) << "Invalid internalformat: " << internalformat_; | 252 LOG(ERROR) << "Invalid internalformat: " << internalformat_; |
| 309 return false; | 253 return false; |
| 310 } | 254 } |
| 311 | 255 |
| 312 if (!ValidFormat(format)) { | 256 if (!ValidFormat(format)) { |
| 313 LOG(ERROR) << "Invalid format: " << static_cast<int>(format); | 257 LOG(ERROR) << "Invalid format: " << static_cast<int>(format); |
| 314 return false; | 258 return false; |
| 315 } | 259 } |
| 316 | 260 |
| 317 if (stride < RowSizeForBufferFormat(size_.width(), format, 0) || stride & 3) { | |
| 318 LOG(ERROR) << "Invalid stride: " << stride; | |
| 319 return false; | |
| 320 } | |
| 321 | |
| 322 DCHECK(memory); | 261 DCHECK(memory); |
| 323 DCHECK(!memory_); | 262 DCHECK(!memory_); |
| 324 DCHECK(!IsCompressedFormat(format) || size_.width() % 4 == 0); | 263 DCHECK(!IsCompressedFormat(format) || size_.width() % 4 == 0); |
| 325 DCHECK(!IsCompressedFormat(format) || size_.height() % 4 == 0); | 264 DCHECK(!IsCompressedFormat(format) || size_.height() % 4 == 0); |
| 326 memory_ = memory; | 265 memory_ = memory; |
| 327 format_ = format; | 266 format_ = format; |
| 328 stride_ = stride; | |
| 329 return true; | 267 return true; |
| 330 } | 268 } |
| 331 | 269 |
| 332 void GLImageMemory::Destroy(bool have_context) { | 270 void GLImageMemory::Destroy(bool have_context) { |
| 333 memory_ = nullptr; | 271 memory_ = nullptr; |
| 334 } | 272 } |
| 335 | 273 |
| 336 gfx::Size GLImageMemory::GetSize() { | 274 gfx::Size GLImageMemory::GetSize() { |
| 337 return size_; | 275 return size_; |
| 338 } | 276 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 352 // GL_TEXTURE_EXTERNAL_OES is not a supported target. | 290 // GL_TEXTURE_EXTERNAL_OES is not a supported target. |
| 353 if (target == GL_TEXTURE_EXTERNAL_OES) | 291 if (target == GL_TEXTURE_EXTERNAL_OES) |
| 354 return false; | 292 return false; |
| 355 | 293 |
| 356 if (IsCompressedFormat(format_)) { | 294 if (IsCompressedFormat(format_)) { |
| 357 glCompressedTexImage2D( | 295 glCompressedTexImage2D( |
| 358 target, 0, TextureFormat(format_), size_.width(), size_.height(), 0, | 296 target, 0, TextureFormat(format_), size_.width(), size_.height(), 0, |
| 359 static_cast<GLsizei>(BufferSizeForBufferFormat(size_, format_)), | 297 static_cast<GLsizei>(BufferSizeForBufferFormat(size_, format_)), |
| 360 memory_); | 298 memory_); |
| 361 } else { | 299 } else { |
| 300 scoped_ptr<uint8_t[]> gles2_data; |
| 362 GLenum data_format = DataFormat(format_); | 301 GLenum data_format = DataFormat(format_); |
| 363 GLenum data_type = DataType(format_); | 302 GLenum data_type = DataType(format_); |
| 364 GLint data_row_length = DataRowLength(stride_, format_); | |
| 365 scoped_ptr<uint8_t[]> gles2_data; | |
| 366 | 303 |
| 367 if (gfx::GLContext::GetCurrent()->GetVersionInfo()->is_es) { | 304 if (gfx::GLContext::GetCurrent()->GetVersionInfo()->is_es) |
| 368 gles2_data = GLES2Data(size_, format_, stride_, memory_, &data_format, | 305 gles2_data = GLES2Data(size_, format_, memory_, &data_format, &data_type); |
| 369 &data_type, &data_row_length); | |
| 370 } | |
| 371 | |
| 372 if (data_row_length != size_.width()) | |
| 373 glPixelStorei(GL_UNPACK_ROW_LENGTH, data_row_length); | |
| 374 | 306 |
| 375 glTexImage2D(target, 0, TextureFormat(format_), size_.width(), | 307 glTexImage2D(target, 0, TextureFormat(format_), size_.width(), |
| 376 size_.height(), 0, data_format, data_type, | 308 size_.height(), 0, data_format, data_type, |
| 377 gles2_data ? gles2_data.get() : memory_); | 309 gles2_data ? gles2_data.get() : memory_); |
| 378 | |
| 379 if (data_row_length != size_.width()) | |
| 380 glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); | |
| 381 } | 310 } |
| 382 | 311 |
| 383 return true; | 312 return true; |
| 384 } | 313 } |
| 385 | 314 |
| 386 bool GLImageMemory::CopyTexSubImage(unsigned target, | 315 bool GLImageMemory::CopyTexSubImage(unsigned target, |
| 387 const gfx::Point& offset, | 316 const gfx::Point& offset, |
| 388 const gfx::Rect& rect) { | 317 const gfx::Rect& rect) { |
| 389 TRACE_EVENT2("gpu", "GLImageMemory::CopyTexSubImage", "width", rect.width(), | 318 TRACE_EVENT2("gpu", "GLImageMemory::CopyTexSubImage", "width", rect.width(), |
| 390 "height", rect.height()); | 319 "height", rect.height()); |
| 391 | 320 |
| 392 // GL_TEXTURE_EXTERNAL_OES is not a supported target. | 321 // GL_TEXTURE_EXTERNAL_OES is not a supported target. |
| 393 if (target == GL_TEXTURE_EXTERNAL_OES) | 322 if (target == GL_TEXTURE_EXTERNAL_OES) |
| 394 return false; | 323 return false; |
| 395 | 324 |
| 396 // Sub width is not supported. | 325 // Sub width is not supported. |
| 397 if (rect.width() != size_.width()) | 326 if (rect.width() != size_.width()) |
| 398 return false; | 327 return false; |
| 399 | 328 |
| 400 const uint8_t* data = memory_ + rect.y() * stride_; | 329 // Height must be a multiple of 4 if compressed. |
| 330 if (IsCompressedFormat(format_) && rect.height() % 4) |
| 331 return false; |
| 332 |
| 333 const uint8_t* data = |
| 334 memory_ + rect.y() * RowSizeForBufferFormat(size_.width(), format_, 0); |
| 401 if (IsCompressedFormat(format_)) { | 335 if (IsCompressedFormat(format_)) { |
| 402 // Height must be a multiple of 4. | |
| 403 if (rect.height() % 4) | |
| 404 return false; | |
| 405 | |
| 406 glCompressedTexSubImage2D( | 336 glCompressedTexSubImage2D( |
| 407 target, 0, offset.x(), offset.y(), rect.width(), rect.height(), | 337 target, 0, offset.x(), offset.y(), rect.width(), rect.height(), |
| 408 DataFormat(format_), | 338 DataFormat(format_), |
| 409 static_cast<GLsizei>(BufferSizeForBufferFormat(rect.size(), format_)), | 339 static_cast<GLsizei>(BufferSizeForBufferFormat(rect.size(), format_)), |
| 410 data); | 340 data); |
| 411 } else { | 341 } else { |
| 412 GLenum data_format = DataFormat(format_); | 342 GLenum data_format = DataFormat(format_); |
| 413 GLenum data_type = DataType(format_); | 343 GLenum data_type = DataType(format_); |
| 414 GLint data_row_length = DataRowLength(stride_, format_); | |
| 415 scoped_ptr<uint8_t[]> gles2_data; | 344 scoped_ptr<uint8_t[]> gles2_data; |
| 416 | 345 |
| 417 if (gfx::GLContext::GetCurrent()->GetVersionInfo()->is_es) { | 346 if (gfx::GLContext::GetCurrent()->GetVersionInfo()->is_es) { |
| 418 gles2_data = GLES2Data(rect.size(), format_, stride_, data, &data_format, | 347 gles2_data = |
| 419 &data_type, &data_row_length); | 348 GLES2Data(rect.size(), format_, data, &data_format, &data_type); |
| 420 } | 349 } |
| 421 | 350 |
| 422 if (data_row_length != rect.width()) | |
| 423 glPixelStorei(GL_UNPACK_ROW_LENGTH, data_row_length); | |
| 424 | |
| 425 glTexSubImage2D(target, 0, offset.x(), offset.y(), rect.width(), | 351 glTexSubImage2D(target, 0, offset.x(), offset.y(), rect.width(), |
| 426 rect.height(), data_format, data_type, | 352 rect.height(), data_format, data_type, |
| 427 gles2_data ? gles2_data.get() : data); | 353 gles2_data ? gles2_data.get() : data); |
| 428 | |
| 429 if (data_row_length != rect.width()) | |
| 430 glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); | |
| 431 } | 354 } |
| 432 | 355 |
| 433 return true; | 356 return true; |
| 434 } | 357 } |
| 435 | 358 |
| 436 bool GLImageMemory::ScheduleOverlayPlane(gfx::AcceleratedWidget widget, | 359 bool GLImageMemory::ScheduleOverlayPlane(gfx::AcceleratedWidget widget, |
| 437 int z_order, | 360 int z_order, |
| 438 gfx::OverlayTransform transform, | 361 gfx::OverlayTransform transform, |
| 439 const gfx::Rect& bounds_rect, | 362 const gfx::Rect& bounds_rect, |
| 440 const gfx::RectF& crop_rect) { | 363 const gfx::RectF& crop_rect) { |
| 441 return false; | 364 return false; |
| 442 } | 365 } |
| 443 | 366 |
| 444 // static | 367 // static |
| 445 unsigned GLImageMemory::GetInternalFormatForTesting(BufferFormat format) { | 368 unsigned GLImageMemory::GetInternalFormatForTesting(BufferFormat format) { |
| 446 DCHECK(ValidFormat(format)); | 369 DCHECK(ValidFormat(format)); |
| 447 return TextureFormat(format); | 370 return TextureFormat(format); |
| 448 } | 371 } |
| 449 | 372 |
| 450 } // namespace gl | 373 } // namespace gl |
| OLD | NEW |