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

Side by Side Diff: src/core/SkBBoxHierarchyRecord.cpp

Issue 568073004: Fix recording of saveLayout with unusual Xfermodes. (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Fixed member var names, formatting, copied comment Created 6 years, 3 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
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2012 Google Inc. 3 * Copyright 2012 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 #include "SkBBoxHierarchyRecord.h" 9 #include "SkBBoxHierarchyRecord.h"
10 #include "SkPictureStateTree.h" 10 #include "SkPictureStateTree.h"
(...skipping 19 matching lines...) Expand all
30 } 30 }
31 31
32 SkCanvas::SaveLayerStrategy SkBBoxHierarchyRecord::willSaveLayer(const SkRect* b ounds, 32 SkCanvas::SaveLayerStrategy SkBBoxHierarchyRecord::willSaveLayer(const SkRect* b ounds,
33 const SkPaint* paint, 33 const SkPaint* paint,
34 SaveFlags flags ) { 34 SaveFlags flags ) {
35 // For now, assume all filters affect transparent black. 35 // For now, assume all filters affect transparent black.
36 // FIXME: This could be made less conservative as an optimization. 36 // FIXME: This could be made less conservative as an optimization.
37 bool paintAffectsTransparentBlack = paint && 37 bool paintAffectsTransparentBlack = paint &&
38 ((paint->getImageFilter()) || 38 ((paint->getImageFilter()) ||
39 (paint->getColorFilter())); 39 (paint->getColorFilter()));
40 bool needToHandleBBox = paintAffectsTransparentBlack;
41 if (!needToHandleBBox && paint) {
42 // Unusual Xfermodes require us to process a saved layer
43 // even with operations outisde the clip.
44 // For example, DstIn is used by masking layers.
45 // https://code.google.com/p/skia/issues/detail?id=1291
46 SkXfermode* xfermode = paint->getXfermode();
47 SkXfermode::Mode mode;
48 // SrcOver is the common case with a NULL xfermode, so we should
49 // make that the fast path and bypass the mode extraction and test.
50 if (xfermode && xfermode->asMode(&mode)) {
51 switch (mode) {
52 case SkXfermode::kClear_Mode:
53 case SkXfermode::kSrc_Mode:
54 case SkXfermode::kSrcIn_Mode:
55 case SkXfermode::kDstIn_Mode:
56 case SkXfermode::kSrcOut_Mode:
57 case SkXfermode::kDstATop_Mode:
58 case SkXfermode::kModulate_Mode:
59 needToHandleBBox = true;
60 break;
61 default:
62 break;
63 }
64 }
65 }
66
40 SkRect drawBounds; 67 SkRect drawBounds;
41 if (paintAffectsTransparentBlack) { 68 if (needToHandleBBox) {
42 SkIRect deviceBounds; 69 SkIRect deviceBounds;
43 this->getClipDeviceBounds(&deviceBounds); 70 this->getClipDeviceBounds(&deviceBounds);
44 drawBounds.set(deviceBounds); 71 drawBounds.set(deviceBounds);
45 } 72 }
46 fStateTree->appendSaveLayer(this->writeStream().bytesWritten()); 73 fStateTree->appendSaveLayer(this->writeStream().bytesWritten());
47 SkCanvas::SaveLayerStrategy strategy = this->INHERITED::willSaveLayer(bounds , paint, flags); 74 SkCanvas::SaveLayerStrategy strategy = this->INHERITED::willSaveLayer(bounds , paint, flags);
48 if (paintAffectsTransparentBlack) { 75 if (needToHandleBBox) {
49 this->handleBBox(drawBounds); 76 this->handleBBox(drawBounds);
50 this->addNoOp(); 77 this->addNoOp();
51 } 78 }
52 return strategy; 79 return strategy;
53 } 80 }
54 81
55 void SkBBoxHierarchyRecord::willRestore() { 82 void SkBBoxHierarchyRecord::willRestore() {
56 fStateTree->appendRestore(); 83 fStateTree->appendRestore();
57 this->INHERITED::willRestore(); 84 this->INHERITED::willRestore();
58 } 85 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 123
97 bool SkBBoxHierarchyRecord::shouldRewind(void* data) { 124 bool SkBBoxHierarchyRecord::shouldRewind(void* data) {
98 // SkBBoxHierarchy::rewindInserts is called by SkPicture after the 125 // SkBBoxHierarchy::rewindInserts is called by SkPicture after the
99 // SkPicture has rewound its command stream. To match that rewind in the 126 // SkPicture has rewound its command stream. To match that rewind in the
100 // BBH, we rewind all draws that reference commands that were recorded 127 // BBH, we rewind all draws that reference commands that were recorded
101 // past the point to which the SkPicture has rewound, which is given by 128 // past the point to which the SkPicture has rewound, which is given by
102 // writeStream().bytesWritten(). 129 // writeStream().bytesWritten().
103 SkPictureStateTree::Draw* draw = static_cast<SkPictureStateTree::Draw*>(data ); 130 SkPictureStateTree::Draw* draw = static_cast<SkPictureStateTree::Draw*>(data );
104 return draw->fOffset >= writeStream().bytesWritten(); 131 return draw->fOffset >= writeStream().bytesWritten();
105 } 132 }
OLDNEW
« no previous file with comments | « gyp/tests.gypi ('k') | src/core/SkRecordDraw.cpp » ('j') | src/core/SkRecordDraw.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698