Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1053)

Unified Diff: cc/resources/resource_provider.cc

Issue 184573002: Use MSAA in GPU rasterization if Skia suggests it (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address review comments Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/resources/resource_provider.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/resources/resource_provider.cc
diff --git a/cc/resources/resource_provider.cc b/cc/resources/resource_provider.cc
index e58ed0b73b7c33c01b62ae654d8ec3bdf1664704..3a63b8c474d4dbe039a1183d5afe9c7a79b4036c 100644
--- a/cc/resources/resource_provider.cc
+++ b/cc/resources/resource_provider.cc
@@ -61,6 +61,9 @@ namespace {
const double kSoftwareUploadTickRate = 0.000250;
const double kTextureUploadTickRate = 0.004;
+// Display density in dots per inch at scale factor 1.0.
+const float kDisplayDensityScaleFactor = 160.0f;
+
GLenum TextureToStorageFormat(ResourceFormat format) {
GLenum storage_format = GL_RGBA8_OES;
switch (format) {
@@ -412,10 +415,18 @@ SkCanvas* ResourceProvider::DirectRasterBuffer::DoLockForWrite() {
}
bool ResourceProvider::DirectRasterBuffer::DoUnlockForWrite() {
- // generationID returns a non-zero, unique value corresponding to the content
- // of surface. Hence, a change since DoLockForWrite was called means the
- // surface has changed.
- return surface_ ? surface_generation_id_ != surface_->generationID() : false;
+ if (surface_) {
+ // generationID returns a non-zero, unique value corresponding to the
+ // content of surface. Hence, a change since DoLockForWrite was called
+ // means the surface has changed.
+ if (surface_generation_id_ != surface_->generationID()) {
+ // Flush any pending or deferred work canvas or device might have. This
+ // also resolves the potential MSAA.
+ surface_->getCanvas()->flush();
+ return true;
+ }
+ }
+ return false;
}
skia::RefPtr<SkSurface> ResourceProvider::DirectRasterBuffer::CreateSurface() {
@@ -432,6 +443,8 @@ skia::RefPtr<SkSurface> ResourceProvider::DirectRasterBuffer::CreateSurface() {
desc.fConfig = ToGrPixelConfig(resource()->format);
desc.fOrigin = kTopLeft_GrSurfaceOrigin;
desc.fTextureHandle = resource()->gl_id;
+ desc.fSampleCnt = resource_provider()->num_gpu_rasterization_samples(
+ resource()->format);
skia::RefPtr<GrTexture> gr_texture =
skia::AdoptRef(gr_context->wrapBackendTexture(desc));
surface = skia::AdoptRef(
@@ -596,6 +609,13 @@ ResourceProvider::~ResourceProvider() {
CleanUpGLIfNeeded();
}
+unsigned ResourceProvider::num_gpu_rasterization_samples(
+ ResourceFormat format) const {
+ const float dpi =
+ kDisplayDensityScaleFactor * output_surface_->SurfaceScaleFactor();
Kimmo Kinnunen 2014/03/06 07:16:51 Not entirely sure if this call is thread-safe. Is
+ return GrContext()->getRecommendedSampleCount(ToGrPixelConfig(format), dpi);
+}
+
bool ResourceProvider::InUseByConsumer(ResourceId id) {
Resource* resource = GetResource(id);
return resource->lock_for_read_count > 0 || resource->exported_count > 0 ||
« no previous file with comments | « cc/resources/resource_provider.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698