Commit ba7b16f7 authored by reed's avatar reed Committed by Commit bot

use picture->cullRect instead of (deprecated) width/height

BUG=

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

Cr-Commit-Position: refs/heads/master@{#308198}
parent b65dfa3e
...@@ -23,17 +23,18 @@ void AwPicture::Destroy(JNIEnv* env, jobject obj) { ...@@ -23,17 +23,18 @@ void AwPicture::Destroy(JNIEnv* env, jobject obj) {
} }
jint AwPicture::GetWidth(JNIEnv* env, jobject obj) { jint AwPicture::GetWidth(JNIEnv* env, jobject obj) {
return picture_->width(); return picture_->cullRect().roundOut().width();
} }
jint AwPicture::GetHeight(JNIEnv* env, jobject obj) { jint AwPicture::GetHeight(JNIEnv* env, jobject obj) {
return picture_->height(); return picture_->cullRect().roundOut().height();
} }
void AwPicture::Draw(JNIEnv* env, jobject obj, jobject canvas) { void AwPicture::Draw(JNIEnv* env, jobject obj, jobject canvas) {
const SkIRect bounds = picture_->cullRect().roundOut();
scoped_ptr<SoftwareCanvasHolder> canvas_holder = SoftwareCanvasHolder::Create( scoped_ptr<SoftwareCanvasHolder> canvas_holder = SoftwareCanvasHolder::Create(
canvas, gfx::Vector2d(), canvas, gfx::Vector2d(),
gfx::Size(picture_->width(), picture_->height())); gfx::Size(bounds.width(), bounds.height()));
if (!canvas_holder || !canvas_holder->GetCanvas()) { if (!canvas_holder || !canvas_holder->GetCanvas()) {
LOG(ERROR) << "Couldn't draw picture"; LOG(ERROR) << "Couldn't draw picture";
return; return;
......
...@@ -121,7 +121,7 @@ scoped_refptr<Picture> Picture::CreateFromSkpValue(const base::Value* value) { ...@@ -121,7 +121,7 @@ scoped_refptr<Picture> Picture::CreateFromSkpValue(const base::Value* value) {
if (skpicture == NULL) if (skpicture == NULL)
return NULL; return NULL;
gfx::Rect layer_rect(skpicture->width(), skpicture->height()); gfx::Rect layer_rect(gfx::SkIRectToRect(skpicture->cullRect().roundOut()));
return make_scoped_refptr(new Picture(skpicture, layer_rect)); return make_scoped_refptr(new Picture(skpicture, layer_rect));
} }
......
...@@ -265,9 +265,11 @@ SK_API void SkDebugf_FileLine(const char* file, int line, bool fatal, ...@@ -265,9 +265,11 @@ SK_API void SkDebugf_FileLine(const char* file, int line, bool fatal,
# define SK_IGNORE_GPU_DITHER # define SK_IGNORE_GPU_DITHER
#endif #endif
#if 0
#ifndef SK_LEGACY_PICTURE_SIZE_API #ifndef SK_LEGACY_PICTURE_SIZE_API
# define SK_LEGACY_PICTURE_SIZE_API # define SK_LEGACY_PICTURE_SIZE_API
#endif #endif
#endif
#ifndef SK_LEGACY_PICTURE_DRAW_API #ifndef SK_LEGACY_PICTURE_DRAW_API
# define SK_LEGACY_PICTURE_DRAW_API # define SK_LEGACY_PICTURE_DRAW_API
......
...@@ -351,15 +351,17 @@ void PixelRefUtils::GatherDiscardablePixelRefs( ...@@ -351,15 +351,17 @@ void PixelRefUtils::GatherDiscardablePixelRefs(
pixel_refs->clear(); pixel_refs->clear();
DiscardablePixelRefSet pixel_ref_set(pixel_refs); DiscardablePixelRefSet pixel_ref_set(pixel_refs);
SkRect picture_bounds = picture->cullRect();
SkIRect picture_ibounds = picture_bounds.roundOut();
SkBitmap empty_bitmap; SkBitmap empty_bitmap;
empty_bitmap.setInfo(SkImageInfo::MakeUnknown(picture->width(), picture->height())); empty_bitmap.setInfo(SkImageInfo::MakeUnknown(picture_ibounds.width(),
picture_ibounds.height()));
GatherPixelRefDevice device(empty_bitmap, &pixel_ref_set); GatherPixelRefDevice device(empty_bitmap, &pixel_ref_set);
SkNoSaveLayerCanvas canvas(&device); SkNoSaveLayerCanvas canvas(&device);
canvas.clipRect(SkRect::MakeWH(picture->width(), picture->height()), // Draw the picture pinned against our top/left corner.
SkRegion::kIntersect_Op, canvas.translate(-picture_bounds.left(), -picture_bounds.top());
false);
canvas.drawPicture(picture); canvas.drawPicture(picture);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment