#if SK_SUPPORT_GPU
#include "GrLayerHoister.h"
#include "GrRecordReplaceDraw.h"
+#include "GrRenderTarget.h"
#endif
void SkMultiPictureDraw::DrawData::draw() {
continue;
}
+ GrRenderTarget* rt = data.fCanvas->internal_private_accessTopLayerRenderTarget();
+ SkASSERT(rt);
+
// TODO: sorting the cacheable layers from smallest to largest
// would improve the packing and reduce the number of swaps
// TODO: another optimization would be to make a first pass to
// lock any required layer that is already in the atlas
GrLayerHoister::FindLayersToAtlas(context, data.fPicture,
clipBounds,
- &atlasedNeedRendering, &atlasedRecycled);
+ &atlasedNeedRendering, &atlasedRecycled,
+ rt->numSamples());
}
}
continue;
}
+ GrRenderTarget* rt = data.fCanvas->internal_private_accessTopLayerRenderTarget();
+ SkASSERT(rt);
+
// Find the layers required by this canvas. It will return atlased
// layers in the 'recycled' list since they have already been drawn.
GrLayerHoister::FindLayersToHoist(context, picture,
- clipBounds, &needRendering, &recycled);
+ clipBounds, &needRendering, &recycled,
+ rt->numSamples());
GrLayerHoister::DrawLayers(context, needRendering);
SkDEBUGCODE(GrAutoValidateLayer avl(fAtlas ? fAtlas->getTexture() : NULL, layer);)
SkASSERT(PlausiblyAtlasable(desc.fWidth, desc.fHeight));
+ SkASSERT(0 == desc.fSampleCnt);
if (layer->locked()) {
// This layer is already locked
const SkIRect& layerRect,
SkTDArray<GrHoistedLayer>* needRendering,
SkTDArray<GrHoistedLayer>* recycled,
- bool attemptToAtlas) {
+ bool attemptToAtlas,
+ int numSamples) {
const SkPicture* pict = info.fPicture ? info.fPicture : topLevelPicture;
SkMatrix combined = SkMatrix::Concat(info.fPreMat, info.fLocalMat);
desc.fWidth = layerRect.width();
desc.fHeight = layerRect.height();
desc.fConfig = kSkia8888_GrPixelConfig;
- // TODO: need to deal with sample count
+ desc.fSampleCnt = numSamples;
bool locked, needsRendering;
if (attemptToAtlas) {
const SkPicture* topLevelPicture,
const SkRect& query,
SkTDArray<GrHoistedLayer>* atlased,
- SkTDArray<GrHoistedLayer>* recycled) {
+ SkTDArray<GrHoistedLayer>* recycled,
+ int numSamples) {
+ if (0 != numSamples) {
+ // MSAA layers are currently never atlased
+ return;
+ }
+
GrLayerCache* layerCache = context->getLayerCache();
layerCache->processDeletedPictures();
continue;
}
- prepare_for_hoisting(layerCache, topLevelPicture, info, ir, atlased, recycled, true);
+ prepare_for_hoisting(layerCache, topLevelPicture, info, ir, atlased, recycled, true, 0);
}
}
const SkPicture* topLevelPicture,
const SkRect& query,
SkTDArray<GrHoistedLayer>* needRendering,
- SkTDArray<GrHoistedLayer>* recycled) {
+ SkTDArray<GrHoistedLayer>* recycled,
+ int numSamples) {
GrLayerCache* layerCache = context->getLayerCache();
layerCache->processDeletedPictures();
layerRect.roundOut(&ir);
prepare_for_hoisting(layerCache, topLevelPicture, info, ir,
- needRendering, recycled, false);
+ needRendering, recycled, false, numSamples);
}
}
@param atlasedNeedRendering Out parameter storing the layers that
should be hoisted to the atlas
@param recycled Out parameter storing layers that are atlased but do not need rendering
+ @param numSamples The number if MSAA samples required
*/
static void FindLayersToAtlas(GrContext* context,
const SkPicture* topLevelPicture,
const SkRect& query,
SkTDArray<GrHoistedLayer>* atlasedNeedRendering,
- SkTDArray<GrHoistedLayer>* recycled);
+ SkTDArray<GrHoistedLayer>* recycled,
+ int numSamples);
/** Find the layers in 'topLevelPicture' that need hoisting. Note that the discovered
layers can be inside nested sub-pictures.
@param needRendering Out parameter storing the layers that need rendering.
This should never include atlased layers.
@param recycled Out parameter storing layers that need hoisting but not rendering
+ @param numSamples The number if MSAA samples required
*/
static void FindLayersToHoist(GrContext* context,
const SkPicture* topLevelPicture,
const SkRect& query,
SkTDArray<GrHoistedLayer>* needRendering,
- SkTDArray<GrHoistedLayer>* recycled);
+ SkTDArray<GrHoistedLayer>* recycled,
+ int numSamples);
/** Draw the specified layers into the atlas.
@param context Owner of the layer cache (and thus the layers)
GrLayerHoister::FindLayersToAtlas(fContext, mainPicture,
clipBounds,
- &atlasedNeedRendering, &atlasedRecycled);
+ &atlasedNeedRendering, &atlasedRecycled,
+ fRenderTarget->numSamples());
GrLayerHoister::DrawLayersToAtlas(fContext, atlasedNeedRendering);
GrLayerHoister::FindLayersToHoist(fContext, mainPicture,
clipBounds,
- &needRendering, &recycled);
+ &needRendering, &recycled,
+ fRenderTarget->numSamples());
GrLayerHoister::DrawLayers(fContext, needRendering);