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

Side by Side Diff: android_webview/native/aw_picture.cc

Issue 797753003: use picture->cullRect instead of (deprecated) width/height (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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 | « no previous file | cc/resources/picture.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "android_webview/native/aw_picture.h" 5 #include "android_webview/native/aw_picture.h"
6 6
7 #include "android_webview/native/java_browser_view_renderer_helper.h" 7 #include "android_webview/native/java_browser_view_renderer_helper.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "jni/AwPicture_jni.h" 9 #include "jni/AwPicture_jni.h"
10 #include "third_party/skia/include/core/SkPicture.h" 10 #include "third_party/skia/include/core/SkPicture.h"
11 11
12 namespace android_webview { 12 namespace android_webview {
13 13
14 AwPicture::AwPicture(skia::RefPtr<SkPicture> picture) 14 AwPicture::AwPicture(skia::RefPtr<SkPicture> picture)
15 : picture_(picture) { 15 : picture_(picture) {
16 DCHECK(picture_); 16 DCHECK(picture_);
17 } 17 }
18 18
19 AwPicture::~AwPicture() {} 19 AwPicture::~AwPicture() {}
20 20
21 void AwPicture::Destroy(JNIEnv* env, jobject obj) { 21 void AwPicture::Destroy(JNIEnv* env, jobject obj) {
22 delete this; 22 delete this;
23 } 23 }
24 24
25 jint AwPicture::GetWidth(JNIEnv* env, jobject obj) { 25 jint AwPicture::GetWidth(JNIEnv* env, jobject obj) {
26 return picture_->width(); 26 return picture_->cullRect().roundOut().width();
27 } 27 }
28 28
29 jint AwPicture::GetHeight(JNIEnv* env, jobject obj) { 29 jint AwPicture::GetHeight(JNIEnv* env, jobject obj) {
30 return picture_->height(); 30 return picture_->cullRect().roundOut().height();
31 } 31 }
32 32
33 void AwPicture::Draw(JNIEnv* env, jobject obj, jobject canvas) { 33 void AwPicture::Draw(JNIEnv* env, jobject obj, jobject canvas) {
34 const SkIRect bounds = picture_->cullRect().roundOut();
34 scoped_ptr<SoftwareCanvasHolder> canvas_holder = SoftwareCanvasHolder::Create( 35 scoped_ptr<SoftwareCanvasHolder> canvas_holder = SoftwareCanvasHolder::Create(
35 canvas, gfx::Vector2d(), 36 canvas, gfx::Vector2d(),
36 gfx::Size(picture_->width(), picture_->height())); 37 gfx::Size(bounds.width(), bounds.height()));
37 if (!canvas_holder || !canvas_holder->GetCanvas()) { 38 if (!canvas_holder || !canvas_holder->GetCanvas()) {
38 LOG(ERROR) << "Couldn't draw picture"; 39 LOG(ERROR) << "Couldn't draw picture";
39 return; 40 return;
40 } 41 }
41 picture_->draw(canvas_holder->GetCanvas()); 42 picture_->draw(canvas_holder->GetCanvas());
42 } 43 }
43 44
44 bool RegisterAwPicture(JNIEnv* env) { 45 bool RegisterAwPicture(JNIEnv* env) {
45 return RegisterNativesImpl(env); 46 return RegisterNativesImpl(env);
46 } 47 }
47 48
48 } // namespace android_webview 49 } // namespace android_webview
OLDNEW
« no previous file with comments | « no previous file | cc/resources/picture.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698