OLD | NEW |
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 "GrTextureParamsAdjuster.h" | 8 #include "GrTextureParamsAdjuster.h" |
9 | 9 |
10 #include "GrCaps.h" | 10 #include "GrCaps.h" |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 return copy; | 157 return copy; |
158 } | 158 } |
159 | 159 |
160 GrTexture* GrTextureAdjuster::refTextureSafeForParams(const GrTextureParams& par
ams, | 160 GrTexture* GrTextureAdjuster::refTextureSafeForParams(const GrTextureParams& par
ams, |
161 SkIPoint* outOffset) { | 161 SkIPoint* outOffset) { |
162 GrTexture* texture = this->originalTexture(); | 162 GrTexture* texture = this->originalTexture(); |
163 GrContext* context = texture->getContext(); | 163 GrContext* context = texture->getContext(); |
164 CopyParams copyParams; | 164 CopyParams copyParams; |
165 const SkIRect* contentArea = this->contentAreaOrNull(); | 165 const SkIRect* contentArea = this->contentAreaOrNull(); |
166 | 166 |
| 167 if (!context) { |
| 168 // The texture was abandoned. |
| 169 return nullptr; |
| 170 } |
| 171 |
167 if (contentArea && GrTextureParams::kMipMap_FilterMode == params.filterMode(
)) { | 172 if (contentArea && GrTextureParams::kMipMap_FilterMode == params.filterMode(
)) { |
168 // If we generate a MIP chain for texture it will read pixel values from
outside the content | 173 // If we generate a MIP chain for texture it will read pixel values from
outside the content |
169 // area. | 174 // area. |
170 copyParams.fWidth = contentArea->width(); | 175 copyParams.fWidth = contentArea->width(); |
171 copyParams.fHeight = contentArea->height(); | 176 copyParams.fHeight = contentArea->height(); |
172 copyParams.fFilter = GrTextureParams::kBilerp_FilterMode; | 177 copyParams.fFilter = GrTextureParams::kBilerp_FilterMode; |
173 } else if (!context->getGpu()->makeCopyForTextureParams(texture, params, &co
pyParams)) { | 178 } else if (!context->getGpu()->makeCopyForTextureParams(texture, params, &co
pyParams)) { |
174 if (outOffset) { | 179 if (outOffset) { |
175 if (contentArea) { | 180 if (contentArea) { |
176 outOffset->set(contentArea->fLeft, contentArea->fRight); | 181 outOffset->set(contentArea->fLeft, contentArea->fRight); |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 } | 512 } |
508 | 513 |
509 GrTexture* GrTextureMaker::generateTextureForParams(const CopyParams& copyParams
, | 514 GrTexture* GrTextureMaker::generateTextureForParams(const CopyParams& copyParams
, |
510 bool willBeMipped) { | 515 bool willBeMipped) { |
511 SkAutoTUnref<GrTexture> original(this->refOriginalTexture(willBeMipped)); | 516 SkAutoTUnref<GrTexture> original(this->refOriginalTexture(willBeMipped)); |
512 if (!original) { | 517 if (!original) { |
513 return nullptr; | 518 return nullptr; |
514 } | 519 } |
515 return copy_on_gpu(original, nullptr, copyParams); | 520 return copy_on_gpu(original, nullptr, copyParams); |
516 } | 521 } |
OLD | NEW |