提交 8f283823 编写于 作者: A Adam Barth 提交者: Collin Jackson

Make RasterCache responsible for prerolling the image

上级 21305459
......@@ -8,8 +8,6 @@
#include "sky/compositor/checkerboard.h"
#include "sky/compositor/raster_cache.h"
#define ENABLE_RASTER_CACHE 0
namespace sky {
namespace compositor {
......@@ -24,13 +22,8 @@ PictureLayer::~PictureLayer() {
void PictureLayer::Preroll(PaintContext::ScopedFrame& frame,
const SkMatrix& matrix) {
#if ENABLE_RASTER_CACHE
image_ = frame.context().raster_cache().GetImage(picture_.get(), matrix);
if (image_) {
image_->preroll(frame.gr_context(), SkShader::kClamp_TileMode,
SkShader::kClamp_TileMode, kMedium_SkFilterQuality);
}
#endif
image_ = frame.context().raster_cache().GetPrerolledImage(
frame.gr_context(), picture_.get(), matrix);
}
void PictureLayer::Paint(PaintContext::ScopedFrame& frame) {
......
......@@ -8,6 +8,8 @@
#include "base/logging.h"
#include "third_party/skia/include/core/SkImage.h"
#define ENABLE_RASTER_CACHE 0
namespace sky {
namespace compositor {
......@@ -32,7 +34,10 @@ RasterCache::Entry::Entry() {
RasterCache::Entry::~Entry() {
}
RefPtr<SkImage> RasterCache::GetImage(SkPicture* picture, const SkMatrix& ctm) {
RefPtr<SkImage> RasterCache::GetPrerolledImage(GrContext* context,
SkPicture* picture,
const SkMatrix& ctm) {
#if ENABLE_RASTER_CACHE
SkScalar scaleX = ctm.getScaleX();
SkScalar scaleY = ctm.getScaleY();
......@@ -67,10 +72,15 @@ RefPtr<SkImage> RasterCache::GetImage(SkPicture* picture, const SkMatrix& ctm) {
SkMatrix matrix = SkMatrix::MakeScale(scaleX, scaleY);
entry.image = adoptRef(SkImage::NewFromPicture(picture, physical_size,
&matrix, nullptr));
entry.image->preroll(context, SkShader::kClamp_TileMode,
SkShader::kClamp_TileMode, kMedium_SkFilterQuality);
}
}
return entry.image;
#else
return nullptr;
#endif
}
void RasterCache::SweepAfterFrame() {
......
......@@ -23,7 +23,8 @@ class RasterCache {
RasterCache();
~RasterCache();
RefPtr<SkImage> GetImage(SkPicture* picture, const SkMatrix& ctm);
RefPtr<SkImage> GetPrerolledImage(GrContext* context, SkPicture* picture,
const SkMatrix& ctm);
void SweepAfterFrame();
private:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册