Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
cc: Remove all traces of synchronous GPU rasterization
Browse files Browse the repository at this point in the history
Removed threaded gpu raster flag, and syncronous gpu raster tests and
all code required for syncronous gpu rasterization.

Removed the empty software rasterizer class, and base and moved
ownership of the gpu rasterizer into the GpuTileTaskWorkerPool, since
it is still a nice separation of functionality

BUG=457860

Review URL: https://codereview.chromium.org/1063493002

Cr-Commit-Position: refs/heads/master@{#323860}
  • Loading branch information
hendrikw authored and Commit bot committed Apr 4, 2015
1 parent a9e0c0d commit 59d4494
Show file tree
Hide file tree
Showing 39 changed files with 74 additions and 643 deletions.
3 changes: 0 additions & 3 deletions cc/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,6 @@ component("cc") {
"resources/raster_tile_priority_queue_all.h",
"resources/raster_tile_priority_queue_required.cc",
"resources/raster_tile_priority_queue_required.h",
"resources/rasterizer.h",
"resources/release_callback.h",
"resources/resource.cc",
"resources/resource.h",
Expand Down Expand Up @@ -427,8 +426,6 @@ component("cc") {
"resources/single_release_callback_impl.h",
"resources/skpicture_content_layer_updater.cc",
"resources/skpicture_content_layer_updater.h",
"resources/software_rasterizer.cc",
"resources/software_rasterizer.h",
"resources/task_graph_runner.cc",
"resources/task_graph_runner.h",
"resources/texture_compressor.cc",
Expand Down
3 changes: 0 additions & 3 deletions cc/cc.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,6 @@
'resources/raster_tile_priority_queue_all.h',
'resources/raster_tile_priority_queue_required.cc',
'resources/raster_tile_priority_queue_required.h',
'resources/rasterizer.h',
'resources/recording_source.h',
'resources/release_callback.h',
'resources/resource.cc',
Expand Down Expand Up @@ -480,8 +479,6 @@
'resources/single_release_callback_impl.h',
'resources/skpicture_content_layer_updater.cc',
'resources/skpicture_content_layer_updater.h',
'resources/software_rasterizer.cc',
'resources/software_rasterizer.h',
'resources/task_graph_runner.cc',
'resources/task_graph_runner.h',
'resources/texture_compressor.cc',
Expand Down
126 changes: 3 additions & 123 deletions cc/resources/gpu_rasterizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,74 +26,19 @@

namespace cc {

// static
scoped_ptr<GpuRasterizer> GpuRasterizer::Create(
ContextProvider* context_provider,
ResourceProvider* resource_provider,
bool use_distance_field_text,
bool threaded_gpu_rasterization_enabled,
int msaa_sample_count) {
return make_scoped_ptr<GpuRasterizer>(new GpuRasterizer(
context_provider, resource_provider, use_distance_field_text,
threaded_gpu_rasterization_enabled, msaa_sample_count));
}

GpuRasterizer::GpuRasterizer(ContextProvider* context_provider,
ResourceProvider* resource_provider,
bool use_distance_field_text,
bool threaded_gpu_rasterization_enabled,
int msaa_sample_count)
: resource_provider_(resource_provider),
use_distance_field_text_(use_distance_field_text),
threaded_gpu_rasterization_enabled_(threaded_gpu_rasterization_enabled),
msaa_sample_count_(msaa_sample_count) {
}

GpuRasterizer::~GpuRasterizer() {
}

PrepareTilesMode GpuRasterizer::GetPrepareTilesMode() {
return threaded_gpu_rasterization_enabled_
? PrepareTilesMode::RASTERIZE_PRIORITIZED_TILES
: PrepareTilesMode::PREPARE_NONE;
}

ContextProvider* GpuRasterizer::GetContextProvider(bool worker_context) {
return worker_context
? resource_provider_->output_surface()->worker_context_provider()
: resource_provider_->output_surface()->context_provider();
}

void GpuRasterizer::RasterizeTiles(
const TileVector& tiles,
ResourcePool* resource_pool,
ResourceFormat resource_format,
const UpdateTileDrawInfoCallback& update_tile_draw_info) {
ScopedGpuRaster gpu_raster(GetContextProvider(false));

ScopedResourceWriteLocks locks;

for (Tile* tile : tiles) {
RasterSource::SolidColorAnalysis analysis;

if (tile->use_picture_analysis())
PerformSolidColorAnalysis(tile, &analysis);

scoped_ptr<ScopedResource> resource;
if (!analysis.is_solid_color) {
resource = resource_pool->AcquireResource(tile->desired_texture_size(),
resource_format);
AddToMultiPictureDraw(tile, resource.get(), &locks);
}
update_tile_draw_info.Run(tile, resource.Pass(), analysis);
}

// If MSAA is enabled, tell Skia to resolve each render target after draw.
multi_picture_draw_.draw(msaa_sample_count_ > 0);
}

void GpuRasterizer::RasterizeSource(
bool use_worker_context,
ResourceProvider::ScopedWriteLockGr* write_lock,
const RasterSource* raster_source,
const gfx::Rect& rect,
Expand All @@ -116,8 +61,9 @@ void GpuRasterizer::RasterizeSource(

// Playback picture into resource.
{
ScopedGpuRaster gpu_raster(GetContextProvider(use_worker_context));
write_lock->InitSkSurface(use_worker_context, use_distance_field_text,
ScopedGpuRaster gpu_raster(
resource_provider_->output_surface()->worker_context_provider());
write_lock->InitSkSurface(use_distance_field_text,
raster_source->CanUseLCDText(),
msaa_sample_count_);

Expand All @@ -135,70 +81,4 @@ void GpuRasterizer::RasterizeSource(
}
}

void GpuRasterizer::PerformSolidColorAnalysis(
const Tile* tile,
RasterSource::SolidColorAnalysis* analysis) {
const void* tile_id = static_cast<const void*>(tile);
frame_viewer_instrumentation::ScopedAnalyzeTask analyze_task(
tile_id, tile->combined_priority().resolution,
tile->source_frame_number(), tile->layer_id());

DCHECK(tile->raster_source());

tile->raster_source()->PerformSolidColorAnalysis(
tile->content_rect(), tile->contents_scale(), analysis);

// Record the solid color prediction.
UMA_HISTOGRAM_BOOLEAN("Renderer4.SolidColorTilesAnalyzed",
analysis->is_solid_color);
}

void GpuRasterizer::AddToMultiPictureDraw(const Tile* tile,
const ScopedResource* resource,
ScopedResourceWriteLocks* locks) {
const void* tile_id = static_cast<const void*>(tile);
frame_viewer_instrumentation::ScopedRasterTask raster_task(
tile_id, tile->combined_priority().resolution,
tile->source_frame_number(), tile->layer_id());

DCHECK(tile->raster_source());

// Turn on distance fields for layers that have ever animated.
bool use_distance_field_text =
use_distance_field_text_ ||
tile->raster_source()->ShouldAttemptToUseDistanceFieldText();
scoped_ptr<ResourceProvider::ScopedWriteLockGr> lock(
new ResourceProvider::ScopedWriteLockGr(resource_provider_,
resource->id()));

lock->InitSkSurface(false, use_distance_field_text,
tile->raster_source()->CanUseLCDText(),
msaa_sample_count_);

SkSurface* sk_surface = lock->sk_surface();

// Allocating an SkSurface will fail after a lost context. Pretend we
// rasterized, as the contents of the resource don't matter anymore.
if (!sk_surface)
return;

locks->push_back(lock.Pass());

SkRTreeFactory factory;
SkPictureRecorder recorder;
gfx::Size size = resource->size();
const int flags = SkPictureRecorder::kComputeSaveLayerInfo_RecordFlag;
skia::RefPtr<SkCanvas> canvas = skia::SharePtr(
recorder.beginRecording(size.width(), size.height(), &factory, flags));

canvas->save();
tile->raster_source()->PlaybackToCanvas(canvas.get(), tile->content_rect(),
tile->contents_scale());
canvas->restore();

// Add the canvas and recorded picture to |multi_picture_draw_|.
skia::RefPtr<SkPicture> picture = skia::AdoptRef(recorder.endRecording());
multi_picture_draw_.add(sk_surface->getCanvas(), picture.get());
}

} // namespace cc
37 changes: 4 additions & 33 deletions cc/resources/gpu_rasterizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include <vector>

#include "cc/base/cc_export.h"
#include "cc/resources/rasterizer.h"
#include "cc/resources/resource_pool.h"
#include "cc/resources/tile.h"
#include "third_party/skia/include/core/SkMultiPictureDraw.h"
Expand All @@ -18,27 +17,11 @@ namespace cc {
class ContextProvider;
class ResourceProvider;

class CC_EXPORT GpuRasterizer : public Rasterizer {
class CC_EXPORT GpuRasterizer {
public:
~GpuRasterizer() override;
~GpuRasterizer();

static scoped_ptr<GpuRasterizer> Create(
ContextProvider* context_provider,
ResourceProvider* resource_provider,
bool use_distance_field_text,
bool threaded_gpu_rasterization_enabled,
int msaa_sample_count);

// Overriden from Rasterizer.
PrepareTilesMode GetPrepareTilesMode() override;
void RasterizeTiles(
const TileVector& tiles,
ResourcePool* resource_pool,
ResourceFormat resource_format,
const UpdateTileDrawInfoCallback& update_tile_draw_info) override;

void RasterizeSource(bool use_worker_context,
ResourceProvider::ScopedWriteLockGr* write_lock,
void RasterizeSource(ResourceProvider::ScopedWriteLockGr* write_lock,
const RasterSource* raster_source,
const gfx::Rect& rect,
float scale);
Expand All @@ -49,26 +32,14 @@ class CC_EXPORT GpuRasterizer : public Rasterizer {
GpuRasterizer(ContextProvider* context_provider,
ResourceProvider* resource_provider,
bool use_distance_filed_text,
bool threaded_gpu_rasterization_enabled,
int msaa_sample_count);

using ScopedResourceWriteLocks =
ScopedPtrVector<ResourceProvider::ScopedWriteLockGr>;

ContextProvider* GetContextProvider(bool worker_context);
void PerformSolidColorAnalysis(const Tile* tile,
RasterSource::SolidColorAnalysis* analysis);
void AddToMultiPictureDraw(const Tile* tile,
const ScopedResource* resource,
ScopedResourceWriteLocks* locks);

ResourceProvider* resource_provider_;
SkMultiPictureDraw multi_picture_draw_;

bool use_distance_field_text_;
bool threaded_gpu_rasterization_enabled_;
int msaa_sample_count_;

friend class GpuTileTaskWorkerPool;
DISALLOW_COPY_AND_ASSIGN(GpuRasterizer);
};

Expand Down
24 changes: 17 additions & 7 deletions cc/resources/gpu_tile_task_worker_pool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class RasterBufferImpl : public RasterBuffer {
context_provider->DetachFromThread();

// Rasterize source into resource.
rasterizer_->RasterizeSource(true, &lock_, raster_source, rect, scale);
rasterizer_->RasterizeSource(&lock_, raster_source, rect, scale);

// Barrier to sync worker context output to cc context.
context_provider->ContextGL()->OrderingBarrierCHROMIUM();
Expand All @@ -68,19 +68,29 @@ class RasterBufferImpl : public RasterBuffer {
scoped_ptr<TileTaskWorkerPool> GpuTileTaskWorkerPool::Create(
base::SequencedTaskRunner* task_runner,
TaskGraphRunner* task_graph_runner,
GpuRasterizer* rasterizer) {
return make_scoped_ptr<TileTaskWorkerPool>(
new GpuTileTaskWorkerPool(task_runner, task_graph_runner, rasterizer));
ContextProvider* context_provider,
ResourceProvider* resource_provider,
bool use_distance_field_text,
int gpu_rasterization_msaa_sample_count) {
return make_scoped_ptr<TileTaskWorkerPool>(new GpuTileTaskWorkerPool(
task_runner, task_graph_runner, context_provider, resource_provider,
use_distance_field_text, gpu_rasterization_msaa_sample_count));
}

GpuTileTaskWorkerPool::GpuTileTaskWorkerPool(
base::SequencedTaskRunner* task_runner,
TaskGraphRunner* task_graph_runner,
GpuRasterizer* rasterizer)
ContextProvider* context_provider,
ResourceProvider* resource_provider,
bool use_distance_field_text,
int gpu_rasterization_msaa_sample_count)
: task_runner_(task_runner),
task_graph_runner_(task_graph_runner),
namespace_token_(task_graph_runner_->GetNamespaceToken()),
rasterizer_(rasterizer),
rasterizer_(new GpuRasterizer(context_provider,
resource_provider,
use_distance_field_text,
gpu_rasterization_msaa_sample_count)),
task_set_finished_weak_ptr_factory_(this),
weak_ptr_factory_(this) {
}
Expand Down Expand Up @@ -199,7 +209,7 @@ void GpuTileTaskWorkerPool::CompleteTasks(const Task::Vector& tasks) {
scoped_ptr<RasterBuffer> GpuTileTaskWorkerPool::AcquireBufferForRaster(
const Resource* resource) {
return make_scoped_ptr<RasterBuffer>(
new RasterBufferImpl(rasterizer_, resource));
new RasterBufferImpl(rasterizer_.get(), resource));
}

void GpuTileTaskWorkerPool::ReleaseBufferForRaster(
Expand Down
14 changes: 11 additions & 3 deletions cc/resources/gpu_tile_task_worker_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
#include "cc/resources/tile_task_worker_pool.h"

namespace cc {
class ContextProvider;
class GpuRasterizer;
class ResourceProvider;

class CC_EXPORT GpuTileTaskWorkerPool : public TileTaskWorkerPool,
public TileTaskRunner,
Expand All @@ -21,7 +23,10 @@ class CC_EXPORT GpuTileTaskWorkerPool : public TileTaskWorkerPool,
static scoped_ptr<TileTaskWorkerPool> Create(
base::SequencedTaskRunner* task_runner,
TaskGraphRunner* task_graph_runner,
GpuRasterizer* rasterizer);
ContextProvider* context_provider,
ResourceProvider* resource_provider,
bool use_distance_field_text,
int gpu_rasterization_msaa_sample_count);

// Overridden from TileTaskWorkerPool:
TileTaskRunner* AsTileTaskRunner() override;
Expand All @@ -41,7 +46,10 @@ class CC_EXPORT GpuTileTaskWorkerPool : public TileTaskWorkerPool,
private:
GpuTileTaskWorkerPool(base::SequencedTaskRunner* task_runner,
TaskGraphRunner* task_graph_runner,
GpuRasterizer* rasterizer);
ContextProvider* context_provider,
ResourceProvider* resource_provider,
bool use_distance_field_text,
int gpu_rasterization_msaa_sample_count);

void OnTaskSetFinished(TaskSet task_set);
void CompleteTasks(const Task::Vector& tasks);
Expand All @@ -50,7 +58,7 @@ class CC_EXPORT GpuTileTaskWorkerPool : public TileTaskWorkerPool,
TaskGraphRunner* task_graph_runner_;
const NamespaceToken namespace_token_;
TileTaskRunnerClient* client_;
GpuRasterizer* rasterizer_;
scoped_ptr<GpuRasterizer> rasterizer_;

TaskSetCollection tasks_pending_;

Expand Down
Loading

0 comments on commit 59d4494

Please sign in to comment.