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

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: Created 5 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
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 const GrTextureParams* params) {
654 GrTexture* result = bitmap.getTexture();
655 // TODO: What if the bitmap already contains a non-mitmapped texture?
scroggo 2015/07/21 14:44:23 non-mipmapped?
cblume 2015/07/21 23:07:30 I mean what if someone calls creates a regular tex
656 if (result) {
657 // TODO: Add stretching. After reading get_stretch(), it appears small
scroggo 2015/07/21 14:44:23 nit: this should be a four space indent
cblume 2015/07/21 23:07:30 Done.
658 // textures can have issues.
659 return SkRef(result);
660 }
661
662 GrSurfaceDesc desc;
663 generate_bitmap_texture_desc(bitmap, &desc);
664
665 auto mipmap = SkMipMap::Build(bitmap, fact);
666 if (mipmap == NULL) {
667 // could not create the mipmap
668 return NULL;
669 } else {
670 return ctx->textureProvider()->createMipmappedTexture(desc, true, *mipma p);
671 // TODO: BitmapInvalidator support
672 }
673 }
674
649 /////////////////////////////////////////////////////////////////////////////// 675 ///////////////////////////////////////////////////////////////////////////////
650 676
651 // alphatype is ignore for now, but if GrPixelConfig is expanded to encompass 677 // alphatype is ignore for now, but if GrPixelConfig is expanded to encompass
652 // alpha info, that will be considered. 678 // alpha info, that will be considered.
653 GrPixelConfig SkImageInfo2GrPixelConfig(SkColorType ct, SkAlphaType, SkColorProf ileType pt) { 679 GrPixelConfig SkImageInfo2GrPixelConfig(SkColorType ct, SkAlphaType, SkColorProf ileType pt) {
654 switch (ct) { 680 switch (ct) {
655 case kUnknown_SkColorType: 681 case kUnknown_SkColorType:
656 return kUnknown_GrPixelConfig; 682 return kUnknown_GrPixelConfig;
657 case kAlpha_8_SkColorType: 683 case kAlpha_8_SkColorType:
658 return kAlpha_8_GrPixelConfig; 684 return kAlpha_8_GrPixelConfig;
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
826 } 852 }
827 return SkImageInfo::Make(w, h, ct, at); 853 return SkImageInfo::Make(w, h, ct, at);
828 } 854 }
829 855
830 856
831 void GrWrapTextureInBitmap(GrTexture* src, int w, int h, bool isOpaque, SkBitmap * dst) { 857 void GrWrapTextureInBitmap(GrTexture* src, int w, int h, bool isOpaque, SkBitmap * dst) {
832 const SkImageInfo info = GrMakeInfoFromTexture(src, w, h, isOpaque); 858 const SkImageInfo info = GrMakeInfoFromTexture(src, w, h, isOpaque);
833 dst->setInfo(info); 859 dst->setInfo(info);
834 dst->setPixelRef(SkNEW_ARGS(SkGrPixelRef, (info, src)))->unref(); 860 dst->setPixelRef(SkNEW_ARGS(SkGrPixelRef, (info, src)))->unref();
835 } 861 }
OLDNEW
« src/gpu/GrGpu.cpp ('K') | « src/gpu/GrTextureProvider.cpp ('k') | src/gpu/gl/GrGLGpu.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698