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

Side by Side Diff: ui/gl/gl_image_memory.cc

Issue 2449993005: Remove GLImage::Destroy(). (Closed)
Patch Set: One more Destroy() call on Mac. Created 4 years, 1 month 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
« no previous file with comments | « ui/gl/gl_image_memory.h ('k') | ui/gl/gl_image_ref_counted_memory.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 345
346 } // namespace 346 } // namespace
347 347
348 GLImageMemory::GLImageMemory(const gfx::Size& size, unsigned internalformat) 348 GLImageMemory::GLImageMemory(const gfx::Size& size, unsigned internalformat)
349 : size_(size), 349 : size_(size),
350 internalformat_(internalformat), 350 internalformat_(internalformat),
351 memory_(nullptr), 351 memory_(nullptr),
352 format_(gfx::BufferFormat::RGBA_8888), 352 format_(gfx::BufferFormat::RGBA_8888),
353 stride_(0) {} 353 stride_(0) {}
354 354
355 GLImageMemory::~GLImageMemory() { 355 GLImageMemory::~GLImageMemory() {}
356 DCHECK(!memory_);
357 }
358 356
359 bool GLImageMemory::Initialize(const unsigned char* memory, 357 bool GLImageMemory::Initialize(const unsigned char* memory,
360 gfx::BufferFormat format, 358 gfx::BufferFormat format,
361 size_t stride) { 359 size_t stride) {
362 if (!ValidInternalFormat(internalformat_)) { 360 if (!ValidInternalFormat(internalformat_)) {
363 LOG(ERROR) << "Invalid internalformat: " << internalformat_; 361 LOG(ERROR) << "Invalid internalformat: " << internalformat_;
364 return false; 362 return false;
365 } 363 }
366 364
367 if (!ValidFormat(format)) { 365 if (!ValidFormat(format)) {
368 LOG(ERROR) << "Invalid format: " << static_cast<int>(format); 366 LOG(ERROR) << "Invalid format: " << static_cast<int>(format);
369 return false; 367 return false;
370 } 368 }
371 369
372 if (stride < RowSizeForBufferFormat(size_.width(), format, 0) || stride & 3) { 370 if (stride < RowSizeForBufferFormat(size_.width(), format, 0) || stride & 3) {
373 LOG(ERROR) << "Invalid stride: " << stride; 371 LOG(ERROR) << "Invalid stride: " << stride;
374 return false; 372 return false;
375 } 373 }
376 374
377 DCHECK(memory); 375 DCHECK(memory);
378 DCHECK(!memory_); 376 DCHECK(!memory_);
379 DCHECK(!IsCompressedFormat(format) || size_.width() % 4 == 0); 377 DCHECK(!IsCompressedFormat(format) || size_.width() % 4 == 0);
380 DCHECK(!IsCompressedFormat(format) || size_.height() % 4 == 0); 378 DCHECK(!IsCompressedFormat(format) || size_.height() % 4 == 0);
381 memory_ = memory; 379 memory_ = memory;
382 format_ = format; 380 format_ = format;
383 stride_ = stride; 381 stride_ = stride;
384 return true; 382 return true;
385 } 383 }
386 384
387 void GLImageMemory::Destroy(bool have_context) {
388 memory_ = nullptr;
389 }
390
391 gfx::Size GLImageMemory::GetSize() { 385 gfx::Size GLImageMemory::GetSize() {
392 return size_; 386 return size_;
393 } 387 }
394 388
395 unsigned GLImageMemory::GetInternalFormat() { 389 unsigned GLImageMemory::GetInternalFormat() {
396 return internalformat_; 390 return internalformat_;
397 } 391 }
398 392
399 bool GLImageMemory::BindTexImage(unsigned target) { 393 bool GLImageMemory::BindTexImage(unsigned target) {
400 return false; 394 return false;
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 return false; 490 return false;
497 } 491 }
498 492
499 // static 493 // static
500 unsigned GLImageMemory::GetInternalFormatForTesting(gfx::BufferFormat format) { 494 unsigned GLImageMemory::GetInternalFormatForTesting(gfx::BufferFormat format) {
501 DCHECK(ValidFormat(format)); 495 DCHECK(ValidFormat(format));
502 return TextureFormat(format); 496 return TextureFormat(format);
503 } 497 }
504 498
505 } // namespace gl 499 } // namespace gl
OLDNEW
« no previous file with comments | « ui/gl/gl_image_memory.h ('k') | ui/gl/gl_image_ref_counted_memory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698