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

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

Issue 20362002: make the filter mode for GrTextureAccess an enum so we can plumb down (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: fall back to mipmaps for HQ sampling (for now) Created 7 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « src/gpu/GrClipMaskManager.cpp ('k') | src/gpu/GrSWMaskHelper.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 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "GrContext.h" 10 #include "GrContext.h"
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 }; 299 };
300 300
301 }; 301 };
302 302
303 // The desired texture is NPOT and tiled but that isn't supported by 303 // The desired texture is NPOT and tiled but that isn't supported by
304 // the current hardware. Resize the texture to be a POT 304 // the current hardware. Resize the texture to be a POT
305 GrTexture* GrContext::createResizedTexture(const GrTextureDesc& desc, 305 GrTexture* GrContext::createResizedTexture(const GrTextureDesc& desc,
306 const GrCacheID& cacheID, 306 const GrCacheID& cacheID,
307 void* srcData, 307 void* srcData,
308 size_t rowBytes, 308 size_t rowBytes,
309 bool needsFiltering) { 309 bool filter) {
310 SkAutoTUnref<GrTexture> clampedTexture(this->findAndRefTexture(desc, cacheID , NULL)); 310 SkAutoTUnref<GrTexture> clampedTexture(this->findAndRefTexture(desc, cacheID , NULL));
311 if (NULL == clampedTexture) { 311 if (NULL == clampedTexture) {
312 clampedTexture.reset(this->createTexture(NULL, desc, cacheID, srcData, r owBytes)); 312 clampedTexture.reset(this->createTexture(NULL, desc, cacheID, srcData, r owBytes));
313 313
314 if (NULL == clampedTexture) { 314 if (NULL == clampedTexture) {
315 return NULL; 315 return NULL;
316 } 316 }
317 } 317 }
318 318
319 GrTextureDesc rtDesc = desc; 319 GrTextureDesc rtDesc = desc;
320 rtDesc.fFlags = rtDesc.fFlags | 320 rtDesc.fFlags = rtDesc.fFlags |
321 kRenderTarget_GrTextureFlagBit | 321 kRenderTarget_GrTextureFlagBit |
322 kNoStencil_GrTextureFlagBit; 322 kNoStencil_GrTextureFlagBit;
323 rtDesc.fWidth = GrNextPow2(GrMax(desc.fWidth, 64)); 323 rtDesc.fWidth = GrNextPow2(GrMax(desc.fWidth, 64));
324 rtDesc.fHeight = GrNextPow2(GrMax(desc.fHeight, 64)); 324 rtDesc.fHeight = GrNextPow2(GrMax(desc.fHeight, 64));
325 325
326 GrTexture* texture = fGpu->createTexture(rtDesc, NULL, 0); 326 GrTexture* texture = fGpu->createTexture(rtDesc, NULL, 0);
327 327
328 if (NULL != texture) { 328 if (NULL != texture) {
329 GrDrawTarget::AutoStateRestore asr(fGpu, GrDrawTarget::kReset_ASRInit); 329 GrDrawTarget::AutoStateRestore asr(fGpu, GrDrawTarget::kReset_ASRInit);
330 GrDrawState* drawState = fGpu->drawState(); 330 GrDrawState* drawState = fGpu->drawState();
331 drawState->setRenderTarget(texture->asRenderTarget()); 331 drawState->setRenderTarget(texture->asRenderTarget());
332 332
333 // if filtering is not desired then we want to ensure all 333 // if filtering is not desired then we want to ensure all
334 // texels in the resampled image are copies of texels from 334 // texels in the resampled image are copies of texels from
335 // the original. 335 // the original.
336 GrTextureParams params(SkShader::kClamp_TileMode, needsFiltering); 336 GrTextureParams params(SkShader::kClamp_TileMode, filter ? GrTexturePara ms::kBilerp_FilterMode :
337 GrTexturePara ms::kNone_FilterMode);
337 drawState->addColorTextureEffect(clampedTexture, SkMatrix::I(), params); 338 drawState->addColorTextureEffect(clampedTexture, SkMatrix::I(), params);
338 339
339 drawState->setVertexAttribs<gVertexAttribs>(SK_ARRAY_COUNT(gVertexAttrib s)); 340 drawState->setVertexAttribs<gVertexAttribs>(SK_ARRAY_COUNT(gVertexAttrib s));
340 341
341 GrDrawTarget::AutoReleaseGeometry arg(fGpu, 4, 0); 342 GrDrawTarget::AutoReleaseGeometry arg(fGpu, 4, 0);
342 343
343 if (arg.succeeded()) { 344 if (arg.succeeded()) {
344 GrPoint* verts = (GrPoint*) arg.vertices(); 345 GrPoint* verts = (GrPoint*) arg.vertices();
345 verts[0].setIRectFan(0, 0, texture->width(), texture->height(), 2 * sizeof(GrPoint)); 346 verts[0].setIRectFan(0, 0, texture->width(), texture->height(), 2 * sizeof(GrPoint));
346 verts[1].setIRectFan(0, 0, 1, 1, 2 * sizeof(GrPoint)); 347 verts[1].setIRectFan(0, 0, 1, 1, 2 * sizeof(GrPoint));
(...skipping 30 matching lines...) Expand all
377 void* srcData, 378 void* srcData,
378 size_t rowBytes) { 379 size_t rowBytes) {
379 SK_TRACE_EVENT0("GrContext::createTexture"); 380 SK_TRACE_EVENT0("GrContext::createTexture");
380 381
381 GrResourceKey resourceKey = GrTexture::ComputeKey(fGpu, params, desc, cacheI D); 382 GrResourceKey resourceKey = GrTexture::ComputeKey(fGpu, params, desc, cacheI D);
382 383
383 GrTexture* texture; 384 GrTexture* texture;
384 if (GrTexture::NeedsResizing(resourceKey)) { 385 if (GrTexture::NeedsResizing(resourceKey)) {
385 texture = this->createResizedTexture(desc, cacheID, 386 texture = this->createResizedTexture(desc, cacheID,
386 srcData, rowBytes, 387 srcData, rowBytes,
387 GrTexture::NeedsFiltering(resourceK ey)); 388 GrTexture::NeedsBilerp(resourceKey) );
388 } else { 389 } else {
389 texture= fGpu->createTexture(desc, srcData, rowBytes); 390 texture= fGpu->createTexture(desc, srcData, rowBytes);
390 } 391 }
391 392
392 if (NULL != texture) { 393 if (NULL != texture) {
393 // Adding a resource could put us overbudget. Try to free up the 394 // Adding a resource could put us overbudget. Try to free up the
394 // necessary space before adding it. 395 // necessary space before adding it.
395 fTextureCache->purgeAsNeeded(1, texture->sizeInBytes()); 396 fTextureCache->purgeAsNeeded(1, texture->sizeInBytes());
396 fTextureCache->addResource(resourceKey, texture); 397 fTextureCache->addResource(resourceKey, texture);
397 } 398 }
(...skipping 1306 matching lines...) Expand 10 before | Expand all | Expand 10 after
1704 return NULL; 1705 return NULL;
1705 } 1706 }
1706 } 1707 }
1707 1708
1708 /////////////////////////////////////////////////////////////////////////////// 1709 ///////////////////////////////////////////////////////////////////////////////
1709 #if GR_CACHE_STATS 1710 #if GR_CACHE_STATS
1710 void GrContext::printCacheStats() const { 1711 void GrContext::printCacheStats() const {
1711 fTextureCache->printStats(); 1712 fTextureCache->printStats();
1712 } 1713 }
1713 #endif 1714 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrClipMaskManager.cpp ('k') | src/gpu/GrSWMaskHelper.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698