OLD | NEW |
---|---|
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 "android_webview/browser/browser_view_renderer.h" | 5 #include "android_webview/browser/browser_view_renderer.h" |
6 | 6 |
7 #include "android_webview/browser/browser_view_renderer_client.h" | 7 #include "android_webview/browser/browser_view_renderer_client.h" |
8 #include "android_webview/browser/shared_renderer_state.h" | 8 #include "android_webview/browser/shared_renderer_state.h" |
9 #include "android_webview/public/browser/draw_gl.h" | 9 #include "android_webview/public/browser/draw_gl.h" |
10 #include "base/android/jni_android.h" | 10 #include "base/android/jni_android.h" |
11 #include "base/auto_reset.h" | 11 #include "base/auto_reset.h" |
12 #include "base/debug/trace_event.h" | 12 #include "base/debug/trace_event.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
15 #include "content/public/browser/android/synchronous_compositor.h" | 15 #include "content/public/browser/android/synchronous_compositor.h" |
16 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
17 #include "third_party/skia/include/core/SkBitmap.h" | 17 #include "third_party/skia/include/core/SkBitmap.h" |
18 #include "third_party/skia/include/core/SkCanvas.h" | 18 #include "third_party/skia/include/core/SkCanvas.h" |
19 #include "third_party/skia/include/core/SkPicture.h" | 19 #include "third_party/skia/include/core/SkPicture.h" |
20 #include "third_party/skia/include/core/SkPictureRecorder.h" | |
20 #include "ui/gfx/vector2d_conversions.h" | 21 #include "ui/gfx/vector2d_conversions.h" |
21 | 22 |
22 using base::android::AttachCurrentThread; | 23 using base::android::AttachCurrentThread; |
23 using base::android::JavaRef; | 24 using base::android::JavaRef; |
24 using base::android::ScopedJavaLocalRef; | 25 using base::android::ScopedJavaLocalRef; |
25 | 26 |
26 namespace android_webview { | 27 namespace android_webview { |
27 | 28 |
28 namespace { | 29 namespace { |
29 | 30 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
139 clip, | 140 clip, |
140 base::Bind(&BrowserViewRenderer::CompositeSW, | 141 base::Bind(&BrowserViewRenderer::CompositeSW, |
141 base::Unretained(this))); | 142 base::Unretained(this))); |
142 } | 143 } |
143 | 144 |
144 skia::RefPtr<SkPicture> BrowserViewRenderer::CapturePicture(int width, | 145 skia::RefPtr<SkPicture> BrowserViewRenderer::CapturePicture(int width, |
145 int height) { | 146 int height) { |
146 TRACE_EVENT0("android_webview", "BrowserViewRenderer::CapturePicture"); | 147 TRACE_EVENT0("android_webview", "BrowserViewRenderer::CapturePicture"); |
147 | 148 |
148 // Return empty Picture objects for empty SkPictures. | 149 // Return empty Picture objects for empty SkPictures. |
149 skia::RefPtr<SkPicture> picture = skia::AdoptRef(new SkPicture); | |
150 if (width <= 0 || height <= 0) { | 150 if (width <= 0 || height <= 0) { |
151 skia::RefPtr<SkPicture> picture = skia::AdoptRef(new SkPicture); | |
151 return picture; | 152 return picture; |
152 } | 153 } |
153 | 154 |
154 // Reset scroll back to the origin, will go back to the old | 155 // Reset scroll back to the origin, will go back to the old |
155 // value when scroll_reset is out of scope. | 156 // value when scroll_reset is out of scope. |
156 AutoResetWithLock scroll_reset( | 157 AutoResetWithLock scroll_reset( |
157 &scroll_offset_dip_, gfx::Vector2dF(), scroll_offset_dip_lock_); | 158 &scroll_offset_dip_, gfx::Vector2dF(), scroll_offset_dip_lock_); |
158 | 159 |
159 SkCanvas* rec_canvas = picture->beginRecording(width, height, 0); | 160 SkPictureRecorder recorder; |
161 SkCanvas* rec_canvas = recorder.beginRecording(width, height, NULL, 0); | |
160 if (has_compositor_) | 162 if (has_compositor_) |
161 CompositeSW(rec_canvas); | 163 CompositeSW(rec_canvas); |
162 picture->endRecording(); | 164 skia::RefPtr<SkPicture> picture(skia::AdoptRef(recorder.endRecording())); |
f(malita)
2014/04/29 17:26:59
return skia::AdoptRef(recorder.endRecording());
robertphillips
2014/04/29 19:14:31
Done.
| |
163 return picture; | 165 return picture; |
164 } | 166 } |
165 | 167 |
166 void BrowserViewRenderer::EnableOnNewPicture(bool enabled) { | 168 void BrowserViewRenderer::EnableOnNewPicture(bool enabled) { |
167 on_new_picture_enable_ = enabled; | 169 on_new_picture_enable_ = enabled; |
168 } | 170 } |
169 | 171 |
170 void BrowserViewRenderer::ClearView() { | 172 void BrowserViewRenderer::ClearView() { |
171 TRACE_EVENT_INSTANT0("android_webview", | 173 TRACE_EVENT_INSTANT0("android_webview", |
172 "BrowserViewRenderer::ClearView", | 174 "BrowserViewRenderer::ClearView", |
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
598 base::StringAppendF(&str, | 600 base::StringAppendF(&str, |
599 "surface width height: [%d %d] ", | 601 "surface width height: [%d %d] ", |
600 draw_info->width, | 602 draw_info->width, |
601 draw_info->height); | 603 draw_info->height); |
602 base::StringAppendF(&str, "is_layer: %d ", draw_info->is_layer); | 604 base::StringAppendF(&str, "is_layer: %d ", draw_info->is_layer); |
603 } | 605 } |
604 return str; | 606 return str; |
605 } | 607 } |
606 | 608 |
607 } // namespace android_webview | 609 } // namespace android_webview |
OLD | NEW |