blob: 2aedad57ef249797bafd3569029d6f2e271862f5 [file] [log] [blame]
bsalomon045802d2015-10-20 07:58:01 -07001/*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#include "GrTextureParamsAdjuster.h"
9
10#include "GrCaps.h"
11#include "GrContext.h"
12#include "GrDrawContext.h"
13#include "GrGpu.h"
bsalomon89fe56b2015-10-29 10:49:28 -070014#include "GrGpuResourcePriv.h"
15#include "GrResourceKey.h"
bsalomon045802d2015-10-20 07:58:01 -070016#include "GrTexture.h"
17#include "GrTextureParams.h"
18#include "GrTextureProvider.h"
19#include "SkCanvas.h"
20#include "SkGr.h"
21#include "SkGrPriv.h"
bsalomonc55271f2015-11-09 11:55:57 -080022#include "effects/GrBicubicEffect.h"
bsalomon89fe56b2015-10-29 10:49:28 -070023#include "effects/GrTextureDomain.h"
bsalomon045802d2015-10-20 07:58:01 -070024
bsalomon89fe56b2015-10-29 10:49:28 -070025typedef GrTextureProducer::CopyParams CopyParams;
bsalomon045802d2015-10-20 07:58:01 -070026
bsalomon89fe56b2015-10-29 10:49:28 -070027//////////////////////////////////////////////////////////////////////////////
28
29static GrTexture* copy_on_gpu(GrTexture* inputTexture, const SkIRect* subset,
30 const CopyParams& copyParams) {
31 SkASSERT(!subset || !subset->isEmpty());
bsalomon045802d2015-10-20 07:58:01 -070032 GrContext* context = inputTexture->getContext();
33 SkASSERT(context);
34 const GrCaps* caps = context->caps();
35
36 // Either it's a cache miss or the original wasn't cached to begin with.
37 GrSurfaceDesc rtDesc = inputTexture->desc();
bsalomon89fe56b2015-10-29 10:49:28 -070038 rtDesc.fFlags = rtDesc.fFlags | kRenderTarget_GrSurfaceFlag;
39 rtDesc.fWidth = copyParams.fWidth;
bsalomon045802d2015-10-20 07:58:01 -070040 rtDesc.fHeight = copyParams.fHeight;
41 rtDesc.fConfig = GrMakePixelConfigUncompressed(rtDesc.fConfig);
42
43 // If the config isn't renderable try converting to either A8 or an 32 bit config. Otherwise,
44 // fail.
45 if (!caps->isConfigRenderable(rtDesc.fConfig, false)) {
46 if (GrPixelConfigIsAlphaOnly(rtDesc.fConfig)) {
47 if (caps->isConfigRenderable(kAlpha_8_GrPixelConfig, false)) {
48 rtDesc.fConfig = kAlpha_8_GrPixelConfig;
49 } else if (caps->isConfigRenderable(kSkia8888_GrPixelConfig, false)) {
50 rtDesc.fConfig = kSkia8888_GrPixelConfig;
51 } else {
52 return nullptr;
53 }
54 } else if (kRGB_GrColorComponentFlags ==
55 (kRGB_GrColorComponentFlags & GrPixelConfigComponentMask(rtDesc.fConfig))) {
56 if (caps->isConfigRenderable(kSkia8888_GrPixelConfig, false)) {
57 rtDesc.fConfig = kSkia8888_GrPixelConfig;
58 } else {
59 return nullptr;
60 }
61 } else {
62 return nullptr;
63 }
64 }
65
66 SkAutoTUnref<GrTexture> copy(context->textureProvider()->createTexture(rtDesc, true));
67 if (!copy) {
68 return nullptr;
69 }
70
bsalomon89fe56b2015-10-29 10:49:28 -070071 // TODO: If no scaling is being performed then use copySurface.
72
bsalomon045802d2015-10-20 07:58:01 -070073 GrPaint paint;
74
egdaniel0a0605d2015-11-23 15:29:36 -080075 // TODO: Initializing these values for no reason cause the compiler is complaining
76 SkScalar sx = 0.f;
77 SkScalar sy = 0.f;
bsalomon89fe56b2015-10-29 10:49:28 -070078 if (subset) {
79 sx = 1.f / inputTexture->width();
80 sy = 1.f / inputTexture->height();
81 }
bsalomon045802d2015-10-20 07:58:01 -070082
bsalomon89fe56b2015-10-29 10:49:28 -070083 if (copyParams.fFilter != GrTextureParams::kNone_FilterMode && subset &&
84 (subset->width() != copyParams.fWidth || subset->height() != copyParams.fHeight)) {
85 SkRect domain;
86 domain.fLeft = (subset->fLeft + 0.5f) * sx;
87 domain.fTop = (subset->fTop + 0.5f)* sy;
88 domain.fRight = (subset->fRight - 0.5f) * sx;
89 domain.fBottom = (subset->fBottom - 0.5f) * sy;
90 // This would cause us to read values from outside the subset. Surely, the caller knows
91 // better!
92 SkASSERT(copyParams.fFilter != GrTextureParams::kMipMap_FilterMode);
93 paint.addColorFragmentProcessor(
94 GrTextureDomainEffect::Create(inputTexture, SkMatrix::I(), domain,
95 GrTextureDomain::kClamp_Mode,
96 copyParams.fFilter))->unref();
97 } else {
98 GrTextureParams params(SkShader::kClamp_TileMode, copyParams.fFilter);
99 paint.addColorTextureProcessor(inputTexture, SkMatrix::I(), params);
100 }
egdaniel813351f2015-11-23 15:12:23 -0800101 paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
bsalomon89fe56b2015-10-29 10:49:28 -0700102
103 SkRect localRect;
104 if (subset) {
105 localRect = SkRect::Make(*subset);
106 localRect.fLeft *= sx;
107 localRect.fTop *= sy;
108 localRect.fRight *= sx;
109 localRect.fBottom *= sy;
110 } else {
111 localRect = SkRect::MakeWH(1.f, 1.f);
112 }
bsalomon045802d2015-10-20 07:58:01 -0700113
114 SkAutoTUnref<GrDrawContext> drawContext(context->drawContext(copy->asRenderTarget()));
115 if (!drawContext) {
116 return nullptr;
117 }
118
bsalomon89fe56b2015-10-29 10:49:28 -0700119 SkRect dstRect = SkRect::MakeWH(SkIntToScalar(rtDesc.fWidth), SkIntToScalar(rtDesc.fHeight));
bsalomona2e69fc2015-11-05 10:41:43 -0800120 drawContext->fillRectToRect(GrClip::WideOpen(), paint, SkMatrix::I(), dstRect, localRect);
bsalomon045802d2015-10-20 07:58:01 -0700121 return copy.detach();
122}
123
bsalomonc75be342015-10-29 12:34:31 -0700124GrTextureAdjuster::GrTextureAdjuster(GrTexture* original, const SkIRect& contentArea)
bsalomon3aa5fce2015-11-12 09:59:44 -0800125 : INHERITED(contentArea.width(), contentArea.height())
126 , fOriginal(original) {
127 SkASSERT(SkIRect::MakeWH(original->width(), original->height()).contains(contentArea));
bsalomonc75be342015-10-29 12:34:31 -0700128 if (contentArea.fLeft > 0 || contentArea.fTop > 0 ||
129 contentArea.fRight < original->width() || contentArea.fBottom < original->height()) {
130 fContentArea.set(contentArea);
bsalomon89fe56b2015-10-29 10:49:28 -0700131 }
132}
133
134GrTexture* GrTextureAdjuster::refTextureSafeForParams(const GrTextureParams& params,
135 SkIPoint* outOffset) {
136 GrTexture* texture = this->originalTexture();
137 GrContext* context = texture->getContext();
138 CopyParams copyParams;
bsalomonc55271f2015-11-09 11:55:57 -0800139 const SkIRect* contentArea = this->contentAreaOrNull();
bsalomon89fe56b2015-10-29 10:49:28 -0700140
bsalomonc75be342015-10-29 12:34:31 -0700141 if (contentArea && GrTextureParams::kMipMap_FilterMode == params.filterMode()) {
142 // If we generate a MIP chain for texture it will read pixel values from outside the content
143 // area.
144 copyParams.fWidth = contentArea->width();
145 copyParams.fHeight = contentArea->height();
146 copyParams.fFilter = GrTextureParams::kBilerp_FilterMode;
147 } else if (!context->getGpu()->makeCopyForTextureParams(texture->width(), texture->height(),
148 params, &copyParams)) {
bsalomon89fe56b2015-10-29 10:49:28 -0700149 if (outOffset) {
bsalomonc75be342015-10-29 12:34:31 -0700150 if (contentArea) {
151 outOffset->set(contentArea->fLeft, contentArea->fRight);
bsalomon89fe56b2015-10-29 10:49:28 -0700152 } else {
153 outOffset->set(0, 0);
154 }
155 }
156 return SkRef(texture);
157 }
158 GrUniqueKey key;
159 this->makeCopyKey(copyParams, &key);
160 if (key.isValid()) {
161 GrTexture* result = context->textureProvider()->findAndRefTextureByUniqueKey(key);
162 if (result) {
163 return result;
164 }
165 }
bsalomonc75be342015-10-29 12:34:31 -0700166 GrTexture* result = copy_on_gpu(texture, contentArea, copyParams);
bsalomon89fe56b2015-10-29 10:49:28 -0700167 if (result) {
168 if (key.isValid()) {
169 result->resourcePriv().setUniqueKey(key);
170 this->didCacheCopy(key);
171 }
172 if (outOffset) {
173 outOffset->set(0, 0);
174 }
175 }
176 return result;
177}
178
bsalomonc55271f2015-11-09 11:55:57 -0800179enum DomainMode {
180 kNoDomain_DomainMode,
181 kDomain_DomainMode,
182 kTightCopy_DomainMode
183};
184
185/** Determines whether a texture domain is necessary and if so what domain to use. There are two
186 * rectangles to consider:
187 * - The first is the content area specified by the texture adjuster. We can *never* allow
188 * filtering to cause bleed of pixels outside this rectangle.
189 * - The second rectangle is the constraint rectangle, which is known to be contained by the
190 * content area. The filterConstraint specifies whether we are allowed to bleed across this
191 * rect.
192 *
193 * We want to avoid using a domain if possible. We consider the above rectangles, the filter type,
194 * and whether the coords generated by the draw would all fall within the constraint rect. If the
195 * latter is true we only need to consider whether the filter would extend beyond the rects.
196 */
197static DomainMode determine_domain_mode(
198 const SkRect& constraintRect,
199 GrTextureAdjuster::FilterConstraint filterConstraint,
200 bool coordsLimitedToConstraintRect,
201 int texW, int texH,
202 const SkIRect* textureContentArea,
203 const GrTextureParams::FilterMode* filterModeOrNullForBicubic,
204 SkRect* domainRect) {
205
206 SkASSERT(SkRect::MakeIWH(texW, texH).contains(constraintRect));
207 // We only expect a content area rect if there is some non-content area.
208 SkASSERT(!textureContentArea ||
209 (!textureContentArea->contains(SkIRect::MakeWH(texW, texH)) &&
210 SkRect::Make(*textureContentArea).contains(constraintRect)));
211
212 SkRect textureBounds = SkRect::MakeIWH(texW, texH);
213 // If the src rectangle contains the whole texture then no need for a domain.
214 if (constraintRect.contains(textureBounds)) {
215 return kNoDomain_DomainMode;
216 }
217
bsalomonb1b01992015-11-18 10:56:08 -0800218 bool restrictFilterToRect = (filterConstraint == GrTextureProducer::kYes_FilterConstraint);
bsalomonc55271f2015-11-09 11:55:57 -0800219
220 // If we can filter outside the constraint rect, and there is no non-content area of the
221 // texture, and we aren't going to generate sample coords outside the constraint rect then we
222 // don't need a domain.
223 if (!restrictFilterToRect && !textureContentArea && coordsLimitedToConstraintRect) {
224 return kNoDomain_DomainMode;
225 }
226
227 // Get the domain inset based on sampling mode (or bail if mipped)
228 SkScalar filterHalfWidth = 0.f;
229 if (filterModeOrNullForBicubic) {
230 switch (*filterModeOrNullForBicubic) {
231 case GrTextureParams::kNone_FilterMode:
232 if (coordsLimitedToConstraintRect) {
233 return kNoDomain_DomainMode;
234 } else {
235 filterHalfWidth = 0.f;
236 }
237 break;
238 case GrTextureParams::kBilerp_FilterMode:
239 filterHalfWidth = .5f;
240 break;
241 case GrTextureParams::kMipMap_FilterMode:
bsalomonb1b01992015-11-18 10:56:08 -0800242 if (restrictFilterToRect || textureContentArea) {
243 // No domain can save us here.
244 return kTightCopy_DomainMode;
245 }
246 return kNoDomain_DomainMode;
bsalomonc55271f2015-11-09 11:55:57 -0800247 }
248 } else {
249 // bicubic does nearest filtering internally.
250 filterHalfWidth = 1.5f;
251 }
252
253 // Both bilerp and bicubic use bilinear filtering and so need to be clamped to the center
254 // of the edge texel. Pinning to the texel center has no impact on nearest mode and MIP-maps
255
256 static const SkScalar kDomainInset = 0.5f;
257 // Figure out the limits of pixels we're allowed to sample from.
258 // Unless we know the amount of outset and the texture matrix we have to conservatively enforce
259 // the domain.
260 if (restrictFilterToRect) {
261 domainRect->fLeft = constraintRect.fLeft + kDomainInset;
262 domainRect->fTop = constraintRect.fTop + kDomainInset;
263 domainRect->fRight = constraintRect.fRight - kDomainInset;
264 domainRect->fBottom = constraintRect.fBottom - kDomainInset;
265 } else if (textureContentArea) {
266 // If we got here then: there is a textureContentArea, the coords are limited to the
267 // constraint rect, and we're allowed to filter across the constraint rect boundary. So
268 // we check whether the filter would reach across the edge of the content area.
269 // We will only set the sides that are required.
270
271 domainRect->setLargest();
272 if (coordsLimitedToConstraintRect) {
273 // We may be able to use the fact that the texture coords are limited to the constraint
274 // rect in order to avoid having to add a domain.
275 bool needContentAreaConstraint = false;
276 if (textureContentArea->fLeft > 0 &&
277 textureContentArea->fLeft + filterHalfWidth > constraintRect.fLeft) {
278 domainRect->fLeft = textureContentArea->fLeft + kDomainInset;
279 needContentAreaConstraint = true;
280 }
281 if (textureContentArea->fTop > 0 &&
282 textureContentArea->fTop + filterHalfWidth > constraintRect.fTop) {
283 domainRect->fTop = textureContentArea->fTop + kDomainInset;
284 needContentAreaConstraint = true;
285 }
286 if (textureContentArea->fRight < texW &&
287 textureContentArea->fRight - filterHalfWidth < constraintRect.fRight) {
288 domainRect->fRight = textureContentArea->fRight - kDomainInset;
289 needContentAreaConstraint = true;
290 }
291 if (textureContentArea->fBottom < texH &&
292 textureContentArea->fBottom - filterHalfWidth < constraintRect.fBottom) {
293 domainRect->fBottom = textureContentArea->fBottom - kDomainInset;
294 needContentAreaConstraint = true;
295 }
296 if (!needContentAreaConstraint) {
297 return kNoDomain_DomainMode;
298 }
299 } else {
300 // Our sample coords for the texture are allowed to be outside the constraintRect so we
301 // don't consider it when computing the domain.
302 if (textureContentArea->fLeft != 0) {
303 domainRect->fLeft = textureContentArea->fLeft + kDomainInset;
304 }
305 if (textureContentArea->fTop != 0) {
306 domainRect->fTop = textureContentArea->fTop + kDomainInset;
307 }
308 if (textureContentArea->fRight != texW) {
309 domainRect->fRight = textureContentArea->fRight - kDomainInset;
310 }
311 if (textureContentArea->fBottom != texH) {
312 domainRect->fBottom = textureContentArea->fBottom - kDomainInset;
313 }
314 }
315 } else {
316 return kNoDomain_DomainMode;
317 }
318
319 if (domainRect->fLeft > domainRect->fRight) {
320 domainRect->fLeft = domainRect->fRight = SkScalarAve(domainRect->fLeft, domainRect->fRight);
321 }
322 if (domainRect->fTop > domainRect->fBottom) {
323 domainRect->fTop = domainRect->fBottom = SkScalarAve(domainRect->fTop, domainRect->fBottom);
324 }
325 domainRect->fLeft /= texW;
326 domainRect->fTop /= texH;
327 domainRect->fRight /= texW;
328 domainRect->fBottom /= texH;
329 return kDomain_DomainMode;
330}
331
bsalomonb1b01992015-11-18 10:56:08 -0800332static const GrFragmentProcessor* create_fp_for_domain_and_filter(
333 GrTexture* texture,
334 const SkMatrix& textureMatrix,
335 DomainMode domainMode,
336 const SkRect& domain,
337 const GrTextureParams::FilterMode* filterOrNullForBicubic) {
338 SkASSERT(kTightCopy_DomainMode != domainMode);
339 if (filterOrNullForBicubic) {
340 if (kDomain_DomainMode == domainMode) {
341 return GrTextureDomainEffect::Create(texture, textureMatrix, domain,
342 GrTextureDomain::kClamp_Mode,
343 *filterOrNullForBicubic);
344 } else {
345 GrTextureParams params(SkShader::kClamp_TileMode, *filterOrNullForBicubic);
346 return GrSimpleTextureEffect::Create(texture, textureMatrix, params);
347 }
348 } else {
349 if (kDomain_DomainMode == domainMode) {
350 return GrBicubicEffect::Create(texture, textureMatrix, domain);
351 } else {
352 static const SkShader::TileMode kClampClamp[] =
353 { SkShader::kClamp_TileMode, SkShader::kClamp_TileMode };
354 return GrBicubicEffect::Create(texture, textureMatrix, kClampClamp);
355 }
356 }
357}
358
bsalomonc55271f2015-11-09 11:55:57 -0800359const GrFragmentProcessor* GrTextureAdjuster::createFragmentProcessor(
bsalomon3aa5fce2015-11-12 09:59:44 -0800360 const SkMatrix& origTextureMatrix,
361 const SkRect& origConstraintRect,
bsalomonc55271f2015-11-09 11:55:57 -0800362 FilterConstraint filterConstraint,
363 bool coordsLimitedToConstraintRect,
364 const GrTextureParams::FilterMode* filterOrNullForBicubic) {
365
bsalomon3aa5fce2015-11-12 09:59:44 -0800366 SkMatrix textureMatrix = origTextureMatrix;
bsalomonc55271f2015-11-09 11:55:57 -0800367 const SkIRect* contentArea = this->contentAreaOrNull();
bsalomon3aa5fce2015-11-12 09:59:44 -0800368 // Convert the constraintRect to be relative to the texture rather than the content area so
369 // that both rects are in the same coordinate system.
370 SkTCopyOnFirstWrite<SkRect> constraintRect(origConstraintRect);
371 if (contentArea) {
372 SkScalar l = SkIntToScalar(contentArea->fLeft);
373 SkScalar t = SkIntToScalar(contentArea->fTop);
374 constraintRect.writable()->offset(l, t);
375 textureMatrix.postTranslate(l, t);
376 }
bsalomonc55271f2015-11-09 11:55:57 -0800377
378 SkRect domain;
379 GrTexture* texture = this->originalTexture();
380 DomainMode domainMode =
bsalomon3aa5fce2015-11-12 09:59:44 -0800381 determine_domain_mode(*constraintRect, filterConstraint, coordsLimitedToConstraintRect,
bsalomonc55271f2015-11-09 11:55:57 -0800382 texture->width(), texture->height(),
383 contentArea, filterOrNullForBicubic,
384 &domain);
385 if (kTightCopy_DomainMode == domainMode) {
386 // TODO: Copy the texture and adjust the texture matrix (both parts need to consider
387 // non-int constraint rect)
388 // For now: treat as bilerp and ignore what goes on above level 0.
389
390 // We only expect MIP maps to require a tight copy.
391 SkASSERT(filterOrNullForBicubic &&
392 GrTextureParams::kMipMap_FilterMode == *filterOrNullForBicubic);
393 static const GrTextureParams::FilterMode kBilerp = GrTextureParams::kBilerp_FilterMode;
394 domainMode =
bsalomon3aa5fce2015-11-12 09:59:44 -0800395 determine_domain_mode(*constraintRect, filterConstraint, coordsLimitedToConstraintRect,
bsalomonc55271f2015-11-09 11:55:57 -0800396 texture->width(), texture->height(),
397 contentArea, &kBilerp, &domain);
398 SkASSERT(kTightCopy_DomainMode != domainMode);
bsalomonc55271f2015-11-09 11:55:57 -0800399 }
400 SkASSERT(kNoDomain_DomainMode == domainMode ||
401 (domain.fLeft <= domain.fRight && domain.fTop <= domain.fBottom));
bsalomon3aa5fce2015-11-12 09:59:44 -0800402 textureMatrix.postIDiv(texture->width(), texture->height());
bsalomonb1b01992015-11-18 10:56:08 -0800403 return create_fp_for_domain_and_filter(texture, textureMatrix, domainMode, domain,
404 filterOrNullForBicubic);
bsalomonc55271f2015-11-09 11:55:57 -0800405}
406
bsalomon89fe56b2015-10-29 10:49:28 -0700407//////////////////////////////////////////////////////////////////////////////
408
bsalomonb1b01992015-11-18 10:56:08 -0800409GrTexture* GrTextureMaker::refTextureForParams(const GrTextureParams& params) {
bsalomon045802d2015-10-20 07:58:01 -0700410 CopyParams copyParams;
bsalomonb1b01992015-11-18 10:56:08 -0800411 if (!fContext->getGpu()->makeCopyForTextureParams(this->width(), this->height(), params,
412 &copyParams)) {
413 return this->refOriginalTexture();
bsalomon045802d2015-10-20 07:58:01 -0700414 }
415 GrUniqueKey copyKey;
416 this->makeCopyKey(copyParams, &copyKey);
417 if (copyKey.isValid()) {
bsalomonb1b01992015-11-18 10:56:08 -0800418 GrTexture* result = fContext->textureProvider()->findAndRefTextureByUniqueKey(copyKey);
bsalomon045802d2015-10-20 07:58:01 -0700419 if (result) {
420 return result;
421 }
422 }
423
bsalomonb1b01992015-11-18 10:56:08 -0800424 GrTexture* result = this->generateTextureForParams(copyParams);
bsalomon045802d2015-10-20 07:58:01 -0700425 if (!result) {
426 return nullptr;
427 }
428
429 if (copyKey.isValid()) {
bsalomonb1b01992015-11-18 10:56:08 -0800430 fContext->textureProvider()->assignUniqueKeyToTexture(copyKey, result);
bsalomon045802d2015-10-20 07:58:01 -0700431 this->didCacheCopy(copyKey);
432 }
433 return result;
434}
435
bsalomonb1b01992015-11-18 10:56:08 -0800436const GrFragmentProcessor* GrTextureMaker::createFragmentProcessor(
437 const SkMatrix& textureMatrix,
438 const SkRect& constraintRect,
439 FilterConstraint filterConstraint,
440 bool coordsLimitedToConstraintRect,
441 const GrTextureParams::FilterMode* filterOrNullForBicubic) {
442
443 const GrTextureParams::FilterMode* fmForDetermineDomain = filterOrNullForBicubic;
444 if (filterOrNullForBicubic && GrTextureParams::kMipMap_FilterMode == *filterOrNullForBicubic &&
445 kYes_FilterConstraint == filterConstraint) {
446 // TODo: Here we should force a copy restricted to the constraintRect since MIP maps will
447 // read outside the constraint rect. However, as in the adjuster case, we aren't currently
448 // doing that.
449 // We instead we compute the domain as though were bilerping which is only correct if we
450 // only sample level 0.
451 static const GrTextureParams::FilterMode kBilerp = GrTextureParams::kBilerp_FilterMode;
452 fmForDetermineDomain = &kBilerp;
453 }
454
455 GrTextureParams params;
456 if (filterOrNullForBicubic) {
457 params.reset(SkShader::kClamp_TileMode, *filterOrNullForBicubic);
458 } else {
459 // Bicubic doesn't use filtering for it's texture accesses.
460 params.reset(SkShader::kClamp_TileMode, GrTextureParams::kNone_FilterMode);
461 }
462 SkAutoTUnref<GrTexture> texture(this->refTextureForParams(params));
463 if (!texture) {
464 return nullptr;
465 }
466 SkRect domain;
467 DomainMode domainMode =
468 determine_domain_mode(constraintRect, filterConstraint, coordsLimitedToConstraintRect,
469 texture->width(), texture->height(), nullptr, fmForDetermineDomain,
470 &domain);
471 SkASSERT(kTightCopy_DomainMode != domainMode);
472 SkMatrix normalizedTextureMatrix = textureMatrix;
473 normalizedTextureMatrix.postIDiv(texture->width(), texture->height());
474 return create_fp_for_domain_and_filter(texture, normalizedTextureMatrix, domainMode, domain,
475 filterOrNullForBicubic);
476}
477
478GrTexture* GrTextureMaker::generateTextureForParams(const CopyParams& copyParams) {
479 SkAutoTUnref<GrTexture> original(this->refOriginalTexture());
bsalomon100b8f82015-10-28 08:37:44 -0700480 if (!original) {
481 return nullptr;
bsalomon045802d2015-10-20 07:58:01 -0700482 }
bsalomon89fe56b2015-10-29 10:49:28 -0700483 return copy_on_gpu(original, nullptr, copyParams);
bsalomon045802d2015-10-20 07:58:01 -0700484}