~brandontschaefer/nux/xim-tests

« back to all changes in this revision

Viewing changes to NuxGraphics/GLTextureResourceManager.cpp

  • Committer: Brandon Schaefer
  • Date: 2012-10-19 00:23:27 UTC
  • mfrom: (637.2.55 trunk)
  • Revision ID: brandon.schaefer@canonical.com-20121019002327-60e88jn3k8chi7gt
* Merged trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
294
294
    return GetGraphicsDisplay()->GetGraphicsEngine()->CacheResource(this);
295
295
  }
296
296
 
297
 
  Texture2D::Texture2D(NUX_FILE_LINE_DECL)
298
 
    : BaseTexture(NUX_FILE_LINE_PARAM)
299
 
  {
300
 
  }
301
 
 
302
 
  Texture2D::Texture2D(const Texture2D& texture, NUX_FILE_LINE_DECL)
303
 
    : BaseTexture(NUX_FILE_LINE_PARAM)
304
 
  {
305
 
    _image = texture._image;
 
297
  Texture2D::Texture2D(NUX_FILE_LINE_DECL)  // TODO: Why can we create a texture without a texture?
 
298
    : BaseTexture(NUX_FILE_LINE_PARAM)
 
299
  {
306
300
  }
307
301
 
308
302
  Texture2D::Texture2D(const NTextureData& texture_data, NUX_FILE_LINE_DECL)
309
 
    : BaseTexture(NUX_FILE_LINE_PARAM)
310
 
  {
311
 
    _image = texture_data;
312
 
  }
313
 
 
314
 
  Texture2D& Texture2D::operator = (const Texture2D& texture)
315
 
  {
316
 
    if (this == &texture)
317
 
      return *this;   // Handle self assignment
318
 
 
319
 
    _image = texture._image;
320
 
    return *this;
 
303
    : BaseTexture(NUX_FILE_LINE_PARAM), _image(texture_data)
 
304
  {
321
305
  }
322
306
 
323
307
  Texture2D::~Texture2D()
356
340
    return ret;
357
341
  }
358
342
 
359
 
  void Texture2D::GetData(void* Buffer, int MipIndex, int StrideY, int face)
 
343
  void Texture2D::GetData(void* Buffer, int MipIndex, int StrideY, int /* face */)
360
344
  {
361
345
    BYTE              *Dest        = (BYTE*) Buffer;
362
346
    const BYTE        *Src         = _image.GetSurface(MipIndex).GetPtrRawData();
371
355
    }
372
356
  }
373
357
 
374
 
  BaseTexture* Texture2D::Clone() const
 
358
  Texture2D* Texture2D::Clone() const
375
359
  {
376
 
    Texture2D* texture = new Texture2D(*this);
377
 
    return texture;
 
360
    return new Texture2D(_image);
378
361
  }
379
362
 
380
363
  CachedBaseTexture::CachedBaseTexture(NResourceSet* ResourceManager)
491
474
  {
492
475
  }
493
476
 
494
 
  TextureRectangle::TextureRectangle(const TextureRectangle& texture)
495
 
  {
496
 
    _image = texture._image;
497
 
  }
498
 
 
499
 
  TextureRectangle::TextureRectangle(const NTextureData& BaseTexture)
500
 
  {
501
 
    _image = BaseTexture;
502
 
  }
503
 
 
504
 
  TextureRectangle& TextureRectangle::operator = (const TextureRectangle& texture)
505
 
  {
506
 
    if (this == &texture)
507
 
      return *this;   // Handle self assignment
508
 
 
509
 
    _image = texture._image;
510
 
    return *this;
 
477
  TextureRectangle::TextureRectangle(const NTextureData& texture, NUX_FILE_LINE_DECL)
 
478
    : BaseTexture(NUX_FILE_LINE_PARAM), _image(texture)
 
479
  {
511
480
  }
512
481
 
513
482
  TextureRectangle::~TextureRectangle()
536
505
    return true;
537
506
  }
538
507
 
539
 
  bool TextureRectangle::Update(const char* filename, bool UpdateAndCacheResource)
 
508
  bool TextureRectangle::Update(const char* filename, bool /* UpdateAndCacheResource */)
540
509
  {
541
510
    bool b = false;
542
511
    NBitmapData* BitmapData = LoadImageFile(filename);
547
516
    return b;
548
517
  }
549
518
 
550
 
  void TextureRectangle::GetData(void* Buffer, int MipIndex, int StrideY, int face)
 
