diff options
author | kkinnunen <kkinnunen@nvidia.com> | 2016-02-12 02:08:12 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-02-12 10:09:29 +0000 |
commit | adbacd950053d80419e4cfec6f998ccb470fc029 (patch) | |
tree | 5a4d115d09e5b6a22a92957b05c8b65430b0593a | |
parent | dca8d578aa3ab16d5153fcd0c1220bc4e6fcc2e3 (diff) | |
download | chromium_src-adbacd950053d80419e4cfec6f998ccb470fc029.zip chromium_src-adbacd950053d80419e4cfec6f998ccb470fc029.tar.gz chromium_src-adbacd950053d80419e4cfec6f998ccb470fc029.tar.bz2 |
cc: Avoid extra flush calls to Skia GrContext
Avoid calling GrContext::flush() upon every tile raster. The correct
way to ensure rendering has been submitted to GPU API level is by
"preparing for external io" the render target.
This fixes the problem where Skia GPU resource cache resources grow
old too quickly. Each flush will age the resources, and after
becoming too old (64), the resources will be redundantly destroyed upon
the next resource allocation. The flush is intended to be called at the
rate the order of frames. Before this fix, the flush was called at least
the amount relative to the amount of tiles. For MSAA, flush was called
more than one time per tile. This fix reduces the amount of flushes.
Also, after this fix the effect of potential extra flushes can be fixed
in Skia.
BUG=582858
CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel
Review URL: https://codereview.chromium.org/1653983002
Cr-Commit-Position: refs/heads/master@{#375152}
-rw-r--r-- | cc/raster/gpu_rasterizer.cc | 2 | ||||
-rw-r--r-- | cc/raster/scoped_gpu_raster.cc | 3 | ||||
-rw-r--r-- | cc/resources/resource_provider.cc | 11 | ||||
-rw-r--r-- | cc/resources/resource_provider.h | 2 |
4 files changed, 12 insertions, 6 deletions
diff --git a/cc/raster/gpu_rasterizer.cc b/cc/raster/gpu_rasterizer.cc index b8ad862..2dcd8e0 100644 --- a/cc/raster/gpu_rasterizer.cc +++ b/cc/raster/gpu_rasterizer.cc @@ -79,7 +79,7 @@ void GpuRasterizer::RasterizeSource( SkMultiPictureDraw multi_picture_draw; multi_picture_draw.add(sk_surface->getCanvas(), picture.get()); - multi_picture_draw.draw(msaa_sample_count_ > 0); + multi_picture_draw.draw(false); write_lock->ReleaseSkSurface(); } } diff --git a/cc/raster/scoped_gpu_raster.cc b/cc/raster/scoped_gpu_raster.cc index e6dcf23..9807c29 100644 --- a/cc/raster/scoped_gpu_raster.cc +++ b/cc/raster/scoped_gpu_raster.cc @@ -34,9 +34,6 @@ void ScopedGpuRaster::BeginGpuRaster() { } void ScopedGpuRaster::EndGpuRaster() { - class GrContext* gr_context = context_provider_->GrContext(); - gr_context->flush(); - GLES2Interface* gl = context_provider_->ContextGL(); // Restore default GL unpack alignment. TextureUploader expects this. diff --git a/cc/resources/resource_provider.cc b/cc/resources/resource_provider.cc index e12d5b2..504b8d3 100644 --- a/cc/resources/resource_provider.cc +++ b/cc/resources/resource_provider.cc @@ -1049,11 +1049,18 @@ void ResourceProvider::ScopedWriteLockGr::InitSkSurface( surface_props = SkSurfaceProps(flags, SkSurfaceProps::kLegacyFontHost_InitType); } - sk_surface_ = skia::AdoptRef( - SkSurface::NewWrappedRenderTarget(gr_context, desc, &surface_props)); + gr_surface_ = + skia::AdoptRef(gr_context->textureProvider()->wrapBackendTexture( + desc, kBorrow_GrWrapOwnership)); + if (gr_surface_) + sk_surface_ = skia::AdoptRef(SkSurface::NewRenderTargetDirect( + gr_surface_->asRenderTarget(), &surface_props)); } void ResourceProvider::ScopedWriteLockGr::ReleaseSkSurface() { + DCHECK(gr_surface_); + gr_surface_->prepareForExternalIO(); + gr_surface_.clear(); sk_surface_.clear(); } diff --git a/cc/resources/resource_provider.h b/cc/resources/resource_provider.h index 28cc134..03cbf8f 100644 --- a/cc/resources/resource_provider.h +++ b/cc/resources/resource_provider.h @@ -42,6 +42,7 @@ #include "ui/gfx/gpu_memory_buffer.h" class GrContext; +class GrSurface; namespace gpu { class GpuMemoryBufferManager; @@ -351,6 +352,7 @@ class CC_EXPORT ResourceProvider ResourceProvider::Resource* resource_; base::ThreadChecker thread_checker_; skia::RefPtr<SkSurface> sk_surface_; + skia::RefPtr<GrSurface> gr_surface_; DISALLOW_COPY_AND_ASSIGN(ScopedWriteLockGr); }; |