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

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: the hunk, actually Created 6 years, 10 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') | chrome/app/generated_resources.grd » ('j') | 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..392b185d94842e1ce149d91e71d4699f54905d0d 100644
--- a/cc/resources/resource_provider.cc
+++ b/cc/resources/resource_provider.cc
@@ -12,6 +12,7 @@
#include "base/stl_util.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
+#include "cc/base/switches.h"
#include "cc/base/util.h"
#include "cc/output/gl_renderer.h" // For the GLC() macro.
#include "cc/resources/platform_color.h"
@@ -412,10 +413,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 +441,7 @@ 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();
nduca 2014/03/01 22:02:28 i think it woudl be better if you obtained this fr
skia::RefPtr<GrTexture> gr_texture =
skia::AdoptRef(gr_context->wrapBackendTexture(desc));
surface = skia::AdoptRef(
@@ -1217,6 +1227,7 @@ ResourceProvider::ResourceProvider(OutputSurface* output_surface,
use_compressed_texture_etc1_(false),
max_texture_size_(0),
best_texture_format_(RGBA_8888),
+ num_gpu_rasterization_samples_(0),
use_rgba_4444_texture_format_(use_rgba_4444_texture_format),
id_allocation_chunk_size_(id_allocation_chunk_size) {
DCHECK(output_surface_->HasClient());
@@ -1260,6 +1271,20 @@ bool ResourceProvider::InitializeGL() {
GLC(gl, gl->GetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size_));
best_texture_format_ = PlatformColor::BestTextureFormat(use_bgra);
+ switch (switches::GetGpuRasterizationType()) {
+ default:
+ NOTREACHED();
+ case switches::GpuRasterizationGpu:
+ num_gpu_rasterization_samples_ = 0;
+ break;
+ case switches::GpuRasterizationMsaa4:
+ num_gpu_rasterization_samples_ = 4;
+ break;
+ case switches::GpuRasterizationMsaa16:
+ num_gpu_rasterization_samples_ = 16;
+ break;
+ }
+
texture_id_allocator_.reset(
new TextureIdAllocator(gl, id_allocation_chunk_size_));
buffer_id_allocator_.reset(
« no previous file with comments | « cc/resources/resource_provider.h ('k') | chrome/app/generated_resources.grd » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698