Cull pushCull and popCull from Skia.

These calls are unused and going away.  Waiting on crrev.com/796083002.

BUG=skia:

Review URL: https://codereview.chromium.org/794263002
This commit is contained in:
mtklein 2014-12-12 08:46:25 -08:00 committed by Commit bot
parent 59dba146fe
commit f0f1411343
18 changed files with 13 additions and 256 deletions

View File

@ -812,8 +812,7 @@ void SkDebuggerGUI::setupListWidget(SkTArray<SkString>* commands, SkTDArray<size
item->setData(Qt::UserRole + 1, counter++);
if (0 == strcmp("Restore", (*commands)[i].c_str()) ||
0 == strcmp("EndCommentGroup", (*commands)[i].c_str()) ||
0 == strcmp("PopCull", (*commands)[i].c_str())) {
0 == strcmp("EndCommentGroup", (*commands)[i].c_str())) {
indent -= 10;
}
@ -821,8 +820,7 @@ void SkDebuggerGUI::setupListWidget(SkTArray<SkString>* commands, SkTDArray<size
if (0 == strcmp("Save", (*commands)[i].c_str()) ||
0 == strcmp("Save Layer", (*commands)[i].c_str()) ||
0 == strcmp("BeginCommentGroup", (*commands)[i].c_str()) ||
0 == strcmp("PushCull", (*commands)[i].c_str())) {
0 == strcmp("BeginCommentGroup", (*commands)[i].c_str())) {
indent += 10;
}

View File

@ -1055,19 +1055,6 @@ public:
// do nothing. Subclasses may do something
}
/**
* With this call the client asserts that subsequent draw operations (up to the
* matching popCull()) are fully contained within the given bounding box. The assertion
* is not enforced, but the information might be used to quick-reject command blocks,
* so an incorrect bounding box may result in incomplete rendering.
*/
void pushCull(const SkRect& cullRect);
/**
* Terminates the current culling block, and restores the previous one (if any).
*/
void popCull();
//////////////////////////////////////////////////////////////////////////
/** Get the current filter object. The filter's reference count is not
@ -1250,9 +1237,6 @@ protected:
// can perform copy-on-write or invalidate any cached images
void predrawNotify();
virtual void onPushCull(const SkRect& cullRect);
virtual void onPopCull();
private:
class MCRec;
@ -1267,7 +1251,6 @@ private:
int fSaveCount; // value returned by getSaveCount()
int fSaveLayerCount; // number of successful saveLayer calls
int fCullCount; // number of active culls
SkMetaData* fMetaData;
@ -1385,9 +1368,6 @@ private:
};
#ifdef SK_DEBUG
// The cull stack rects are in device-space
SkTDArray<SkIRect> fCullStack;
void validateCull(const SkIRect&);
void validateClip() const;
#else
void validateClip() const {}

View File

@ -121,8 +121,6 @@ protected:
virtual void onDrawPatch(const SkPoint cubics[12], const SkColor colors[4],
const SkPoint texCoords[4], SkXfermode* xmode,
const SkPaint& paint) SK_OVERRIDE;
virtual void onPushCull(const SkRect& cullRect) SK_OVERRIDE;
virtual void onPopCull() SK_OVERRIDE;
virtual void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE;
virtual void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE;

View File

@ -417,7 +417,6 @@ SkBaseDevice* SkCanvas::init(SkBaseDevice* device, InitFlags flags) {
fDeviceCMDirty = true;
fSaveCount = 1;
fSaveLayerCount = 0;
fCullCount = 0;
fMetaData = NULL;
fMCRec = (MCRec*)fMCStack.push_back();
@ -696,7 +695,7 @@ bool SkCanvas::readPixels(const SkImageInfo& dstInfo, void* dstP, size_t rowByte
return false;
}
const SkISize size = this->getBaseLayerSize();
SkReadPixelsRec rec(dstInfo, dstP, rowBytes, x, y);
if (!rec.trim(size.width(), size.height())) {
return false;
@ -844,7 +843,7 @@ void SkCanvas::restoreToCount(int count) {
if (count < 1) {
count = 1;
}
int n = this->getSaveCount() - count;
for (int i = 0; i < n; ++i) {
this->restore();
@ -1119,71 +1118,7 @@ bool SkAutoROCanvasPixels::asROBitmap(SkBitmap* bitmap) const {
}
}
void SkCanvas::onPushCull(const SkRect& cullRect) {
// do nothing. Subclasses may do something
}
void SkCanvas::onPopCull() {
// do nothing. Subclasses may do something
}
/////////////////////////////////////////////////////////////////////////////
#ifdef SK_DEBUG
// Ensure that cull rects are monotonically nested in device space.
void SkCanvas::validateCull(const SkIRect& devCull) {
if (fCullStack.isEmpty()
|| devCull.isEmpty()
|| fCullStack.top().contains(devCull)) {
return;
}
SkDEBUGF(("Invalid cull: [%d %d %d %d] (previous cull: [%d %d %d %d])\n",
devCull.x(), devCull.y(), devCull.right(), devCull.bottom(),
fCullStack.top().x(), fCullStack.top().y(),
fCullStack.top().right(), fCullStack.top().bottom()));
#ifdef ASSERT_NESTED_CULLING
SkDEBUGFAIL("Invalid cull.");
#endif
}
#endif
void SkCanvas::pushCull(const SkRect& cullRect) {
this->checkForDeferredSave();
++fCullCount;
this->onPushCull(cullRect);
#ifdef SK_DEBUG
// Map the cull rect into device space.
SkRect mappedCull;
this->getTotalMatrix().mapRect(&mappedCull, cullRect);
// Take clipping into account.
SkIRect devClip, devCull;
mappedCull.roundOut(&devCull);
this->getClipDeviceBounds(&devClip);
if (!devCull.intersect(devClip)) {
devCull.setEmpty();
}
this->validateCull(devCull);
fCullStack.push(devCull); // balanced in popCull
#endif
}
void SkCanvas::popCull() {
SkASSERT(fCullStack.count() == fCullCount);
if (fCullCount > 0) {
--fCullCount;
this->onPopCull();
SkDEBUGCODE(fCullStack.pop());
}
}
/////////////////////////////////////////////////////////////////////////////
void SkCanvas::internalDrawBitmap(const SkBitmap& bitmap,
const SkMatrix& matrix, const SkPaint* paint) {
if (bitmap.drawsNothing()) {

View File

@ -63,8 +63,8 @@ enum DrawType {
// new ops -- feel free to re-alphabetize on next version bump
DRAW_DRRECT,
PUSH_CULL,
POP_CULL,
PUSH_CULL, // deprecated, M41 was last Chromium version to write this to an .skp
POP_CULL, // deprecated, M41 was last Chromium version to write this to an .skp
DRAW_PATCH, // could not add in aphabetical order
DRAW_PICTURE_MATRIX_PAINT,

View File

@ -148,18 +148,8 @@ void SkPicturePlayback::handleOp(SkReader32* reader,
reader->setOffset(offsetToRestore);
}
} break;
case PUSH_CULL: {
const SkRect& cullRect = reader->skipT<SkRect>();
size_t offsetToRestore = reader->readInt();
if (offsetToRestore && canvas->quickReject(cullRect)) {
reader->setOffset(offsetToRestore);
} else {
canvas->pushCull(cullRect);
}
} break;
case POP_CULL:
canvas->popCull();
break;
case PUSH_CULL: break; // Deprecated, safe to ignore both push and pop.
case POP_CULL: break;
case CONCAT: {
SkMatrix matrix;
reader->readMatrix(&matrix);

View File

@ -847,36 +847,6 @@ void SkPictureRecord::endCommentGroup() {
this->validate(initialOffset, size);
}
// [op/size] [rect] [skip offset]
static const uint32_t kPushCullOpSize = 2 * kUInt32Size + sizeof(SkRect);
void SkPictureRecord::onPushCull(const SkRect& cullRect) {
size_t size = kPushCullOpSize;
size_t initialOffset = this->addDraw(PUSH_CULL, &size);
// PUSH_CULL's size should stay constant (used to rewind).
SkASSERT(size == kPushCullOpSize);
this->addRect(cullRect);
fCullOffsetStack.push(SkToU32(fWriter.bytesWritten()));
this->addInt(0);
this->validate(initialOffset, size);
}
void SkPictureRecord::onPopCull() {
SkASSERT(!fCullOffsetStack.isEmpty());
uint32_t cullSkipOffset = fCullOffsetStack.top();
fCullOffsetStack.pop();
// op only
size_t size = kUInt32Size;
size_t initialOffset = this->addDraw(POP_CULL, &size);
// update the cull skip offset to point past this op.
fWriter.overwriteTAt<uint32_t>(cullSkipOffset, SkToU32(fWriter.bytesWritten()));
this->validate(initialOffset, size);
}
///////////////////////////////////////////////////////////////////////////////
SkSurface* SkPictureRecord::onNewSurface(const SkImageInfo& info, const SkSurfaceProps&) {

View File

@ -186,8 +186,6 @@ protected:
virtual void didSetMatrix(const SkMatrix&) SK_OVERRIDE;
virtual void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) SK_OVERRIDE;
virtual void onPushCull(const SkRect&) SK_OVERRIDE;
virtual void onPopCull() SK_OVERRIDE;
virtual void onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y,
const SkPaint&) SK_OVERRIDE;

View File

@ -81,8 +81,6 @@ template <> void Draw::draw(const NoOp&) {}
DRAW(Restore, restore());
DRAW(Save, save());
DRAW(SaveLayer, saveLayer(r.bounds, r.paint, r.flags));
DRAW(PopCull, popCull());
DRAW(PushCull, pushCull(r.rect));
DRAW(Clear, clear(r.color));
DRAW(SetMatrix, setMatrix(SkMatrix::Concat(fInitialCTM, r.matrix)));
@ -286,8 +284,6 @@ private:
void trackBounds(const ClipRRect&) { this->pushControl(); }
void trackBounds(const ClipPath&) { this->pushControl(); }
void trackBounds(const ClipRegion&) { this->pushControl(); }
void trackBounds(const PushCull&) { this->pushControl(); }
void trackBounds(const PopCull&) { this->pushControl(); }
void trackBounds(const BeginCommentGroup&) { this->pushControl(); }
void trackBounds(const AddComment&) { this->pushControl(); }
void trackBounds(const EndCommentGroup&) { this->pushControl(); }

View File

@ -295,14 +295,6 @@ void SkRecorder::didRestore() {
APPEND(Restore, this->devBounds(), this->getTotalMatrix());
}
void SkRecorder::onPushCull(const SkRect& rect) {
APPEND(PushCull, rect);
}
void SkRecorder::onPopCull() {
APPEND(PopCull);
}
void SkRecorder::didConcat(const SkMatrix& matrix) {
this->didSetMatrix(this->getTotalMatrix());
}

View File

@ -130,9 +130,6 @@ public:
void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) SK_OVERRIDE;
void onPushCull(const SkRect& cullRect) SK_OVERRIDE;
void onPopCull() SK_OVERRIDE;
void beginCommentGroup(const char*) SK_OVERRIDE;
void addComment(const char*, const char*) SK_OVERRIDE;
void endCommentGroup() SK_OVERRIDE;

View File

@ -30,8 +30,6 @@ namespace SkRecords {
M(Restore) \
M(Save) \
M(SaveLayer) \
M(PushCull) \
M(PopCull) \
M(SetMatrix) \
M(ClipPath) \
M(ClipRRect) \
@ -225,9 +223,6 @@ RECORD2(Restore, SkIRect, devBounds, TypedMatrix, matrix);
RECORD0(Save);
RECORD3(SaveLayer, Optional<SkRect>, bounds, Optional<SkPaint>, paint, SkCanvas::SaveFlags, flags);
RECORD1(PushCull, SkRect, rect);
RECORD0(PopCull);
RECORD1(SetMatrix, TypedMatrix, matrix);
struct RegionOpAndAA {

View File

@ -292,15 +292,6 @@ void SkDumpCanvas::onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) {
this->INHERITED::onClipRegion(deviceRgn, op);
}
void SkDumpCanvas::onPushCull(const SkRect& cullRect) {
SkString str;
toString(cullRect, &str);
this->dump(kCull_Verb, NULL, "pushCull(%s)", str.c_str());
}
void SkDumpCanvas::onPopCull() {
this->dump(kCull_Verb, NULL, "popCull()");
}
///////////////////////////////////////////////////////////////////////////////
void SkDumpCanvas::drawPaint(const SkPaint& paint) {

View File

@ -209,7 +209,6 @@ private:
// return true in their 'active' method
void SkDebugCanvas::markActiveCommands(int index) {
fActiveLayers.rewind();
fActiveCulls.rewind();
for (int i = 0; i < fCommandVector.count(); ++i) {
fCommandVector[i]->setActive(false);
@ -221,10 +220,6 @@ void SkDebugCanvas::markActiveCommands(int index) {
fActiveLayers.push(fCommandVector[i]);
} else if (SkDrawCommand::kPopLayer_Action == result) {
fActiveLayers.pop();
} else if (SkDrawCommand::kPushCull_Action == result) {
fActiveCulls.push(fCommandVector[i]);
} else if (SkDrawCommand::kPopCull_Action == result) {
fActiveCulls.pop();
}
}
@ -232,9 +227,6 @@ void SkDebugCanvas::markActiveCommands(int index) {
fActiveLayers[i]->setActive(true);
}
for (int i = 0; i < fActiveCulls.count(); ++i) {
fActiveCulls[i]->setActive(true);
}
}
void SkDebugCanvas::drawTo(SkCanvas* canvas, int index) {
@ -315,7 +307,7 @@ void SkDebugCanvas::drawTo(SkCanvas* canvas, int index) {
}
if (fMegaVizMode) {
SkRect r = SkRect::MakeWH(SkIntToScalar(fWindowSize.fWidth),
SkRect r = SkRect::MakeWH(SkIntToScalar(fWindowSize.fWidth),
SkIntToScalar(fWindowSize.fHeight));
r.outset(SK_Scalar1, SK_Scalar1);
@ -505,8 +497,8 @@ void SkDebugCanvas::drawPath(const SkPath& path, const SkPaint& paint) {
this->addDrawCommand(new SkDrawPathCommand(path, paint));
}
void SkDebugCanvas::onDrawPicture(const SkPicture* picture,
const SkMatrix* matrix,
void SkDebugCanvas::onDrawPicture(const SkPicture* picture,
const SkMatrix* matrix,
const SkPaint* paint) {
this->addDrawCommand(new SkDrawPictureCommand(picture, matrix, paint));
}
@ -570,14 +562,6 @@ void SkDebugCanvas::drawVertices(VertexMode vmode, int vertexCount,
texs, colors, NULL, indices, indexCount, paint));
}
void SkDebugCanvas::onPushCull(const SkRect& cullRect) {
this->addDrawCommand(new SkPushCullCommand(cullRect));
}
void SkDebugCanvas::onPopCull() {
this->addDrawCommand(new SkPopCullCommand());
}
void SkDebugCanvas::willRestore() {
this->addDrawCommand(new SkRestoreCommand());
this->INHERITED::willRestore();

View File

@ -237,8 +237,6 @@ protected:
const SkMatrix* matrix, const SkPaint&) SK_OVERRIDE;
virtual void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
const SkPaint& paint) SK_OVERRIDE;
virtual void onPushCull(const SkRect& cullRect) SK_OVERRIDE;
virtual void onPopCull() SK_OVERRIDE;
virtual void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE;
virtual void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE;
@ -285,12 +283,6 @@ private:
*/
SkTDArray<SkDrawCommand*> fActiveLayers;
/**
The active cull commands at a given point in the rendering.
Only used when "mega" visualization is enabled.
*/
SkTDArray<SkDrawCommand*> fActiveCulls;
/**
Adds the command to the classes vector of commands.
@param command The draw command for execution

View File

@ -65,8 +65,6 @@ const char* SkDrawCommand::GetCommandString(DrawType type) {
case COMMENT: return "Comment";
case END_COMMENT_GROUP: return "EndCommentGroup";
case DRAW_DRRECT: return "Draw DRRect";
case PUSH_CULL: return "PushCull";
case POP_CULL: return "PopCull";
default:
SkDebugf("DrawType error 0x%08x\n", type);
SkASSERT(0);
@ -972,27 +970,3 @@ void SkTranslateCommand::execute(SkCanvas* canvas) const {
canvas->translate(fDx, fDy);
}
SkPushCullCommand::SkPushCullCommand(const SkRect& cullRect)
: INHERITED(PUSH_CULL)
, fCullRect(cullRect) {
fInfo.push(SkObjectParser::RectToString(cullRect));
}
void SkPushCullCommand::execute(SkCanvas* canvas) const {
canvas->pushCull(fCullRect);
}
void SkPushCullCommand::vizExecute(SkCanvas* canvas) const {
canvas->pushCull(fCullRect);
SkPaint p;
p.setColor(SK_ColorCYAN);
p.setStyle(SkPaint::kStroke_Style);
canvas->drawRect(fCullRect, p);
}
SkPopCullCommand::SkPopCullCommand() : INHERITED(POP_CULL) { }
void SkPopCullCommand::execute(SkCanvas* canvas) const {
canvas->popCull();
}

View File

@ -46,23 +46,16 @@ public:
subclasses to track unresolved save() calls. */
virtual void trackSaveState(int* state) {}
// The next "active" system is only used by save, saveLayer, restore,
// pushCull and popCull. It is used in two ways:
// To determine which saveLayers are currently active (at a
// The next "active" system is only used by save, saveLayer, and restore.
// It is used to determine which saveLayers are currently active (at a
// given point in the rendering).
// saves just return a kPushLayer action but don't track active state
// restores just return a kPopLayer action
// saveLayers return kPushLayer but also track the active state
// To determine which culls are currently active (at a given point)
// in the rendering).
// pushCulls return a kPushCull action
// popCulls return a kPopCull action
enum Action {
kNone_Action,
kPopLayer_Action,
kPushLayer_Action,
kPopCull_Action,
kPushCull_Action
};
virtual Action action() const { return kNone_Action; }
virtual void setActive(bool active) {}
@ -613,28 +606,4 @@ private:
typedef SkDrawCommand INHERITED;
};
class SkPushCullCommand : public SkDrawCommand {
public:
SkPushCullCommand(const SkRect&);
virtual void execute(SkCanvas*) const SK_OVERRIDE;
virtual void vizExecute(SkCanvas* canvas) const SK_OVERRIDE;
virtual Action action() const { return kPushCull_Action; }
virtual void setActive(bool active) { fActive = active; }
virtual bool active() const { return fActive; }
private:
SkRect fCullRect;
bool fActive;
typedef SkDrawCommand INHERITED;
};
class SkPopCullCommand : public SkDrawCommand {
public:
SkPopCullCommand();
virtual void execute(SkCanvas* canvas) const SK_OVERRIDE;
virtual Action action() const { return kPopCull_Action; }
private:
typedef SkDrawCommand INHERITED;
};
#endif

View File

@ -122,10 +122,8 @@ DEF_TEST(RecordPattern_Complex, r) {
start = record.count();
recorder.save();
recorder.pushCull(SkRect::MakeWH(300, 200));
recorder.clipRect(SkRect::MakeWH(300, 200));
recorder.clipRect(SkRect::MakeWH(100, 400));
recorder.popCull();
recorder.restore();
REPORTER_ASSERT(r, pattern.match(&record, start) == record.count());
end = start;