Index: cc/resources/resource_provider.cc |
diff --git a/cc/resources/resource_provider.cc b/cc/resources/resource_provider.cc |
index 7ad1492aedbb12c6944005ba4533cb5a34a9fbd4..87b1c7a1fbf2eb9bfa7fc32927df8ca73bece18a 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. |
nduca
2014/04/23 23:07:24
what the heck is this? why do you need this?
|
+const float kDisplayDensityScaleFactor = 160.0f; |
+ |
GLenum TextureToStorageFormat(ResourceFormat format) { |
GLenum storage_format = GL_RGBA8_OES; |
switch (format) { |
@@ -444,10 +447,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()) { |
nduca
2014/04/23 23:07:24
can you do this as a separate change please?
|
+ // 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() { |
@@ -464,6 +475,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( |
@@ -624,6 +637,13 @@ ResourceProvider::~ResourceProvider() { |
CleanUpGLIfNeeded(); |
} |
+unsigned ResourceProvider::num_gpu_rasterization_samples( |
+ ResourceFormat format) const { |
+ const float dpi = |
+ kDisplayDensityScaleFactor * output_surface_->SurfaceScaleFactor(); |
+ 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 || |