519
  void TextureRectangle::GetData(void* Buffer, int MipIndex, int StrideY, int /* face */)
551
520
  {
552
521
    BYTE              *Dest        = (BYTE *) Buffer;
553
522
    const BYTE         *Src         = _image.GetSurface(MipIndex).GetPtrRawData();
562
531
    }
563
532
  }
564
533
 
565
 
  BaseTexture* TextureRectangle::Clone() const
 
534
  TextureRectangle* TextureRectangle::Clone() const
566
535
  {
567
 
    TextureRectangle* texture = new TextureRectangle(*this);
568
 
    return texture;
 
536
    return new TextureRectangle(_image);
569
537
  }
570
538
 
571
539
  CachedTextureRectangle::CachedTextureRectangle(NResourceSet* ResourceManager, TextureRectangle* SourceTexture)
638
606
    OGL_CALL(TextureRectangle->UnlockRect( MipLevel ));
639
607
  }
640
608
 
641
 
  TextureCube::TextureCube(NUX_FILE_LINE_DECL)
 
609
  TextureCube::TextureCube(NUX_FILE_LINE_DECL)  // TODO: why can we have a texture without a texture?
642
610
    : BaseTexture(NUX_FILE_LINE_PARAM)
643
611
  {
644
612
  }
645
613
 
646
 
  TextureCube::TextureCube(const TextureCube& texture)
647
 
  {
648
 
    _image = texture._image;
649
 
  }
650
 
 
651
 
  TextureCube& TextureCube::operator = (const TextureCube& texture)
652
 
  {
653
 
    if (this == &texture)
654
 
      return *this;   // Handle self assignment
655
 
 
656
 
    _image = texture._image;
657
 
    return *this;
 
614
  TextureCube::TextureCube(const NCubemapData& Image)
 
615
    : _image(Image)
 
616
  {
658
617
  }
659
618
 
660
619
  TextureCube::~TextureCube()
684
643
    return true;
685
644
  }
686
645
 
687
 
  bool TextureCube::Update(const char* filename, bool UpdateAndCacheResource)
 
646
  bool TextureCube::Update(const char* filename, bool /* UpdateAndCacheResource */)
688
647
  {
689
648
    NBitmapData* BitmapData = LoadImageFile(filename);
690
649
    nuxAssertMsg(BitmapData, "[TextureCube::Update] Bitmap for file(%s) is NULL.", filename);
709
668
    }
710
669
  }
711
670
 
712
 
  BaseTexture* TextureCube::Clone() const
 
671
  TextureCube* TextureCube::Clone() const
713
672
  {
714
 
    TextureCube* texture = new TextureCube(*this);
715
 
    return texture;
 
673
    return new TextureCube(_image);
716
674
  }
717
675
 
718
676
  CachedTextureCube::CachedTextureCube(NResourceSet* ResourceManager, TextureCube* SourceTexture)
786
744
    }
787
745
  }
788
746
 
789
 
  TextureVolume::TextureVolume(NUX_FILE_LINE_DECL)
 
747
  TextureVolume::TextureVolume(NUX_FILE_LINE_DECL)  // TODO: why can we have a texture without a texture?
790
748
    : BaseTexture(NUX_FILE_LINE_PARAM)
791
749
  {
792
750
  }
793
751
 
794
 
  TextureVolume::TextureVolume(const TextureVolume& texture)
795
 
  {
796
 
    _image = texture._image;
797
 
  }
798
 
 
799
 
  TextureVolume& TextureVolume::operator = (const TextureVolume& texture)
800
 
  {
801
 
    if (this == &texture)
802
 
      return *this;   // Handle self assignment
803
 
 
804
 
    _image = texture._image;
805
 
    return *this;
 
752
  TextureVolume::TextureVolume(const NVolumeData& Image)
 
753
    : _image(Image)
 
754
  {
806
755
  }
807
756
 
808
757
  TextureVolume::~TextureVolume()
832
781
    return true;
833
782
  }
834
783
 
835
 
  bool TextureVolume::Update(const char* filename, bool UpdateAndCacheResource)
 
784
  bool TextureVolume::Update(const char* filename, bool /* UpdateAndCacheResource */)
836
785
  {
837
786
    NBitmapData* BitmapData = LoadImageFile(filename);
838
787
    nuxAssertMsg(BitmapData, "[TextureVolume::Update] Bitmap for file(%s) is NULL.", filename);
842
791
    return ret;
843
792
  }
844
793
 
