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

Side by Side Diff: core/cross/command_buffer/texture_cb.cc

Issue 200127: Made gyp file for command buffer libraries.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/o3d/
Patch Set: '' Created 11 years, 3 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
« no previous file with comments | « core/cross/command_buffer/texture_cb.h ('k') | core/win/d3d9/utils_d3d9.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 /* 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 // Writes the data information into a buffer to be sent to the server side. 99 // Writes the data information into a buffer to be sent to the server side.
100 void SetTextureDataBuffer(Texture::Format format, 100 void SetTextureDataBuffer(Texture::Format format,
101 const void* src_data, 101 const void* src_data,
102 int src_pitch, 102 int src_pitch,
103 unsigned src_width, 103 unsigned src_width,
104 unsigned src_height, 104 unsigned src_height,
105 void* dst_buffer, 105 void* dst_buffer,
106 unsigned int dst_pitch) { 106 unsigned int dst_pitch) {
107 const uint8* src = static_cast<const uint8*>(src_data); 107 const uint8* src = static_cast<const uint8*>(src_data);
108 uint8* dst = static_cast<uint8*>(dst_buffer); 108 uint8* dst = static_cast<uint8*>(dst_buffer);
109 size_t bytes_per_line = image::ComputePitch(format, src_width); 109
110 for (unsigned yy = 0; yy < src_height; ++yy) { 110 size_t bytes_per_row = image::ComputePitch(format, src_width);
111 memcpy(dst, src, bytes_per_line); 111 unsigned num_rows = src_height;
112 if (Texture::IsCompressedFormat(format)) {
113 num_rows = (num_rows + 3) / 4;
114 }
115
116 for (unsigned yy = 0; yy < num_rows; ++yy) {
117 memcpy(dst, src, bytes_per_row);
112 src += src_pitch; 118 src += src_pitch;
113 dst += dst_pitch; 119 dst += dst_pitch;
114 } 120 }
115 } 121 }
122
116 // Sends the SET_TEXTURE_DATA command after formatting the args properly. 123 // Sends the SET_TEXTURE_DATA command after formatting the args properly.
117 void SetTextureData(RendererCB *renderer, 124 void SetTextureData(RendererCB *renderer,
118 ResourceID texture_id, 125 ResourceID texture_id,
119 unsigned int x, 126 unsigned int x,
120 unsigned int y, 127 unsigned int y,
121 unsigned int mip_width, 128 unsigned int mip_width,
122 unsigned int mip_height, 129 unsigned int mip_height,
123 unsigned int z, 130 unsigned int z,
124 unsigned int depth, 131 unsigned int depth,
125 unsigned int level, 132 unsigned int level,
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 } else { 402 } else {
396 unsigned blocks_across = (mip_width + 3) / 4; 403 unsigned blocks_across = (mip_width + 3) / 4;
397 unsigned bytes_per_block = format() == Texture::DXT1 ? 8 : 16; 404 unsigned bytes_per_block = format() == Texture::DXT1 ? 8 : 16;
398 unsigned bytes_per_row = bytes_per_block * blocks_across; 405 unsigned bytes_per_row = bytes_per_block * blocks_across;
399 *pitch = bytes_per_row; 406 *pitch = bytes_per_row;
400 } 407 }
401 if (mode != kWriteOnly && !HasLevel(level)) { 408 if (mode != kWriteOnly && !HasLevel(level)) {
402 DCHECK_EQ(backing_bitmap_->width(), width()); 409 DCHECK_EQ(backing_bitmap_->width(), width());
403 DCHECK_EQ(backing_bitmap_->height(), height()); 410 DCHECK_EQ(backing_bitmap_->height(), height());
404 DCHECK_EQ(backing_bitmap_->format(), format()); 411 DCHECK_EQ(backing_bitmap_->format(), format());
405 DCHECK_GT(backing_bitmap_->num_mipmaps(), level); 412 DCHECK_GT(backing_bitmap_->num_mipmaps(), static_cast<unsigned int>(level));
406 CopyBackResourceToBitmap(renderer_, resource_id_, level, 413 CopyBackResourceToBitmap(renderer_, resource_id_, level,
407 TextureCUBE::FACE_POSITIVE_X, 414 TextureCUBE::FACE_POSITIVE_X,
408 *backing_bitmap_.Get()); 415 *backing_bitmap_.Get());
409 has_levels_ |= 1 << level; 416 has_levels_ |= 1 << level;
410 } 417 }
411 locked_levels_ |= 1 << level; 418 locked_levels_ |= 1 << level;
412 return true; 419 return true;
413 } 420 }
414 421
415 // Unlocks the given mipmap level of this texture, uploading the main memory 422 // Unlocks the given mipmap level of this texture, uploading the main memory
416 // data buffer to the command buffer service. 423 // data buffer to the command buffer service.
417 bool Texture2DCB::PlatformSpecificUnlock(int level) { 424 bool Texture2DCB::PlatformSpecificUnlock(int level) {
418 DCHECK_GE(level, 0); 425 DCHECK_GE(level, 0);
419 DCHECK_LT(level, levels()); 426 DCHECK_LT(level, levels());
420 DCHECK(backing_bitmap_->image_data()); 427 DCHECK(backing_bitmap_->image_data());
421 DCHECK_EQ(backing_bitmap_->width(), width()); 428 DCHECK_EQ(backing_bitmap_->width(), width());
422 DCHECK_EQ(backing_bitmap_->height(), height()); 429 DCHECK_EQ(backing_bitmap_->height(), height());
423 DCHECK_EQ(backing_bitmap_->format(), format()); 430 DCHECK_EQ(backing_bitmap_->format(), format());
424 DCHECK_GT(backing_bitmap_->num_mipmaps(), level); 431 DCHECK_GT(backing_bitmap_->num_mipmaps(), static_cast<unsigned int>(level));
425 if (LockedMode(level) != kReadOnly) { 432 if (LockedMode(level) != kReadOnly) {
426 UpdateResourceFromBitmap(renderer_, resource_id_, level, 433 UpdateResourceFromBitmap(renderer_, resource_id_, level,
427 TextureCUBE::FACE_POSITIVE_X, 434 TextureCUBE::FACE_POSITIVE_X,
428 *backing_bitmap_.Get()); 435 *backing_bitmap_.Get());
429 } 436 }
430 locked_levels_ &= ~(1 << level); 437 locked_levels_ &= ~(1 << level);
431 if (locked_levels_ == 0) { 438 if (locked_levels_ == 0) {
432 backing_bitmap_->FreeData(); 439 backing_bitmap_->FreeData();
433 has_levels_ = 0; 440 has_levels_ = 0;
434 } 441 }
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 } else { 634 } else {
628 unsigned blocks_across = (mip_width + 3) / 4; 635 unsigned blocks_across = (mip_width + 3) / 4;
629 unsigned bytes_per_block = format() == Texture::DXT1 ? 8 : 16; 636 unsigned bytes_per_block = format() == Texture::DXT1 ? 8 : 16;
630 unsigned bytes_per_row = bytes_per_block * blocks_across; 637 unsigned bytes_per_row = bytes_per_block * blocks_across;
631 *pitch = bytes_per_row; 638 *pitch = bytes_per_row;
632 } 639 }
633 if (mode != kWriteOnly && !HasLevel(face, level)) { 640 if (mode != kWriteOnly && !HasLevel(face, level)) {
634 DCHECK_EQ(backing_bitmap->width(), edge_length()); 641 DCHECK_EQ(backing_bitmap->width(), edge_length());
635 DCHECK_EQ(backing_bitmap->height(), edge_length()); 642 DCHECK_EQ(backing_bitmap->height(), edge_length());
636 DCHECK_EQ(backing_bitmap->format(), format()); 643 DCHECK_EQ(backing_bitmap->format(), format());
637 DCHECK_GT(backing_bitmap->num_mipmaps(), level); 644 DCHECK_GT(backing_bitmap->num_mipmaps(), static_cast<unsigned int>(level));
638 CopyBackResourceToBitmap(renderer_, resource_id_, level, 645 CopyBackResourceToBitmap(renderer_, resource_id_, level,
639 TextureCUBE::FACE_POSITIVE_X, *backing_bitmap); 646 TextureCUBE::FACE_POSITIVE_X, *backing_bitmap);
640 has_levels_[face] |= 1 << level; 647 has_levels_[face] |= 1 << level;
641 } 648 }
642 locked_levels_[face] |= 1 << level; 649 locked_levels_[face] |= 1 << level;
643 return false; 650 return false;
644 } 651 }
645 652
646 // Unlocks the given face and mipmap level of this texture. 653 // Unlocks the given face and mipmap level of this texture.
647 bool TextureCUBECB::PlatformSpecificUnlock(CubeFace face, int level) { 654 bool TextureCUBECB::PlatformSpecificUnlock(CubeFace face, int level) {
648 DCHECK_GE(level, 0); 655 DCHECK_GE(level, 0);
649 DCHECK_LT(level, levels()); 656 DCHECK_LT(level, levels());
650 Bitmap* backing_bitmap = backing_bitmaps_[face].Get(); 657 Bitmap* backing_bitmap = backing_bitmaps_[face].Get();
651 DCHECK(backing_bitmap->image_data()); 658 DCHECK(backing_bitmap->image_data());
652 DCHECK_EQ(backing_bitmap->width(), edge_length()); 659 DCHECK_EQ(backing_bitmap->width(), edge_length());
653 DCHECK_EQ(backing_bitmap->height(), edge_length()); 660 DCHECK_EQ(backing_bitmap->height(), edge_length());
654 DCHECK_EQ(backing_bitmap->format(), format()); 661 DCHECK_EQ(backing_bitmap->format(), format());
655 DCHECK_GT(backing_bitmap->num_mipmaps(), level); 662 DCHECK_GT(backing_bitmap->num_mipmaps(), static_cast<unsigned int>(level));
656 663
657 if (LockedMode(face, level) != kReadOnly) { 664 if (LockedMode(face, level) != kReadOnly) {
658 UpdateResourceFromBitmap(renderer_, resource_id_, level, face, 665 UpdateResourceFromBitmap(renderer_, resource_id_, level, face,
659 *backing_bitmap); 666 *backing_bitmap);
660 } 667 }
661 locked_levels_[face] &= ~(1 << level); 668 locked_levels_[face] &= ~(1 << level);
662 if (locked_levels_[face] == 0) { 669 if (locked_levels_[face] == 0) {
663 backing_bitmap->FreeData(); 670 backing_bitmap->FreeData();
664 has_levels_[face] = 0; 671 has_levels_[face] = 0;
665 } 672 }
(...skipping 25 matching lines...) Expand all
691 face, 698 face,
692 this, 699 this,
693 renderer_)); 700 renderer_));
694 } 701 }
695 702
696 const Texture::RGBASwizzleIndices& TextureCUBECB::GetABGR32FSwizzleIndices() { 703 const Texture::RGBASwizzleIndices& TextureCUBECB::GetABGR32FSwizzleIndices() {
697 return g_cb_abgr32f_swizzle_indices; 704 return g_cb_abgr32f_swizzle_indices;
698 } 705 }
699 706
700 } // namespace o3d 707 } // namespace o3d
OLDNEW
« no previous file with comments | « core/cross/command_buffer/texture_cb.h ('k') | core/win/d3d9/utils_d3d9.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698