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

Unified Diff: cc/resources/raster_worker_pool.cc

Issue 21159007: cc: Adding support for RGBA_4444 tile textures (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix raster-on-demand codepath Created 7 years, 3 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
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..f5c795520db7d67c4ac1a65008d5c02c3ab406a6 100644
--- a/cc/resources/raster_worker_pool.cc
+++ b/cc/resources/raster_worker_pool.cc
@@ -13,11 +13,25 @@
#include "cc/resources/picture_pile_impl.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;
@@ -48,7 +62,8 @@ class RasterWorkerPoolTaskImpl : public internal::RasterWorkerPoolTask {
int source_frame_number,
RenderingStatsInstrumentation* rendering_stats,
const RasterWorkerPool::RasterTask::Reply& reply,
- TaskVector* dependencies)
+ TaskVector* dependencies,
+ bool use_16bit_tiles)
: internal::RasterWorkerPoolTask(resource, dependencies),
picture_pile_(picture_pile),
content_rect_(content_rect),
@@ -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),
+ use_16bit_tiles_(use_16bit_tiles) {}
void RunAnalysisOnThread(unsigned thread_index) {
TRACE_EVENT1("cc",
@@ -89,7 +105,9 @@ 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) {
TRACE_EVENT2(
benchmark_instrumentation::kCategory,
benchmark_instrumentation::kRunRasterOnThread,
@@ -102,7 +120,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 +128,14 @@ class RasterWorkerPoolTaskImpl : public internal::RasterWorkerPoolTask {
PicturePileImpl* picture_clone =
picture_pile_->GetCloneForDrawingOnThread(thread_index);
- SkCanvas canvas(device);
+ SkBitmap bitmap_32;
Sami 2013/09/05 14:13:26 If we gave this function an SkBitmapDevice instead
kaanb 2013/09/06 02:05:54 Apparently getPixelRef is protected not public, so
+ bitmap_32.setConfig(SkBitmap::kARGB_8888_Config,
+ size.width(),
+ size.height());
+ bitmap_32.allocPixels();
reveman 2013/09/05 16:24:17 we shouldn't be allocating a temporary bitmap unle
kaanb 2013/09/06 02:05:54 Good point. Fixed.
+ SkBitmapDevice device_32(bitmap_32);
+ SkCanvas canvas(&device_32);
skia::RefPtr<SkDrawFilter> draw_filter;
switch (raster_mode_) {
case LOW_QUALITY_RASTER_MODE:
@@ -149,14 +173,23 @@ class RasterWorkerPoolTaskImpl : public internal::RasterWorkerPoolTask {
picture_clone->RasterToBitmap(
&canvas, content_rect_, contents_scale_, NULL);
}
+
+ if (use_16bit_tiles_) {
+ SkBitmap bitmap_16;
+ IdentityAllocator allocator(buffer);
+ bitmap_32.copyTo(&bitmap_16, SkBitmap::kARGB_4444_Config, &allocator);
enne (OOO) 2013/09/05 02:01:19 Just to be clear, this is copying from the 8888 bi
Sami 2013/09/05 14:13:26 If I read this right we're copying from bitmap_32
kaanb 2013/09/06 02:05:54 Also, note that we want the destination of the buf
kaanb 2013/09/06 02:05:54 Actually 8888 bitmap uses temporary heap memory in
+ }
+
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)
OVERRIDE {
RunAnalysisOnThread(thread_index);
- return RunRasterOnThread(device, thread_index);
+ return RunRasterOnThread(thread_index, buffer, size);
}
virtual void CompleteOnOriginThread() OVERRIDE {
reply_.Run(analysis_, !HasFinishedRunning() || WasCanceled());
@@ -189,6 +222,7 @@ class RasterWorkerPoolTaskImpl : public internal::RasterWorkerPoolTask {
int source_frame_number_;
RenderingStatsInstrumentation* rendering_stats_;
const RasterWorkerPool::RasterTask::Reply reply_;
+ bool use_16bit_tiles_;
DISALLOW_COPY_AND_ASSIGN(RasterWorkerPoolTaskImpl);
};
@@ -379,7 +413,8 @@ RasterWorkerPool::RasterTask RasterWorkerPool::CreateRasterTask(
int source_frame_number,
RenderingStatsInstrumentation* rendering_stats,
const RasterTask::Reply& reply,
- Task::Set* dependencies) {
+ Task::Set* dependencies,
+ bool use_16bit_tiles) {
return RasterTask(
new RasterWorkerPoolTaskImpl(resource,
picture_pile,
@@ -393,7 +428,8 @@ RasterWorkerPool::RasterTask RasterWorkerPool::CreateRasterTask(
source_frame_number,
rendering_stats,
reply,
- &dependencies->tasks_));
+ &dependencies->tasks_,
+ use_16bit_tiles));
}
// static

Powered by Google App Engine
This is Rietveld 408576698