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

Side by Side Diff: core/cross/gl/texture_gl.cc

Issue 159168: This fixes a number of things that are warnings in the Mac compiler.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/o3d/
Patch Set: Created 11 years, 5 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright 2009, Google Inc. 2 * Copyright 2009, Google Inc.
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 } else { 128 } else {
129 // TODO: we need to convert DXT3 -> RGBA8 but keep around the 129 // TODO: we need to convert DXT3 -> RGBA8 but keep around the
130 // pixels so that we can read them back (we won't try to convert back 130 // pixels so that we can read them back (we won't try to convert back
131 // to DXTC). 131 // to DXTC).
132 LOG(ERROR) << "DXT5 compressed textures not supported yet."; 132 LOG(ERROR) << "DXT5 compressed textures not supported yet.";
133 *internal_format = 0; 133 *internal_format = 0;
134 *data_type = GL_BYTE; 134 *data_type = GL_BYTE;
135 return 0; 135 return 0;
136 } 136 }
137 } 137 }
138 case Texture::UNKNOWN_FORMAT:
139 break;
138 } 140 }
139 // failed to find a matching format 141 // failed to find a matching format
140 LOG(ERROR) << "Unrecognized Texture format type."; 142 LOG(ERROR) << "Unrecognized Texture format type.";
141 *internal_format = 0; 143 *internal_format = 0;
142 *data_type = 0; 144 *data_type = 0;
143 return 0; 145 return 0;
144 } 146 }
145 147
146 // Updates a GL image from a bitmap, rescaling if necessary. 148 // Updates a GL image from a bitmap, rescaling if necessary.
147 static bool UpdateGLImageFromBitmap(GLenum target, 149 static bool UpdateGLImageFromBitmap(GLenum target,
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 bitmap.width(), 264 bitmap.width(),
263 bitmap.height(), 265 bitmap.height(),
264 bitmap.format(), 266 bitmap.format(),
265 bitmap.num_mipmaps(), 267 bitmap.num_mipmaps(),
266 bitmap.CheckAlphaIsOne(), 268 bitmap.CheckAlphaIsOne(),
267 resize_to_pot, 269 resize_to_pot,
268 enable_render_surfaces), 270 enable_render_surfaces),
269 renderer_(static_cast<RendererGL*>( 271 renderer_(static_cast<RendererGL*>(
270 service_locator->GetService<Renderer>())), 272 service_locator->GetService<Renderer>())),
271 gl_texture_(texture), 273 gl_texture_(texture),
272 has_levels_(0), 274 backing_bitmap_(Bitmap::Ref(new Bitmap(service_locator))),
273 backing_bitmap_(Bitmap::Ref(new Bitmap(service_locator))) { 275 has_levels_(0) {
274 DLOG(INFO) << "Texture2DGL Construct from GLint"; 276 DLOG(INFO) << "Texture2DGL Construct from GLint";
275 DCHECK_NE(format(), Texture::UNKNOWN_FORMAT); 277 DCHECK_NE(format(), Texture::UNKNOWN_FORMAT);
276 } 278 }
277 279
278 // Creates a new texture object from scratch. 280 // Creates a new texture object from scratch.
279 Texture2DGL* Texture2DGL::Create(ServiceLocator* service_locator, 281 Texture2DGL* Texture2DGL::Create(ServiceLocator* service_locator,
280 Bitmap *bitmap, 282 Bitmap *bitmap,
281 bool enable_render_surfaces) { 283 bool enable_render_surfaces) {
282 DLOG(INFO) << "Texture2DGL Create"; 284 DLOG(INFO) << "Texture2DGL Create";
283 DCHECK_NE(bitmap->format(), Texture::UNKNOWN_FORMAT); 285 DCHECK_NE(bitmap->format(), Texture::UNKNOWN_FORMAT);
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 memset(texture->backing_bitmap_->image_data(), 0, 350 memset(texture->backing_bitmap_->image_data(), 0,
349 texture->backing_bitmap_->GetTotalSize()); 351 texture->backing_bitmap_->GetTotalSize());
350 texture->has_levels_ = (1 << bitmap->num_mipmaps()) - 1; 352 texture->has_levels_ = (1 << bitmap->num_mipmaps()) - 1;
351 } 353 }
352 } 354 }
353 CHECK_GL_ERROR(); 355 CHECK_GL_ERROR();
354 return texture; 356 return texture;
355 } 357 }
356 358
357 void Texture2DGL::UpdateBackedMipLevel(unsigned int level) { 359 void Texture2DGL::UpdateBackedMipLevel(unsigned int level) {
358 DCHECK_LT(level, levels()); 360 DCHECK_LT(static_cast<int>(level), levels());
359 DCHECK(backing_bitmap_->image_data()); 361 DCHECK(backing_bitmap_->image_data());
360 DCHECK_EQ(backing_bitmap_->width(), width()); 362 DCHECK_EQ(backing_bitmap_->width(), static_cast<unsigned int>(width()));
361 DCHECK_EQ(backing_bitmap_->height(), height()); 363 DCHECK_EQ(backing_bitmap_->height(), static_cast<unsigned int>(height()));
362 DCHECK_EQ(backing_bitmap_->format(), format()); 364 DCHECK_EQ(backing_bitmap_->format(), format());
363 DCHECK(HasLevel(level)); 365 DCHECK(HasLevel(level));
364 glBindTexture(GL_TEXTURE_2D, gl_texture_); 366 glBindTexture(GL_TEXTURE_2D, gl_texture_);
365 UpdateGLImageFromBitmap(GL_TEXTURE_2D, level, TextureCUBE::FACE_POSITIVE_X, 367 UpdateGLImageFromBitmap(GL_TEXTURE_2D, level, TextureCUBE::FACE_POSITIVE_X,
366 *backing_bitmap_.Get(), resize_to_pot_); 368 *backing_bitmap_.Get(), resize_to_pot_);
367 } 369 }
368 370
369 Texture2DGL::~Texture2DGL() { 371 Texture2DGL::~Texture2DGL() {
370 DLOG(INFO) << "Texture2DGL Destruct"; 372 DLOG(INFO) << "Texture2DGL Destruct";
371 if (gl_texture_) { 373 if (gl_texture_) {
(...skipping 15 matching lines...) Expand all
387 << " on Texture \"" << name(); 389 << " on Texture \"" << name();
388 return false; 390 return false;
389 } 391 }
390 if (IsLocked(level)) { 392 if (IsLocked(level)) {
391 O3D_ERROR(service_locator()) 393 O3D_ERROR(service_locator())
392 << "Level " << level << " of texture \"" << name() 394 << "Level " << level << " of texture \"" << name()
393 << "\" is already locked."; 395 << "\" is already locked.";
394 return false; 396 return false;
395 } 397 }
396 if (!backing_bitmap_->image_data()) { 398 if (!backing_bitmap_->image_data()) {
397 DCHECK_EQ(has_levels_, 0); 399 DCHECK_EQ(has_levels_, 0u);
398 backing_bitmap_->Allocate(format(), width(), height(), levels(), false); 400 backing_bitmap_->Allocate(format(), width(), height(), levels(), false);
399 } 401 }
400 *data = backing_bitmap_->GetMipData(level, TextureCUBE::FACE_POSITIVE_X); 402 *data = backing_bitmap_->GetMipData(level, TextureCUBE::FACE_POSITIVE_X);
401 if (!HasLevel(level)) { 403 if (!HasLevel(level)) {
402 // TODO: add some API so we don't have to copy back the data if we 404 // TODO: add some API so we don't have to copy back the data if we
403 // will rewrite it all. 405 // will rewrite it all.
404 DCHECK(!resize_to_pot_); 406 DCHECK(!resize_to_pot_);
405 GLenum gl_internal_format = 0; 407 GLenum gl_internal_format = 0;
406 GLenum gl_data_type = 0; 408 GLenum gl_data_type = 0;
407 GLenum gl_format = GLFormatFromO3DFormat(format(), 409 GLenum gl_format = GLFormatFromO3DFormat(format(),
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 } 600 }
599 } 601 }
600 } 602 }
601 CHECK_GL_ERROR(); 603 CHECK_GL_ERROR();
602 DLOG(INFO) << "Created cube map texture (GLuint=" << gl_texture << ")"; 604 DLOG(INFO) << "Created cube map texture (GLuint=" << gl_texture << ")";
603 return texture; 605 return texture;
604 } 606 }
605 607
606 void TextureCUBEGL::UpdateBackedMipLevel(unsigned int level, 608 void TextureCUBEGL::UpdateBackedMipLevel(unsigned int level,
607 TextureCUBE::CubeFace face) { 609 TextureCUBE::CubeFace face) {
608 DCHECK_LT(level, levels()); 610 DCHECK_LT(static_cast<int>(level), levels());
609 DCHECK(backing_bitmap_->image_data()); 611 DCHECK(backing_bitmap_->image_data());
610 DCHECK(backing_bitmap_->is_cubemap()); 612 DCHECK(backing_bitmap_->is_cubemap());
611 DCHECK_EQ(backing_bitmap_->width(), edge_length()); 613 DCHECK_EQ(backing_bitmap_->width(), static_cast<unsigned int>(edge_length()));
612 DCHECK_EQ(backing_bitmap_->height(), edge_length()); 614 DCHECK_EQ(backing_bitmap_->height(),
615 static_cast<unsigned int>(edge_length()));
613 DCHECK_EQ(backing_bitmap_->format(), format()); 616 DCHECK_EQ(backing_bitmap_->format(), format());
614 DCHECK(HasLevel(level, face)); 617 DCHECK(HasLevel(level, face));
615 glBindTexture(GL_TEXTURE_2D, gl_texture_); 618 glBindTexture(GL_TEXTURE_2D, gl_texture_);
616 UpdateGLImageFromBitmap(kCubemapFaceList[face], level, face, 619 UpdateGLImageFromBitmap(kCubemapFaceList[face], level, face,
617 *backing_bitmap_.Get(), 620 *backing_bitmap_.Get(),
618 resize_to_pot_); 621 resize_to_pot_);
619 } 622 }
620 623
621 RenderSurface::Ref TextureCUBEGL::GetRenderSurface(TextureCUBE::CubeFace face, 624 RenderSurface::Ref TextureCUBEGL::GetRenderSurface(TextureCUBE::CubeFace face,
622 int mip_level, 625 int mip_level,
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 } 668 }
666 if (IsLocked(level, face)) { 669 if (IsLocked(level, face)) {
667 O3D_ERROR(service_locator()) 670 O3D_ERROR(service_locator())
668 << "Level " << level << " Face " << face 671 << "Level " << level << " Face " << face
669 << " of texture \"" << name() 672 << " of texture \"" << name()
670 << "\" is already locked."; 673 << "\" is already locked.";
671 return false; 674 return false;
672 } 675 }
673 if (!backing_bitmap_->image_data()) { 676 if (!backing_bitmap_->image_data()) {
674 for (unsigned int i = 0; i < 6; ++i) { 677 for (unsigned int i = 0; i < 6; ++i) {
675 DCHECK_EQ(has_levels_[i], 0); 678 DCHECK_EQ(has_levels_[i], 0u);
676 } 679 }
677 backing_bitmap_->Allocate(format(), edge_length(), edge_length(), 680 backing_bitmap_->Allocate(format(), edge_length(), edge_length(),
678 levels(), true); 681 levels(), true);
679 } 682 }
680 *data = backing_bitmap_->GetMipData(level, face); 683 *data = backing_bitmap_->GetMipData(level, face);
681 GLenum gl_target = kCubemapFaceList[face]; 684 GLenum gl_target = kCubemapFaceList[face];
682 if (!HasLevel(level, face)) { 685 if (!HasLevel(level, face)) {
683 // TODO: add some API so we don't have to copy back the data if we 686 // TODO: add some API so we don't have to copy back the data if we
684 // will rewrite it all. 687 // will rewrite it all.
685 DCHECK(!resize_to_pot_); 688 DCHECK(!resize_to_pot_);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 } 736 }
734 CHECK_GL_ERROR(); 737 CHECK_GL_ERROR();
735 return false; 738 return false;
736 } 739 }
737 740
738 const Texture::RGBASwizzleIndices& TextureCUBEGL::GetABGR32FSwizzleIndices() { 741 const Texture::RGBASwizzleIndices& TextureCUBEGL::GetABGR32FSwizzleIndices() {
739 return g_gl_abgr32f_swizzle_indices; 742 return g_gl_abgr32f_swizzle_indices;
740 } 743 }
741 744
742 } // namespace o3d 745 } // namespace o3d
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698