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

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

Issue 54543008: Revert "Avoid re-rendering stencil clip for every draw with reducable clip stack" (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 1 month 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/GrStencilBuffer.h ('k') | tests/ClipCacheTest.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 2011 Google Inc. 2 * Copyright 2011 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 "SkGpuDevice.h" 8 #include "SkGpuDevice.h"
9 9
10 #include "effects/GrTextureDomainEffect.h" 10 #include "effects/GrTextureDomainEffect.h"
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 config = config8888_to_grconfig_and_flags(config8888, &flags); 337 config = config8888_to_grconfig_and_flags(config8888, &flags);
338 } else { 338 } else {
339 flags = 0; 339 flags = 0;
340 config= SkBitmapConfig2GrPixelConfig(bitmap.config()); 340 config= SkBitmapConfig2GrPixelConfig(bitmap.config());
341 } 341 }
342 342
343 fRenderTarget->writePixels(x, y, bitmap.width(), bitmap.height(), 343 fRenderTarget->writePixels(x, y, bitmap.width(), bitmap.height(),
344 config, bitmap.getPixels(), bitmap.rowBytes(), fl ags); 344 config, bitmap.getPixels(), bitmap.rowBytes(), fl ags);
345 } 345 }
346 346
347 namespace {
348 void purgeClipCB(int genID, void* ) {
349
350 if (SkClipStack::kInvalidGenID == genID ||
351 SkClipStack::kEmptyGenID == genID ||
352 SkClipStack::kWideOpenGenID == genID) {
353 // none of these cases will have a cached clip mask
354 return;
355 }
356
357 }
358 };
359
347 void SkGpuDevice::onAttachToCanvas(SkCanvas* canvas) { 360 void SkGpuDevice::onAttachToCanvas(SkCanvas* canvas) {
348 INHERITED::onAttachToCanvas(canvas); 361 INHERITED::onAttachToCanvas(canvas);
349 362
350 // Canvas promises that this ptr is valid until onDetachFromCanvas is called 363 // Canvas promises that this ptr is valid until onDetachFromCanvas is called
351 fClipData.fClipStack = canvas->getClipStack(); 364 fClipData.fClipStack = canvas->getClipStack();
365
366 fClipData.fClipStack->addPurgeClipCallback(purgeClipCB, fContext);
352 } 367 }
353 368
354 void SkGpuDevice::onDetachFromCanvas() { 369 void SkGpuDevice::onDetachFromCanvas() {
355 INHERITED::onDetachFromCanvas(); 370 INHERITED::onDetachFromCanvas();
371
372 // TODO: iterate through the clip stack and clean up any cached clip masks
373 fClipData.fClipStack->removePurgeClipCallback(purgeClipCB, fContext);
374
356 fClipData.fClipStack = NULL; 375 fClipData.fClipStack = NULL;
357 } 376 }
358 377
359 // call this every draw call, to ensure that the context reflects our state, 378 // call this every draw call, to ensure that the context reflects our state,
360 // and not the state from some other canvas/device 379 // and not the state from some other canvas/device
361 void SkGpuDevice::prepareDraw(const SkDraw& draw, bool forceIdentity) { 380 void SkGpuDevice::prepareDraw(const SkDraw& draw, bool forceIdentity) {
362 SkASSERT(NULL != fClipData.fClipStack); 381 SkASSERT(NULL != fClipData.fClipStack);
363 382
364 fContext->setRenderTarget(fRenderTarget); 383 fContext->setRenderTarget(fRenderTarget);
365 384
(...skipping 1466 matching lines...) Expand 10 before | Expand all | Expand 10 after
1832 GrTexture* texture, 1851 GrTexture* texture,
1833 bool needClear) 1852 bool needClear)
1834 : SkBitmapDevice(make_bitmap(context, texture->asRenderTarget())) { 1853 : SkBitmapDevice(make_bitmap(context, texture->asRenderTarget())) {
1835 1854
1836 SkASSERT(texture && texture->asRenderTarget()); 1855 SkASSERT(texture && texture->asRenderTarget());
1837 // This constructor is called from onCreateCompatibleDevice. It has locked t he RT in the texture 1856 // This constructor is called from onCreateCompatibleDevice. It has locked t he RT in the texture
1838 // cache. We pass true for the third argument so that it will get unlocked. 1857 // cache. We pass true for the third argument so that it will get unlocked.
1839 this->initFromRenderTarget(context, texture->asRenderTarget(), true); 1858 this->initFromRenderTarget(context, texture->asRenderTarget(), true);
1840 fNeedClear = needClear; 1859 fNeedClear = needClear;
1841 } 1860 }
OLDNEW
« no previous file with comments | « src/gpu/GrStencilBuffer.h ('k') | tests/ClipCacheTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698