Skip to content

Commit

Permalink
Move destruction of PictureLayer's SkPicture to the IO thread (flutte…
Browse files Browse the repository at this point in the history
…r#3219)

The picture may hold references to images backed by GPU textures that must
be deleted on the IO thread.
  • Loading branch information
jason-simmons authored Nov 11, 2016
1 parent e1ac3ca commit ac479c4
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion flow/layers/picture_layer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,20 @@

#include "flutter/flow/layers/picture_layer.h"

#include "flutter/common/threads.h"
#include "flutter/flow/raster_cache.h"
#include "lib/ftl/logging.h"

namespace flow {

PictureLayer::PictureLayer() {}

PictureLayer::~PictureLayer() {}
PictureLayer::~PictureLayer() {
// The picture may contain references to textures that are associated
// with the IO thread's context.
SkPicture* picture = picture_.release();
blink::Threads::IO()->PostTask([picture]() { picture->unref(); });
}

void PictureLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) {
if (auto cache = context->raster_cache) {
Expand Down

0 comments on commit ac479c4

Please sign in to comment.