blob: 336ab6b10c4a8f37d9bf96763be57f7144e6c3c7 [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
bsalomonf1ecd212015-12-09 17:06:02 -0800124GrTextureAdjuster::GrTextureAdjuster(GrTexture* original,
125 const SkIRect& contentArea,
126 bool isAlphaOnly)
127 : INHERITED(contentArea.width(), contentArea.height(), isAlphaOnly)
bsalomon3aa5fce2015-11-12 09:59:44 -0800128 , fOriginal(original) {
129 SkASSERT(SkIRect::MakeWH(original->width(), original->height()).contains(contentArea));
bsalomonc75be342015-10-29 12:34:31 -0700130 if (contentArea.fLeft > 0 || contentArea.fTop > 0 ||
131 contentArea.fRight < original->width() || contentArea.fBottom < original->height()) {
132 fContentArea.set(contentArea);
bsalomon89fe56b2015-10-29 10:49:28 -0700133 }
134}
135
136GrTexture* GrTextureAdjuster::refTextureSafeForParams(const GrTextureParams& params,
137 SkIPoint* outOffset) {
138 GrTexture* texture = this->originalTexture();
139 GrContext* context = texture->getContext();
140 CopyParams copyParams;
bsalomonc55271f2015-11-09 11:55:57 -0800141 const SkIRect* contentArea = this->contentAreaOrNull();
bsalomon89fe56b2015-10-29 10:49:28 -0700142
bsalomonc75be342015-10-29 12:34:31 -0700143 if (contentArea && GrTextureParams::kMipMap_FilterMode == params.filterMode()) {
144 // If we generate a MIP chain for texture it will read pixel values from outside the content
145 // area.
146 copyParams.fWidth = contentArea->width();
147 copyParams.fHeight = contentArea->height();
148 copyParams.fFilter = GrTextureParams::kBilerp_FilterMode;
149 } else if (!context->getGpu()->makeCopyForTextureParams(texture->width(), texture->height(),
150 params, &copyParams)) {
bsalomon89fe56b2015-10-29 10:49:28 -0700151 if (outOffset) {
bsalomonc75be342015-10-29 12:34:31 -0700152 if (contentArea) {
153 outOffset->set(contentArea->fLeft, contentArea->fRight);
bsalomon89fe56b2015-10-29 10:49:28 -0700154 } else {
155 outOffset->set(0, 0);
156 }
157 }
158 return SkRef(texture);
159 }
160 GrUniqueKey key;
161 this->makeCopyKey(copyParams, &key);
162 if (key.isValid()) {
163 GrTexture* result = context->textureProvider()->findAndRefTextureByUniqueKey(key);
164 if (result) {
165 return result;
166 }
167 }
bsalomonc75be342015-10-29 12:34:31 -0700168 GrTexture* result = copy_on_gpu(texture, contentArea, copyParams);
bsalomon89fe56b2015-10-29 10:49:28 -0700169 if (result) {
170 if (key.isValid()) {
171 result->resourcePriv().setUniqueKey(key);
172 this->didCacheCopy(key);
173 }
174 if (outOffset) {
175 outOffset->set(0, 0);
176 }
177 }
178 return result;
179}
180
bsalomonc55271f2015-11-09 11:55:57 -0800181enum DomainMode {
182 kNoDomain_DomainMode,
183 kDomain_DomainMode,
184 kTightCopy_DomainMode
185};
186
187/** Determines whether a texture domain is necessary and if so what domain to use. There are two
188 * rectangles to consider:
189 * - The first is the content area specified by the texture adjuster. We can *never* allow
190 * filtering to cause bleed of pixels outside this rectangle.
191 * - The second rectangle is the constraint rectangle, which is known to be contained by the
192 * content area. The filterConstraint specifies whether we are allowed to bleed across this
193 * rect.
194 *
195 * We want to avoid using a domain if possible. We consider the above rectangles, the filter type,
196 * and whether the coords generated by the draw would all fall within the constraint rect. If the
197 * latter is true we only need to consider whether the filter would extend beyond the rects.
198 */
199static DomainMode determine_domain_mode(
200 const SkRect& constraintRect,
201 GrTextureAdjuster::FilterConstraint filterConstraint,
202 bool coordsLimitedToConstraintRect,
203 int texW, int texH,
204 const SkIRect* textureContentArea,
205 const GrTextureParams::FilterMode* filterModeOrNullForBicubic,
206 SkRect* domainRect) {
207
208 SkASSERT(SkRect::MakeIWH(texW, texH).contains(constraintRect));
209 // We only expect a content area rect if there is some non-content area.
210 SkASSERT(!textureContentArea ||
211 (!textureContentArea->contains(SkIRect::MakeWH(texW, texH)) &&
212 SkRect::Make(*textureContentArea).contains(constraintRect)));
213
214 SkRect textureBounds = SkRect::MakeIWH(texW, texH);
215 // If the src rectangle contains the whole texture then no need for a domain.
216 if (constraintRect.contains(textureBounds)) {
217 return kNoDomain_DomainMode;
218 }
219
bsalomonb1b01992015-11-18 10:56:08 -0800220 bool restrictFilterToRect = (filterConstraint == GrTextureProducer::kYes_FilterConstraint);
bsalomonc55271f2015-11-09 11:55:57 -0800221
222 // If we can filter outside the constraint rect, and there is no non-content area of the
223 // texture, and we aren't going to generate sample coords outside the constraint rect then we
224 // don't need a domain.
225 if (!restrictFilterToRect && !textureContentArea && coordsLimitedToConstraintRect) {
226 return kNoDomain_DomainMode;
227 }
228
229 // Get the domain inset based on sampling mode (or bail if mipped)
230 SkScalar filterHalfWidth = 0.f;
231 if (filterModeOrNullForBicubic) {
232 switch (*filterModeOrNullForBicubic) {
233 case GrTextureParams::kNone_FilterMode:
234 if (coordsLimitedToConstraintRect) {
235 return kNoDomain_DomainMode;
236 } else {
237 filterHalfWidth = 0.f;
238 }
239 break;
240 case GrTextureParams::kBilerp_FilterMode:
241 filterHalfWidth = .5f;
242 break;
243 case GrTextureParams::kMipMap_FilterMode:
bsalomonb1b01992015-11-18 10:56:08 -0800244 if (restrictFilterToRect || textureContentArea) {
245 // No domain can save us here.
246 return kTightCopy_DomainMode;
247 }
248 return kNoDomain_DomainMode;
bsalomonc55271f2015-11-09 11:55:57 -0800249 }
250 } else {
251 // bicubic does nearest filtering internally.
252 filterHalfWidth = 1.5f;
253 }
254
255 // Both bilerp and bicubic use bilinear filtering and so need to be clamped to the center
256 // of the edge texel. Pinning to the texel center has no impact on nearest mode and MIP-maps
257
258 static const SkScalar kDomainInset = 0.5f;
259 // Figure out the limits of pixels we're allowed to sample from.
260 // Unless we know the amount of outset and the texture matrix we have to conservatively enforce
261 // the domain.
262 if (restrictFilterToRect) {
263 domainRect->fLeft = constraintRect.fLeft + kDomainInset;
264 domainRect->fTop = constraintRect.fTop + kDomainInset;
265 domainRect->fRight = constraintRect.fRight - kDomainInset;
266 domainRect->fBottom = constraintRect.fBottom - kDomainInset;
267 } else if (textureContentArea) {
268 // If we got here then: there is a textureContentArea, the coords are limited to the
269 // constraint rect, and we're allowed to filter across the constraint rect boundary. So
270 // we check whether the filter would reach across the edge of the content area.
271 // We will only set the sides that are required.
272
273 domainRect->setLargest();
274 if (coordsLimitedToConstraintRect) {
275 // We may be able to use the fact that the texture coords are limited to the constraint
276 // rect in order to avoid having to add a domain.
277 bool needContentAreaConstraint = false;
278 if (textureContentArea->fLeft > 0 &&
279 textureContentArea->fLeft + filterHalfWidth > constraintRect.fLeft) {
280 domainRect->fLeft = textureContentArea->fLeft + kDomainInset;
281 needContentAreaConstraint = true;
282 }
283 if (textureContentArea->fTop > 0 &&
284 textureContentArea->fTop + filterHalfWidth > constraintRect.fTop) {
285 domainRect->fTop = textureContentArea->fTop + kDomainInset;
286 needContentAreaConstraint = true;
287 }
288 if (textureContentArea->fRight < texW &&
289 textureContentArea->fRight - filterHalfWidth < constraintRect.fRight) {
290 domainRect->fRight = textureContentArea->fRight - kDomainInset;
291 needContentAreaConstraint = true;
292 }
293 if (textureContentArea->fBottom < texH &&
294 textureContentArea->fBottom - filterHalfWidth < constraintRect.fBottom) {
295 domainRect->fBottom = textureContentArea->fBottom - kDomainInset;
296 needContentAreaConstraint = true;
297 }
298 if (!needContentAreaConstraint) {
299 return kNoDomain_DomainMode;
300 }
301 } else {
302 // Our sample coords for the texture are allowed to be outside the constraintRect so we
303 // don't consider it when computing the domain.
304 if (textureContentArea->fLeft != 0) {
305 domainRect->fLeft = textureContentArea->fLeft + kDomainInset;
306 }
307 if (textureContentArea->fTop != 0) {
308 domainRect->fTop = textureContentArea->fTop + kDomainInset;
309 }
310 if (textureContentArea->fRight != texW) {
311 domainRect->fRight = textureContentArea->fRight - kDomainInset;
312 }
313 if (textureContentArea->fBottom != texH) {
314 domainRect->fBottom = textureContentArea->fBottom - kDomainInset;
315 }
316 }
317 } else {
318 return kNoDomain_DomainMode;
319 }
320
321 if (domainRect->fLeft > domainRect->fRight) {
322 domainRect->fLeft = domainRect->fRight = SkScalarAve(domainRect->fLeft, domainRect->fRight);
323 }
324 if (domainRect->fTop > domainRect->fBottom) {
325 domainRect->fTop = domainRect->fBottom = SkScalarAve(domainRect->fTop, domainRect->fBottom);
326 }
327 domainRect->fLeft /= texW;
328 domainRect->fTop /= texH;
329 domainRect->fRight /= texW;
330 domainRect->fBottom /= texH;
331 return kDomain_DomainMode;
332}
333
bsalomonb1b01992015-11-18 10:56:08 -0800334static const GrFragmentProcessor* create_fp_for_domain_and_filter(
335 GrTexture* texture,
336 const SkMatrix& textureMatrix,
337 DomainMode domainMode,
338 const SkRect& domain,
339 const GrTextureParams::FilterMode* filterOrNullForBicubic) {
340 SkASSERT(kTightCopy_DomainMode != domainMode);
341 if (filterOrNullForBicubic) {
342 if (kDomain_DomainMode == domainMode) {
343 return GrTextureDomainEffect::Create(texture, textureMatrix, domain,
344 GrTextureDomain::kClamp_Mode,
345 *filterOrNullForBicubic);
346 } else {
347 GrTextureParams params(SkShader::kClamp_TileMode, *filterOrNullForBicubic);
348 return GrSimpleTextureEffect::Create(texture, textureMatrix, params);
349 }
350 } else {
351 if (kDomain_DomainMode == domainMode) {
352 return GrBicubicEffect::Create(texture, textureMatrix, domain);
353 } else {
354 static const SkShader::TileMode kClampClamp[] =
355 { SkShader::kClamp_TileMode, SkShader::kClamp_TileMode };
356 return GrBicubicEffect::Create(texture, textureMatrix, kClampClamp);
357 }
358 }
359}
360
bsalomonc55271f2015-11-09 11:55:57 -0800361const GrFragmentProcessor* GrTextureAdjuster::createFragmentProcessor(
bsalomon3aa5fce2015-11-12 09:59:44 -0800362 const SkMatrix& origTextureMatrix,
363 const SkRect& origConstraintRect,
bsalomonc55271f2015-11-09 11:55:57 -0800364 FilterConstraint filterConstraint,
365 bool coordsLimitedToConstraintRect,
366 const GrTextureParams::FilterMode* filterOrNullForBicubic) {
367
bsalomon3aa5fce2015-11-12 09:59:44 -0800368 SkMatrix textureMatrix = origTextureMatrix;
bsalomonc55271f2015-11-09 11:55:57 -0800369 const SkIRect* contentArea = this->contentAreaOrNull();
bsalomon3aa5fce2015-11-12 09:59:44 -0800370 // Convert the constraintRect to be relative to the texture rather than the content area so
371 // that both rects are in the same coordinate system.
372 SkTCopyOnFirstWrite<SkRect> constraintRect(origConstraintRect);
373 if (contentArea) {
374 SkScalar l = SkIntToScalar(contentArea->fLeft);
375 SkScalar t = SkIntToScalar(contentArea->fTop);
376 constraintRect.writable()->offset(l, t);
377 textureMatrix.postTranslate(l, t);
378 }
bsalomonc55271f2015-11-09 11:55:57 -0800379
380 SkRect domain;
381 GrTexture* texture = this->originalTexture();
382 DomainMode domainMode =
bsalomon3aa5fce2015-11-12 09:59:44 -0800383 determine_domain_mode(*constraintRect, filterConstraint, coordsLimitedToConstraintRect,
bsalomonc55271f2015-11-09 11:55:57 -0800384 texture->width(), texture->height(),
385 contentArea, filterOrNullForBicubic,
386 &domain);
387 if (kTightCopy_DomainMode == domainMode) {
388 // TODO: Copy the texture and adjust the texture matrix (both parts need to consider
389 // non-int constraint rect)
390 // For now: treat as bilerp and ignore what goes on above level 0.
391
392 // We only expect MIP maps to require a tight copy.
393 SkASSERT(filterOrNullForBicubic &&
394 GrTextureParams::kMipMap_FilterMode == *filterOrNullForBicubic);
395 static const GrTextureParams::FilterMode kBilerp = GrTextureParams::kBilerp_FilterMode;
396 domainMode =
bsalomon3aa5fce2015-11-12 09:59:44 -0800397 determine_domain_mode(*constraintRect, filterConstraint, coordsLimitedToConstraintRect,
bsalomonc55271f2015-11-09 11:55:57 -0800398 texture->width(), texture->height(),
399 contentArea, &kBilerp, &domain);
400 SkASSERT(kTightCopy_DomainMode != domainMode);
bsalomonc55271f2015-11-09 11:55:57 -0800401 }
402 SkASSERT(kNoDomain_DomainMode == domainMode ||
403 (domain.fLeft <= domain.fRight && domain.fTop <= domain.fBottom));
bsalomon3aa5fce2015-11-12 09:59:44 -0800404 textureMatrix.postIDiv(texture->width(), texture->height());
bsalomonb1b01992015-11-18 10:56:08 -0800405 return create_fp_for_domain_and_filter(texture, textureMatrix, domainMode, domain,
406 filterOrNullForBicubic);
bsalomonc55271f2015-11-09 11:55:57 -0800407}
408
bsalomon89fe56b2015-10-29 10:49:28 -0700409//////////////////////////////////////////////////////////////////////////////
410
bsalomonb1b01992015-11-18 10:56:08 -0800411GrTexture* GrTextureMaker::refTextureForParams(const GrTextureParams& params) {
bsalomon045802d2015-10-20 07:58:01 -0700412 CopyParams copyParams;
bsalomonb1b01992015-11-18 10:56:08 -0800413 if (!fContext->getGpu()->makeCopyForTextureParams(this->width(), this->height(), params,
414 &copyParams)) {
415 return this->refOriginalTexture();
bsalomon045802d2015-10-20 07:58:01 -0700416 }
417 GrUniqueKey copyKey;
418 this->makeCopyKey(copyParams, &copyKey);
419 if (copyKey.isValid()) {
bsalomonb1b01992015-11-18 10:56:08 -0800420 GrTexture* result = fContext->textureProvider()->findAndRefTextureByUniqueKey(copyKey);
bsalomon045802d2015-10-20 07:58:01 -0700421 if (result) {
422 return result;
423 }
424 }
425
bsalomonb1b01992015-11-18 10:56:08 -0800426 GrTexture* result = this->generateTextureForParams(copyParams);
bsalomon045802d2015-10-20 07:58:01 -0700427 if (!result) {
428 return nullptr;
429 }
430
431 if (copyKey.isValid()) {
bsalomonb1b01992015-11-18 10:56:08 -0800432 fContext->textureProvider()->assignUniqueKeyToTexture(copyKey, result);
bsalomon045802d2015-10-20 07:58:01 -0700433 this->didCacheCopy(copyKey);
434 }
435 return result;
436}
437
bsalomonb1b01992015-11-18 10:56:08 -0800438const GrFragmentProcessor* GrTextureMaker::createFragmentProcessor(
439 const SkMatrix& textureMatrix,
440 const SkRect& constraintRect,
441 FilterConstraint filterConstraint,
442 bool coordsLimitedToConstraintRect,
443 const GrTextureParams::FilterMode* filterOrNullForBicubic) {
444
445 const GrTextureParams::FilterMode* fmForDetermineDomain = filterOrNullForBicubic;
446 if (filterOrNullForBicubic && GrTextureParams::kMipMap_FilterMode == *filterOrNullForBicubic &&
447 kYes_FilterConstraint == filterConstraint) {
448 // TODo: Here we should force a copy restricted to the constraintRect since MIP maps will
449 // read outside the constraint rect. However, as in the adjuster case, we aren't currently
450 // doing that.
451 // We instead we compute the domain as though were bilerping which is only correct if we
452 // only sample level 0.
453 static const GrTextureParams::FilterMode kBilerp = GrTextureParams::kBilerp_FilterMode;
454 fmForDetermineDomain = &kBilerp;
455 }
456
457 GrTextureParams params;
458 if (filterOrNullForBicubic) {
459 params.reset(SkShader::kClamp_TileMode, *filterOrNullForBicubic);
460 } else {
461 // Bicubic doesn't use filtering for it's texture accesses.
462 params.reset(SkShader::kClamp_TileMode, GrTextureParams::kNone_FilterMode);
463 }
464 SkAutoTUnref<GrTexture> texture(this->refTextureForParams(params));
465 if (!texture) {
466 return nullptr;
467 }
468 SkRect domain;
469 DomainMode domainMode =
470 determine_domain_mode(constraintRect, filterConstraint, coordsLimitedToConstraintRect,
471 texture->width(), texture->height(), nullptr, fmForDetermineDomain,
472 &domain);
473 SkASSERT(kTightCopy_DomainMode != domainMode);
474 SkMatrix normalizedTextureMatrix = textureMatrix;
475 normalizedTextureMatrix.postIDiv(texture->width(), texture->height());
476 return create_fp_for_domain_and_filter(texture, normalizedTextureMatrix, domainMode, domain,
477 filterOrNullForBicubic);
478}
479
480GrTexture* GrTextureMaker::generateTextureForParams(const CopyParams& copyParams) {
481 SkAutoTUnref<GrTexture> original(this->refOriginalTexture());
bsalomon100b8f82015-10-28 08:37:44 -0700482 if (!original) {
483 return nullptr;
bsalomon045802d2015-10-20 07:58:01 -0700484 }
bsalomon89fe56b2015-10-29 10:49:28 -0700485 return copy_on_gpu(original, nullptr, copyParams);
bsalomon045802d2015-10-20 07:58:01 -0700486}