845
 
  void TextureVolume::GetData(void* Buffer, int MipIndex, int StrideY, int face)
 
794
  void TextureVolume::GetData(void* Buffer, int MipIndex, int StrideY, int /* face */)
846
795
  {
847
796
    BYTE               *Dest        = (BYTE *) Buffer;
848
797
//     const BYTE*         Src         = _image.GetSurface(MipIndex, slice).GetPtrRawData();
878
827
//     }
879
828
  }
880
829
 
881
 
  BaseTexture* TextureVolume::Clone() const
 
830
  TextureVolume* TextureVolume::Clone() const
882
831
  {
883
 
    TextureVolume* texture = new TextureVolume(*this);
884
 
    return texture;
 
832
    return new TextureVolume(_image);
885
833
  }
886
834
 
887
835
  CachedTextureVolume::CachedTextureVolume(NResourceSet* ResourceManager, TextureVolume* SourceTexture)
967
915
//     }
968
916
  }
969
917
 
970
 
  TextureFrameAnimation::TextureFrameAnimation(NUX_FILE_LINE_DECL)
 
918
  TextureFrameAnimation::TextureFrameAnimation(NUX_FILE_LINE_DECL) // TODO: why can we have a texture without a texture?
971
919
    : BaseTexture(NUX_FILE_LINE_PARAM)
972
920
  {
973
921
  }
974
922
 
975
 
  TextureFrameAnimation::TextureFrameAnimation(const TextureFrameAnimation& texture)
976
 
  {
977
 
    _image = texture._image;
978
 
  }
979
 
 
980
 
  TextureFrameAnimation& TextureFrameAnimation::operator = (const TextureFrameAnimation& texture)
981
 
  {
982
 
    if (this == &texture)
983
 
      return *this;   // Handle self assignment
984
 
 
985
 
    _image = texture._image;
986
 
    return *this;
 
923
  TextureFrameAnimation::TextureFrameAnimation(const NAnimatedTextureData& Image)
 
924
    : _image(Image)
 
925
  {
987
926
  }
988
927
 
989
928
  TextureFrameAnimation::~TextureFrameAnimation()
1013
952
    return true;
1014
953
  }
1015
954
 
1016
 
  bool TextureFrameAnimation::Update(const char* filename, bool UpdateAndCacheResource)
 
955
  bool TextureFrameAnimation::Update(const char* filename, bool /* UpdateAndCacheResource */)
1017
956
  {
1018
957
    NBitmapData* BitmapData = LoadImageFile(filename);
1019
958
    nuxAssertMsg(BitmapData, "[TextureFrameAnimation::Update] Bitmap for file(%s) is NULL.", filename);
1023
962
    return ret;
1024
963
  }
1025
964
 
1026
 
  void TextureFrameAnimation::GetData(void* Buffer, int MipIndex, int StrideY, int slice)
 
965
  void TextureFrameAnimation::GetData(void* Buffer, int /* MipIndex */, int StrideY, int slice)
1027
966
  {
1028
967
    BYTE               *Dest        = (BYTE *) Buffer;
1029
968
    //for(int slice = 0; slice < ImageSurface::GetLevelDim(_image.GetFormat(), _image.GetDepth(), MipIndex); slice++)
1048
987
    return _image.GetFrameTime(Frame);
1049
988
  }
1050
989
 
1051
 
  BaseTexture* TextureFrameAnimation::Clone() const
 
990
  TextureFrameAnimation* TextureFrameAnimation::Clone() const
1052
991
  {
1053
 
    TextureFrameAnimation* texture = new TextureFrameAnimation(*this);
1054
 
    return texture;
 
992
    return new TextureFrameAnimation(_image);
1055
993
  }
1056
994
 
1057
995
  CachedTextureFrameAnimation::CachedTextureFrameAnimation(NResourceSet* ResourceManager, TextureFrameAnimation* SourceTexture)
1114
1052
    }
1115
1053
  }
1116
1054
 
1117
 
  void CachedTextureFrameAnimation::LoadMipLevel(BaseTexture* SourceTexture, int MipLevel)
 
1055
  void CachedTextureFrameAnimation::LoadMipLevel(BaseTexture* SourceTexture, int /* MipLevel */)
1118
1056
  {
1119
1057
    SURFACE_LOCKED_RECT       LockedRect;
1120
1058
    ObjectPtr <IOpenGLAnimatedTexture> AnimatedTexture = m_Texture; //m_Texture.CastRef<IOpenGLAnimatedTexture>();