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

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

Issue 1249543003: Creating functions for uploading a mipmapped texture. (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Rebasing. Created 4 years, 9 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
« no previous file with comments | « src/gpu/GrImageIDTextureAdjuster.h ('k') | src/gpu/GrSurface.cpp » ('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 2015 Google Inc. 2 * Copyright 2015 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 "GrImageIDTextureAdjuster.h" 8 #include "GrImageIDTextureAdjuster.h"
9 9
10 #include "GrContext.h" 10 #include "GrContext.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 , fBitmap(bitmap) { 74 , fBitmap(bitmap) {
75 SkASSERT(!bitmap.getTexture()); 75 SkASSERT(!bitmap.getTexture());
76 if (!bitmap.isVolatile()) { 76 if (!bitmap.isVolatile()) {
77 SkIPoint origin = bitmap.pixelRefOrigin(); 77 SkIPoint origin = bitmap.pixelRefOrigin();
78 SkIRect subset = SkIRect::MakeXYWH(origin.fX, origin.fY, bitmap.width(), 78 SkIRect subset = SkIRect::MakeXYWH(origin.fX, origin.fY, bitmap.width(),
79 bitmap.height()); 79 bitmap.height());
80 GrMakeKeyFromImageID(&fOriginalKey, bitmap.pixelRef()->getGenerationID() , subset); 80 GrMakeKeyFromImageID(&fOriginalKey, bitmap.pixelRef()->getGenerationID() , subset);
81 } 81 }
82 } 82 }
83 83
84 GrTexture* GrBitmapTextureMaker::refOriginalTexture() { 84 GrTexture* GrBitmapTextureMaker::refOriginalTexture(bool willBeMipped) {
85 GrTexture* tex; 85 GrTexture* tex;
86 86
87 if (fOriginalKey.isValid()) { 87 if (fOriginalKey.isValid()) {
88 tex = this->context()->textureProvider()->findAndRefTextureByUniqueKey(f OriginalKey); 88 tex = this->context()->textureProvider()->findAndRefTextureByUniqueKey(f OriginalKey);
89 if (tex) { 89 if (tex) {
90 return tex; 90 return tex;
91 } 91 }
92 } 92 }
93 93
94 tex = GrUploadBitmapToTexture(this->context(), fBitmap); 94 if (willBeMipped) {
95 tex = GrGenerateMipMapsAndUploadToTexture(this->context(), fBitmap);
96 } else {
97 tex = GrUploadBitmapToTexture(this->context(), fBitmap);
98 }
95 if (tex && fOriginalKey.isValid()) { 99 if (tex && fOriginalKey.isValid()) {
96 tex->resourcePriv().setUniqueKey(fOriginalKey); 100 tex->resourcePriv().setUniqueKey(fOriginalKey);
97 GrInstallBitmapUniqueKeyInvalidator(fOriginalKey, fBitmap.pixelRef()); 101 GrInstallBitmapUniqueKeyInvalidator(fOriginalKey, fBitmap.pixelRef());
98 } 102 }
99 return tex; 103 return tex;
100 } 104 }
101 105
102 void GrBitmapTextureMaker::makeCopyKey(const CopyParams& copyParams, GrUniqueKey * copyKey) { 106 void GrBitmapTextureMaker::makeCopyKey(const CopyParams& copyParams, GrUniqueKey * copyKey) {
103 if (fOriginalKey.isValid()) { 107 if (fOriginalKey.isValid()) {
104 MakeCopyKeyFromOrigKey(fOriginalKey, copyParams, copyKey); 108 MakeCopyKeyFromOrigKey(fOriginalKey, copyParams, copyKey);
(...skipping 14 matching lines...) Expand all
119 cacher_is_alpha_only(*cacher)) 123 cacher_is_alpha_only(*cacher))
120 , fCacher(cacher) 124 , fCacher(cacher)
121 , fClient(client) 125 , fClient(client)
122 , fCachingHint(chint) { 126 , fCachingHint(chint) {
123 if (client) { 127 if (client) {
124 GrMakeKeyFromImageID(&fOriginalKey, client->uniqueID(), 128 GrMakeKeyFromImageID(&fOriginalKey, client->uniqueID(),
125 SkIRect::MakeWH(this->width(), this->height())); 129 SkIRect::MakeWH(this->width(), this->height()));
126 } 130 }
127 } 131 }
128 132
129 GrTexture* GrImageTextureMaker::refOriginalTexture() { 133 GrTexture* GrImageTextureMaker::refOriginalTexture(bool willBeMipped) {
130 return fCacher->lockTexture(this->context(), fOriginalKey, fClient, fCaching Hint); 134 return fCacher->lockTexture(this->context(), fOriginalKey, fClient, fCaching Hint, willBeMipped);
131 } 135 }
132 136
133 void GrImageTextureMaker::makeCopyKey(const CopyParams& stretch, GrUniqueKey* pa ramsCopyKey) { 137 void GrImageTextureMaker::makeCopyKey(const CopyParams& stretch, GrUniqueKey* pa ramsCopyKey) {
134 if (fOriginalKey.isValid() && SkImage::kAllow_CachingHint == fCachingHint) { 138 if (fOriginalKey.isValid() && SkImage::kAllow_CachingHint == fCachingHint) {
135 MakeCopyKeyFromOrigKey(fOriginalKey, stretch, paramsCopyKey); 139 MakeCopyKeyFromOrigKey(fOriginalKey, stretch, paramsCopyKey);
136 } 140 }
137 } 141 }
138 142
139 void GrImageTextureMaker::didCacheCopy(const GrUniqueKey& copyKey) { 143 void GrImageTextureMaker::didCacheCopy(const GrUniqueKey& copyKey) {
140 if (fClient) { 144 if (fClient) {
141 as_IB(fClient)->notifyAddedToCache(); 145 as_IB(fClient)->notifyAddedToCache();
142 } 146 }
143 } 147 }
OLDNEW
« no previous file with comments | « src/gpu/GrImageIDTextureAdjuster.h ('k') | src/gpu/GrSurface.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698