| Index: cc/resources/raster_worker_pool.cc
|
| diff --git a/cc/resources/raster_worker_pool.cc b/cc/resources/raster_worker_pool.cc
|
| index 15b8aa41133312b094cec77d073ab1c5c954e41f..777df0aa935dfeb88f863aff6e249777b436df18 100644
|
| --- a/cc/resources/raster_worker_pool.cc
|
| +++ b/cc/resources/raster_worker_pool.cc
|
| @@ -11,13 +11,28 @@
|
| #include "cc/debug/devtools_instrumentation.h"
|
| #include "cc/debug/traced_value.h"
|
| #include "cc/resources/picture_pile_impl.h"
|
| +#include "cc/resources/resource_provider.h"
|
| #include "skia/ext/lazy_pixel_ref.h"
|
| #include "skia/ext/paint_simplifier.h"
|
| +#include "third_party/skia/include/core/SkBitmap.h"
|
|
|
| namespace cc {
|
|
|
| namespace {
|
|
|
| +// Subclass of Allocator that takes a suitably allocated pointer and uses
|
| +// it as the pixel memory for the bitmap.
|
| +class IdentityAllocator : public SkBitmap::Allocator {
|
| + public:
|
| + explicit IdentityAllocator(void* buffer) : buffer_(buffer) {}
|
| + virtual bool allocPixelRef(SkBitmap* dst, SkColorTable*) OVERRIDE {
|
| + dst->setPixels(buffer_);
|
| + return true;
|
| + }
|
| + private:
|
| + void* buffer_;
|
| +};
|
| +
|
| // Flag to indicate whether we should try and detect that
|
| // a tile is of solid color.
|
| const bool kUseColorEstimator = true;
|
| @@ -60,7 +75,8 @@ class RasterWorkerPoolTaskImpl : public internal::RasterWorkerPoolTask {
|
| tile_id_(tile_id),
|
| source_frame_number_(source_frame_number),
|
| rendering_stats_(rendering_stats),
|
| - reply_(reply) {}
|
| + reply_(reply),
|
| + texture_format_(resource->format()) {}
|
|
|
| void RunAnalysisOnThread(unsigned thread_index) {
|
| TRACE_EVENT1("cc",
|
| @@ -89,7 +105,10 @@ class RasterWorkerPoolTaskImpl : public internal::RasterWorkerPoolTask {
|
| analysis_.is_solid_color &= kUseColorEstimator;
|
| }
|
|
|
| - bool RunRasterOnThread(SkBaseDevice* device, unsigned thread_index) {
|
| + bool RunRasterOnThread(unsigned thread_index,
|
| + void* buffer,
|
| + gfx::Size size,
|
| + int stride) {
|
| TRACE_EVENT2(
|
| benchmark_instrumentation::kCategory,
|
| benchmark_instrumentation::kRunRasterOnThread,
|
| @@ -102,7 +121,7 @@ class RasterWorkerPoolTaskImpl : public internal::RasterWorkerPoolTask {
|
| devtools_instrumentation::kRasterTask, layer_id_);
|
|
|
| DCHECK(picture_pile_.get());
|
| - DCHECK(device);
|
| + DCHECK(buffer);
|
|
|
| if (analysis_.is_solid_color)
|
| return false;
|
| @@ -110,8 +129,24 @@ class RasterWorkerPoolTaskImpl : public internal::RasterWorkerPoolTask {
|
| PicturePileImpl* picture_clone =
|
| picture_pile_->GetCloneForDrawingOnThread(thread_index);
|
|
|
| - SkCanvas canvas(device);
|
| + SkBitmap bitmap_32;
|
| + bitmap_32.setConfig(SkBitmap::kARGB_8888_Config,
|
| + size.width(),
|
| + size.height(),
|
| + stride);
|
| + switch (texture_format_) {
|
| + case ResourceProvider::RGBA_4444:
|
| + bitmap_32.allocPixels();
|
| + break;
|
| + case ResourceProvider::RGBA_8888:
|
| + case ResourceProvider::BGRA_8888:
|
| + case ResourceProvider::LUMINANCE_8:
|
| + bitmap_32.setPixels(buffer);
|
| + break;
|
| + }
|
|
|
| + SkBitmapDevice device_32(bitmap_32);
|
| + SkCanvas canvas(&device_32);
|
| skia::RefPtr<SkDrawFilter> draw_filter;
|
| switch (raster_mode_) {
|
| case LOW_QUALITY_RASTER_MODE:
|
| @@ -149,14 +184,24 @@ class RasterWorkerPoolTaskImpl : public internal::RasterWorkerPoolTask {
|
| picture_clone->RasterToBitmap(
|
| &canvas, content_rect_, contents_scale_, NULL);
|
| }
|
| +
|
| + if (texture_format_ == ResourceProvider::RGBA_4444) {
|
| + SkBitmap bitmap_16;
|
| + IdentityAllocator allocator(buffer);
|
| + bitmap_32.copyTo(&bitmap_16, SkBitmap::kARGB_4444_Config, &allocator);
|
| + }
|
| +
|
| return true;
|
| }
|
|
|
| // Overridden from internal::RasterWorkerPoolTask:
|
| - virtual bool RunOnWorkerThread(SkBaseDevice* device, unsigned thread_index)
|
| + virtual bool RunOnWorkerThread(unsigned thread_index,
|
| + void* buffer,
|
| + gfx::Size size,
|
| + int stride)
|
| OVERRIDE {
|
| RunAnalysisOnThread(thread_index);
|
| - return RunRasterOnThread(device, thread_index);
|
| + return RunRasterOnThread(thread_index, buffer, size, stride);
|
| }
|
| virtual void CompleteOnOriginThread() OVERRIDE {
|
| reply_.Run(analysis_, !HasFinishedRunning() || WasCanceled());
|
| @@ -189,6 +234,7 @@ class RasterWorkerPoolTaskImpl : public internal::RasterWorkerPoolTask {
|
| int source_frame_number_;
|
| RenderingStatsInstrumentation* rendering_stats_;
|
| const RasterWorkerPool::RasterTask::Reply reply_;
|
| + ResourceProvider::Format texture_format_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(RasterWorkerPoolTaskImpl);
|
| };
|
|
|