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

Side by Side Diff: skia/ext/pixel_ref_utils.cc

Issue 1303033002: asABitmap is deprecated, switch over to (simpler) isABitmap (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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
« no previous file with comments | « cc/raster/tile_task_worker_pool.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "skia/ext/pixel_ref_utils.h" 5 #include "skia/ext/pixel_ref_utils.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "third_party/skia/include/core/SkBitmapDevice.h" 9 #include "third_party/skia/include/core/SkBitmapDevice.h"
10 #include "third_party/skia/include/core/SkCanvas.h" 10 #include "third_party/skia/include/core/SkCanvas.h"
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 const SkMatrix& matrix, 355 const SkMatrix& matrix,
356 SkFilterQuality filter_quality) { 356 SkFilterQuality filter_quality) {
357 SkRect canvas_rect = SkRect::MakeWH(width(), height()); 357 SkRect canvas_rect = SkRect::MakeWH(width(), height());
358 if (rect.intersects(canvas_rect)) { 358 if (rect.intersects(canvas_rect)) {
359 pixel_ref_set_->Add(bm.pixelRef(), rect, matrix, filter_quality); 359 pixel_ref_set_->Add(bm.pixelRef(), rect, matrix, filter_quality);
360 } 360 }
361 } 361 }
362 362
363 bool GetBitmapFromPaint(const SkPaint& paint, SkBitmap* bm) { 363 bool GetBitmapFromPaint(const SkPaint& paint, SkBitmap* bm) {
364 SkShader* shader = paint.getShader(); 364 SkShader* shader = paint.getShader();
365 if (shader) { 365 return shader && shader->isABitmap(bm, NULL, NULL);
366 // Check whether the shader is a gradient in order to prevent generation
367 // of bitmaps from gradient shaders, which implement asABitmap.
368 if (SkShader::kNone_GradientType == shader->asAGradient(NULL))
369 return shader->asABitmap(bm, NULL, NULL);
370 }
371 return false;
372 } 366 }
373 }; 367 };
374 368
375 } // namespace 369 } // namespace
376 370
377 void PixelRefUtils::GatherDiscardablePixelRefs( 371 void PixelRefUtils::GatherDiscardablePixelRefs(
378 SkPicture* picture, 372 SkPicture* picture,
379 std::vector<PositionPixelRef>* pixel_refs) { 373 std::vector<PositionPixelRef>* pixel_refs) {
380 pixel_refs->clear(); 374 pixel_refs->clear();
381 DiscardablePixelRefSet pixel_ref_set(pixel_refs); 375 DiscardablePixelRefSet pixel_ref_set(pixel_refs);
382 376
383 SkRect picture_bounds = picture->cullRect(); 377 SkRect picture_bounds = picture->cullRect();
384 SkIRect picture_ibounds = picture_bounds.roundOut(); 378 SkIRect picture_ibounds = picture_bounds.roundOut();
385 SkBitmap empty_bitmap; 379 SkBitmap empty_bitmap;
386 // Use right/bottom as the size so that we don't need a translate and, as a 380 // Use right/bottom as the size so that we don't need a translate and, as a
387 // result, the information is returned relative to the picture's origin. 381 // result, the information is returned relative to the picture's origin.
388 empty_bitmap.setInfo(SkImageInfo::MakeUnknown(picture_ibounds.right(), 382 empty_bitmap.setInfo(SkImageInfo::MakeUnknown(picture_ibounds.right(),
389 picture_ibounds.bottom())); 383 picture_ibounds.bottom()));
390 384
391 GatherPixelRefDevice device(empty_bitmap, &pixel_ref_set); 385 GatherPixelRefDevice device(empty_bitmap, &pixel_ref_set);
392 SkNoSaveLayerCanvas canvas(&device); 386 SkNoSaveLayerCanvas canvas(&device);
393 387
394 canvas.drawPicture(picture); 388 canvas.drawPicture(picture);
395 } 389 }
396 390
397 } // namespace skia 391 } // namespace skia
OLDNEW
« no previous file with comments | « cc/raster/tile_task_worker_pool.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698