| 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 <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/numerics/safe_conversions.h" | 10 #include "base/numerics/safe_conversions.h" |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 | 356 |
| 357 GLImageMemory::GLImageMemory(const gfx::Size& size, unsigned internalformat) | 357 GLImageMemory::GLImageMemory(const gfx::Size& size, unsigned internalformat) |
| 358 : size_(size), | 358 : size_(size), |
| 359 internalformat_(internalformat), | 359 internalformat_(internalformat), |
| 360 memory_(nullptr), | 360 memory_(nullptr), |
| 361 format_(gfx::BufferFormat::RGBA_8888), | 361 format_(gfx::BufferFormat::RGBA_8888), |
| 362 stride_(0) {} | 362 stride_(0) {} |
| 363 | 363 |
| 364 GLImageMemory::~GLImageMemory() {} | 364 GLImageMemory::~GLImageMemory() {} |
| 365 | 365 |
| 366 // static |
| 367 GLImageMemory* GLImageMemory::FromGLImage(GLImage* image) { |
| 368 if (!image || image->GetType() != Type::MEMORY) |
| 369 return nullptr; |
| 370 return static_cast<GLImageMemory*>(image); |
| 371 } |
| 372 |
| 366 bool GLImageMemory::Initialize(const unsigned char* memory, | 373 bool GLImageMemory::Initialize(const unsigned char* memory, |
| 367 gfx::BufferFormat format, | 374 gfx::BufferFormat format, |
| 368 size_t stride) { | 375 size_t stride) { |
| 369 if (!ValidInternalFormat(internalformat_)) { | 376 if (!ValidInternalFormat(internalformat_)) { |
| 370 LOG(ERROR) << "Invalid internalformat: " << internalformat_; | 377 LOG(ERROR) << "Invalid internalformat: " << internalformat_; |
| 371 return false; | 378 return false; |
| 372 } | 379 } |
| 373 | 380 |
| 374 if (!ValidFormat(format)) { | 381 if (!ValidFormat(format)) { |
| 375 LOG(ERROR) << "Invalid format: " << static_cast<int>(format); | 382 LOG(ERROR) << "Invalid format: " << static_cast<int>(format); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 492 } | 499 } |
| 493 | 500 |
| 494 bool GLImageMemory::ScheduleOverlayPlane(gfx::AcceleratedWidget widget, | 501 bool GLImageMemory::ScheduleOverlayPlane(gfx::AcceleratedWidget widget, |
| 495 int z_order, | 502 int z_order, |
| 496 gfx::OverlayTransform transform, | 503 gfx::OverlayTransform transform, |
| 497 const gfx::Rect& bounds_rect, | 504 const gfx::Rect& bounds_rect, |
| 498 const gfx::RectF& crop_rect) { | 505 const gfx::RectF& crop_rect) { |
| 499 return false; | 506 return false; |
| 500 } | 507 } |
| 501 | 508 |
| 509 GLImageMemory::Type GLImageMemory::GetType() const { |
| 510 return Type::MEMORY; |
| 511 } |
| 512 |
| 502 // static | 513 // static |
| 503 unsigned GLImageMemory::GetInternalFormatForTesting(gfx::BufferFormat format) { | 514 unsigned GLImageMemory::GetInternalFormatForTesting(gfx::BufferFormat format) { |
| 504 DCHECK(ValidFormat(format)); | 515 DCHECK(ValidFormat(format)); |
| 505 return TextureFormat(format); | 516 return TextureFormat(format); |
| 506 } | 517 } |
| 507 | 518 |
| 508 } // namespace gl | 519 } // namespace gl |
| OLD | NEW |