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

Side by Side Diff: src/gpu/SkGr.cpp

Issue 1249543003: Creating functions for uploading a mipmapped texture. (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: No longer exposing SkMipMap and SkCachedData. Created 5 years, 4 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
OLDNEW
1 /* 1 /*
2 * Copyright 2010 Google Inc. 2 * Copyright 2010 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkGr.h" 8 #include "SkGr.h"
9 9
10 #include "GrCaps.h" 10 #include "GrCaps.h"
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 if (result) { 639 if (result) {
640 return result; 640 return result;
641 } 641 }
642 642
643 SkErrorInternals::SetError( kInternalError_SkError, 643 SkErrorInternals::SetError( kInternalError_SkError,
644 "---- failed to create texture for cache [%d %d] \n", 644 "---- failed to create texture for cache [%d %d] \n",
645 bitmap.width(), bitmap.height()); 645 bitmap.width(), bitmap.height());
646 646
647 return NULL; 647 return NULL;
648 } 648 }
649
650 GrTexture* GrMipMapTexture(GrContext& ctx,
651 const SkBitmap& bitmap,
652 SkDiscardableFactoryProc fact) {
653 GrTexture* result = bitmap.getTexture();
654 // TODO: What if the bitmap already contains a non-mipmapped texture?
bsalomon 2015/08/26 18:30:11 Maybe just preserve the existing glGenMipmaps()? t
cblume 2015/08/26 18:58:00 Hrmmm the point of all this was to try to remove t
bsalomon 2015/08/27 13:22:49 The GrTexture tracks whether it's MIPs are "dirty"
655 if (result) {
656 // TODO: Add stretching. After reading get_stretch(), it appears small
657 // textures can have issues.
658 return SkRef(result);
659 }
660
661 GrSurfaceDesc desc;
662 generate_bitmap_texture_desc(bitmap, &desc);
663
664 auto mipmap = SkMipMap::Build(bitmap, fact);
665 if (mipmap == NULL) {
666 // could not create the mipmap
667 return NULL;
668 } else {
669 auto mipLevelCount = mipmap->getLevelsCount();
670 SkTArray<SkMipMapLevel> texels(mipLevelCount);
671 for (int i = 0; i < mipLevelCount; i++) {
672 SkMipMap::Level level;
673 mipmap->getLevel(i, &level);
674
675 SkMipMapLevel currentMipLevel(level.fPixels, level.fRowBytes);
676
677 texels.push_back(currentMipLevel);
678 }
679 return ctx.textureProvider()->createTexture(desc, true, texels);
680 // TODO: BitmapInvalidator support
681 }
682 }
683
649 /////////////////////////////////////////////////////////////////////////////// 684 ///////////////////////////////////////////////////////////////////////////////
650 685
651 // alphatype is ignore for now, but if GrPixelConfig is expanded to encompass 686 // alphatype is ignore for now, but if GrPixelConfig is expanded to encompass
652 // alpha info, that will be considered. 687 // alpha info, that will be considered.
653 GrPixelConfig SkImageInfo2GrPixelConfig(SkColorType ct, SkAlphaType, SkColorProf ileType pt) { 688 GrPixelConfig SkImageInfo2GrPixelConfig(SkColorType ct, SkAlphaType, SkColorProf ileType pt) {
654 switch (ct) { 689 switch (ct) {
655 case kUnknown_SkColorType: 690 case kUnknown_SkColorType:
656 return kUnknown_GrPixelConfig; 691 return kUnknown_GrPixelConfig;
657 case kAlpha_8_SkColorType: 692 case kAlpha_8_SkColorType:
658 return kAlpha_8_GrPixelConfig; 693 return kAlpha_8_GrPixelConfig;
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
826 } 861 }
827 return SkImageInfo::Make(w, h, ct, at); 862 return SkImageInfo::Make(w, h, ct, at);
828 } 863 }
829 864
830 865
831 void GrWrapTextureInBitmap(GrTexture* src, int w, int h, bool isOpaque, SkBitmap * dst) { 866 void GrWrapTextureInBitmap(GrTexture* src, int w, int h, bool isOpaque, SkBitmap * dst) {
832 const SkImageInfo info = GrMakeInfoFromTexture(src, w, h, isOpaque); 867 const SkImageInfo info = GrMakeInfoFromTexture(src, w, h, isOpaque);
833 dst->setInfo(info); 868 dst->setInfo(info);
834 dst->setPixelRef(SkNEW_ARGS(SkGrPixelRef, (info, src)))->unref(); 869 dst->setPixelRef(SkNEW_ARGS(SkGrPixelRef, (info, src)))->unref();
835 } 870 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698