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

Side by Side Diff: cc/resources/picture.cc

Issue 15995033: cc: Low quality support for low res tiles (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/resources/picture.h" 5 #include "cc/resources/picture.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <set> 9 #include <set>
10 10
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 73
74 // Try JPEG. 74 // Try JPEG.
75 scoped_ptr<SkBitmap> decoded_jpeg(gfx::JPEGCodec::Decode(data, size)); 75 scoped_ptr<SkBitmap> decoded_jpeg(gfx::JPEGCodec::Decode(data, size));
76 if (decoded_jpeg) { 76 if (decoded_jpeg) {
77 *bm = *decoded_jpeg; 77 *bm = *decoded_jpeg;
78 return true; 78 return true;
79 } 79 }
80 return false; 80 return false;
81 } 81 }
82 82
83 class DisableLCDTextFilter : public SkDrawFilter {
84 public:
85 // SkDrawFilter interface.
86 virtual bool filter(SkPaint* paint, SkDrawFilter::Type type) OVERRIDE {
87 if (type != SkDrawFilter::kText_Type)
88 return true;
89
90 paint->setLCDRenderText(false);
91 return true;
92 }
93 };
94
95 // URI label for a lazily decoded SkPixelRef. 83 // URI label for a lazily decoded SkPixelRef.
96 const char kLabelLazyDecoded[] = "lazy"; 84 const char kLabelLazyDecoded[] = "lazy";
97 85
98 void GatherPixelRefsForRect( 86 void GatherPixelRefsForRect(
99 SkPicture* picture, 87 SkPicture* picture,
100 gfx::Rect rect, 88 gfx::Rect rect,
101 Picture::PixelRefs* pixel_refs) { 89 Picture::PixelRefs* pixel_refs) {
102 DCHECK(picture); 90 DCHECK(picture);
103 SkData* pixel_ref_data = SkPictureUtils::GatherPixelRefs( 91 SkData* pixel_ref_data = SkPictureUtils::GatherPixelRefs(
104 picture, 92 picture,
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 SkCanvas* canvas, 332 SkCanvas* canvas,
345 SkDrawPictureCallback* callback, 333 SkDrawPictureCallback* callback,
346 gfx::Rect content_rect, 334 gfx::Rect content_rect,
347 float contents_scale, 335 float contents_scale,
348 bool enable_lcd_text) { 336 bool enable_lcd_text) {
349 TRACE_EVENT_BEGIN1("cc", "Picture::Raster", 337 TRACE_EVENT_BEGIN1("cc", "Picture::Raster",
350 "data", AsTraceableRasterData(content_rect, contents_scale)); 338 "data", AsTraceableRasterData(content_rect, contents_scale));
351 339
352 DCHECK(picture_); 340 DCHECK(picture_);
353 341
354 skia::RefPtr<DisableLCDTextFilter> disable_lcd_text_filter;
355
356 canvas->save(); 342 canvas->save();
357 canvas->clipRect(gfx::RectToSkRect(content_rect)); 343 canvas->clipRect(gfx::RectToSkRect(content_rect));
358 canvas->scale(contents_scale, contents_scale); 344 canvas->scale(contents_scale, contents_scale);
359 canvas->translate(layer_rect_.x(), layer_rect_.y()); 345 canvas->translate(layer_rect_.x(), layer_rect_.y());
360 // Pictures by default have LCD text enabled.
361 if (!enable_lcd_text) {
362 disable_lcd_text_filter = skia::AdoptRef(new DisableLCDTextFilter);
363 canvas->setDrawFilter(disable_lcd_text_filter.get());
364 }
365 picture_->draw(canvas, callback); 346 picture_->draw(canvas, callback);
366 SkIRect bounds; 347 SkIRect bounds;
367 canvas->getClipDeviceBounds(&bounds); 348 canvas->getClipDeviceBounds(&bounds);
368 canvas->restore(); 349 canvas->restore();
369 TRACE_EVENT_END1("cc", "Picture::Raster", 350 TRACE_EVENT_END1("cc", "Picture::Raster",
370 "num_pixels_rasterized", bounds.width() * bounds.height()); 351 "num_pixels_rasterized", bounds.width() * bounds.height());
371 } 352 }
372 353
373 scoped_ptr<Value> Picture::AsValue() const { 354 scoped_ptr<Value> Picture::AsValue() const {
374 SkDynamicMemoryWStream stream; 355 SkDynamicMemoryWStream stream;
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 raster_data->Set("picture_id", TracedValue::CreateIDRef(this).release()); 476 raster_data->Set("picture_id", TracedValue::CreateIDRef(this).release());
496 raster_data->SetDouble("scale", scale); 477 raster_data->SetDouble("scale", scale);
497 raster_data->SetDouble("rect_x", rect.x()); 478 raster_data->SetDouble("rect_x", rect.x());
498 raster_data->SetDouble("rect_y", rect.y()); 479 raster_data->SetDouble("rect_y", rect.y());
499 raster_data->SetDouble("rect_width", rect.width()); 480 raster_data->SetDouble("rect_width", rect.width());
500 raster_data->SetDouble("rect_height", rect.height()); 481 raster_data->SetDouble("rect_height", rect.height());
501 return TracedValue::FromValue(raster_data.release()); 482 return TracedValue::FromValue(raster_data.release());
502 } 483 }
503 484
504 } // namespace cc 485 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698