Remove use of EXPERIMENTAL_getActiveOps from layer hoisting code
This is getting in the way of switching to the SkRecord backend and is of questionable value. R=bsalomon@google.com Author: robertphillips@google.com Review URL: https://codereview.chromium.org/539693002
This commit is contained in:
parent
6a2f5fe867
commit
2ed8a75c28
@ -280,18 +280,12 @@ private:
|
||||
SkTDArray<void*> fOps;
|
||||
};
|
||||
|
||||
/** PRIVATE / EXPERIMENTAL -- do not call
|
||||
Return the operations required to render the content inside 'queryRect'.
|
||||
*/
|
||||
const OperationList* EXPERIMENTAL_getActiveOps(const SkRect& queryRect) const;
|
||||
|
||||
void createHeader(SkPictInfo* info) const;
|
||||
static bool IsValidPictInfo(const SkPictInfo& info);
|
||||
|
||||
friend class SkPictureData; // to access OperationList
|
||||
friend class SkPictureRecorder; // just for SkPicture-based constructor
|
||||
friend class SkGpuDevice; // for EXPERIMENTAL_getActiveOps/OperationList
|
||||
friend class GrLayerHoister; // for EXPERIMENTAL_getActiveOps/OperationList
|
||||
friend class SkGpuDevice; // for fData access
|
||||
friend class CollectLayers; // access to fRecord
|
||||
friend class SkPicturePlayback; // to get fData & OperationList
|
||||
friend class SkPictureReplacementPlayback; // to access OperationList
|
||||
|
@ -326,15 +326,6 @@ const SkMatrix& SkPicture::OperationList::matrix(int index) const {
|
||||
return *((SkPictureStateTree::Draw*)fOps[index])->fMatrix;
|
||||
}
|
||||
|
||||
// fRecord TODO(robert) / kind of OK in a non-optimal sense
|
||||
const SkPicture::OperationList* SkPicture::EXPERIMENTAL_getActiveOps(const SkRect& queryRect) const {
|
||||
SkASSERT(NULL != fData.get());
|
||||
if (NULL != fData.get()) {
|
||||
return fData->getActiveOps(queryRect);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// fRecord OK
|
||||
void SkPicture::draw(SkCanvas* canvas, SkDrawPictureCallback* callback) const {
|
||||
SkASSERT(NULL != canvas);
|
||||
|
@ -13,13 +13,9 @@
|
||||
|
||||
// Return true if any layers are suitable for hoisting
|
||||
bool GrLayerHoister::FindLayersToHoist(const GrAccelData *gpuData,
|
||||
const SkPicture::OperationList* ops,
|
||||
const SkRect& query,
|
||||
bool pullForward[]) {
|
||||
bool anyHoisted = false;
|
||||
for (int i = 0; i < gpuData->numSaveLayers(); ++i) {
|
||||
pullForward[i] = false;
|
||||
}
|
||||
|
||||
// Layer hoisting pre-renders the entire layer since it will be cached and potentially
|
||||
// reused with different clips (e.g., in different tiles). Because of this the
|
||||
@ -27,67 +23,32 @@ bool GrLayerHoister::FindLayersToHoist(const GrAccelData *gpuData,
|
||||
// is used to limit which clips are pre-rendered.
|
||||
static const int kSaveLayerMaxSize = 256;
|
||||
|
||||
if (NULL != ops) {
|
||||
// In this case the picture has been generated with a BBH so we use
|
||||
// the BBH to limit the pre-rendering to just the layers needed to cover
|
||||
// the region being drawn
|
||||
for (int i = 0; i < ops->numOps(); ++i) {
|
||||
uint32_t offset = ops->offset(i);
|
||||
// Pre-render all the layers that intersect the query rect
|
||||
for (int i = 0; i < gpuData->numSaveLayers(); ++i) {
|
||||
pullForward[i] = false;
|
||||
|
||||
// For now we're saving all the layers in the GrAccelData so they
|
||||
// can be nested. Additionally, the nested layers appear before
|
||||
// their parent in the list.
|
||||
for (int j = 0; j < gpuData->numSaveLayers(); ++j) {
|
||||
const GrAccelData::SaveLayerInfo& info = gpuData->saveLayerInfo(j);
|
||||
const GrAccelData::SaveLayerInfo& info = gpuData->saveLayerInfo(i);
|
||||
|
||||
if (pullForward[j]) {
|
||||
continue; // already pulling forward
|
||||
}
|
||||
SkRect layerRect = SkRect::MakeXYWH(SkIntToScalar(info.fOffset.fX),
|
||||
SkIntToScalar(info.fOffset.fY),
|
||||
SkIntToScalar(info.fSize.fWidth),
|
||||
SkIntToScalar(info.fSize.fHeight));
|
||||
|
||||
if (offset < info.fSaveLayerOpID || offset > info.fRestoreOpID) {
|
||||
continue; // the op isn't in this range
|
||||
}
|
||||
|
||||
// TODO: once this code is more stable unsuitable layers can
|
||||
// just be omitted during the optimization stage
|
||||
if (!info.fValid ||
|
||||
kSaveLayerMaxSize < info.fSize.fWidth ||
|
||||
kSaveLayerMaxSize < info.fSize.fHeight ||
|
||||
info.fIsNested) {
|
||||
continue; // this layer is unsuitable
|
||||
}
|
||||
|
||||
pullForward[j] = true;
|
||||
anyHoisted = true;
|
||||
}
|
||||
if (!SkRect::Intersects(query, layerRect)) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
// In this case there is no BBH associated with the picture. Pre-render
|
||||
// all the layers that intersect the drawn region
|
||||
for (int j = 0; j < gpuData->numSaveLayers(); ++j) {
|
||||
const GrAccelData::SaveLayerInfo& info = gpuData->saveLayerInfo(j);
|
||||
|
||||
SkRect layerRect = SkRect::MakeXYWH(SkIntToScalar(info.fOffset.fX),
|
||||
SkIntToScalar(info.fOffset.fY),
|
||||
SkIntToScalar(info.fSize.fWidth),
|
||||
SkIntToScalar(info.fSize.fHeight));
|
||||
|
||||
if (!SkRect::Intersects(query, layerRect)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// TODO: once this code is more stable unsuitable layers can
|
||||
// just be omitted during the optimization stage
|
||||
if (!info.fValid ||
|
||||
kSaveLayerMaxSize < info.fSize.fWidth ||
|
||||
kSaveLayerMaxSize < info.fSize.fHeight ||
|
||||
info.fIsNested) {
|
||||
continue;
|
||||
}
|
||||
|
||||
pullForward[j] = true;
|
||||
anyHoisted = true;
|
||||
// TODO: once this code is more stable unsuitable layers can
|
||||
// just be omitted during the optimization stage
|
||||
if (!info.fValid ||
|
||||
kSaveLayerMaxSize < info.fSize.fWidth ||
|
||||
kSaveLayerMaxSize < info.fSize.fHeight ||
|
||||
info.fIsNested) {
|
||||
continue;
|
||||
}
|
||||
|
||||
pullForward[i] = true;
|
||||
anyHoisted = true;
|
||||
}
|
||||
|
||||
return anyHoisted;
|
||||
|
@ -24,14 +24,12 @@ class GrLayerHoister {
|
||||
public:
|
||||
/** Find the layers in 'gpuData' that need hoisting.
|
||||
@param gpuData Acceleration structure containing layer information for a picture
|
||||
@param ops If a BBH is being used the operations about to be executed; NULL otherwise.
|
||||
@param query The rectangle that is about to be drawn.
|
||||
@param pullForward A gpuData->numSaveLayers -sized Boolean array indicating
|
||||
which layers are to be hoisted
|
||||
Return true if any layers are suitable for hoisting; false otherwise
|
||||
*/
|
||||
static bool FindLayersToHoist(const GrAccelData *gpuData,
|
||||
const SkPicture::OperationList* ops,
|
||||
const SkRect& query,
|
||||
bool pullForward[]);
|
||||
|
||||
|
@ -1871,10 +1871,7 @@ bool SkGpuDevice::EXPERIMENTAL_drawPicture(SkCanvas* mainCanvas, const SkPicture
|
||||
return true;
|
||||
}
|
||||
|
||||
SkAutoTDelete<const SkPicture::OperationList> ops(
|
||||
picture->EXPERIMENTAL_getActiveOps(clipBounds));
|
||||
|
||||
if (!GrLayerHoister::FindLayersToHoist(gpuData, ops.get(), clipBounds, pullForward.get())) {
|
||||
if (!GrLayerHoister::FindLayersToHoist(gpuData, clipBounds, pullForward.get())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1939,7 +1936,7 @@ bool SkGpuDevice::EXPERIMENTAL_drawPicture(SkCanvas* mainCanvas, const SkPicture
|
||||
GrLayerHoister::DrawLayers(picture, atlased, nonAtlased);
|
||||
|
||||
// Render the entire picture using new layers
|
||||
SkPictureReplacementPlayback playback(picture, &replacements, ops.get());
|
||||
SkPictureReplacementPlayback playback(picture, &replacements, NULL);
|
||||
|
||||
playback.draw(mainCanvas, NULL);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user