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

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

Issue 48593003: Avoid re-rendering stencil clip for every draw with reducable clip stack (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: rebase 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
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
360 void SkGpuDevice::onAttachToCanvas(SkCanvas* canvas) { 347 void SkGpuDevice::onAttachToCanvas(SkCanvas* canvas) {
361 INHERITED::onAttachToCanvas(canvas); 348 INHERITED::onAttachToCanvas(canvas);
362 349
363 // Canvas promises that this ptr is valid until onDetachFromCanvas is called 350 // Canvas promises that this ptr is valid until onDetachFromCanvas is called
364 fClipData.fClipStack = canvas->getClipStack(); 351 fClipData.fClipStack = canvas->getClipStack();
365
366 fClipData.fClipStack->addPurgeClipCallback(purgeClipCB, fContext);
367 } 352 }
368 353
369 void SkGpuDevice::onDetachFromCanvas() { 354 void SkGpuDevice::onDetachFromCanvas() {
370 INHERITED::onDetachFromCanvas(); 355 INHERITED::onDetachFromCanvas();
371 356
372 // TODO: iterate through the clip stack and clean up any cached clip masks 357 // TODO: iterate through the clip stack and clean up any cached clip masks
bsalomon 2013/10/30 14:25:59 This comment should go too I think
Kimmo Kinnunen 2013/11/01 12:12:20 Done.
373 fClipData.fClipStack->removePurgeClipCallback(purgeClipCB, fContext);
374
375 fClipData.fClipStack = NULL; 358 fClipData.fClipStack = NULL;
376 } 359 }
377 360
378 // call this every draw call, to ensure that the context reflects our state, 361 // call this every draw call, to ensure that the context reflects our state,
379 // and not the state from some other canvas/device 362 // and not the state from some other canvas/device
380 void SkGpuDevice::prepareDraw(const SkDraw& draw, bool forceIdentity) { 363 void SkGpuDevice::prepareDraw(const SkDraw& draw, bool forceIdentity) {
381 SkASSERT(NULL != fClipData.fClipStack); 364 SkASSERT(NULL != fClipData.fClipStack);
382 365
383 fContext->setRenderTarget(fRenderTarget); 366 fContext->setRenderTarget(fRenderTarget);
384 367
(...skipping 1466 matching lines...) Expand 10 before | Expand all | Expand 10 after
1851 GrTexture* texture, 1834 GrTexture* texture,
1852 bool needClear) 1835 bool needClear)
1853 : SkBitmapDevice(make_bitmap(context, texture->asRenderTarget())) { 1836 : SkBitmapDevice(make_bitmap(context, texture->asRenderTarget())) {
1854 1837
1855 SkASSERT(texture && texture->asRenderTarget()); 1838 SkASSERT(texture && texture->asRenderTarget());
1856 // This constructor is called from onCreateCompatibleDevice. It has locked t he RT in the texture 1839 // This constructor is called from onCreateCompatibleDevice. It has locked t he RT in the texture
1857 // cache. We pass true for the third argument so that it will get unlocked. 1840 // cache. We pass true for the third argument so that it will get unlocked.
1858 this->initFromRenderTarget(context, texture->asRenderTarget(), true); 1841 this->initFromRenderTarget(context, texture->asRenderTarget(), true);
1859 fNeedClear = needClear; 1842 fNeedClear = needClear;
1860 } 1843 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698