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

Side by Side Diff: android_webview/browser/browser_view_renderer.cc

Issue 251843005: Fixing Chromium Android build's reliance on old SkPicture recording API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed code review issues Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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 "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
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 return picture; 151 return skia::AdoptRef(new SkPicture);
152 } 152 }
153 153
154 // Reset scroll back to the origin, will go back to the old 154 // Reset scroll back to the origin, will go back to the old
155 // value when scroll_reset is out of scope. 155 // value when scroll_reset is out of scope.
156 AutoResetWithLock scroll_reset( 156 AutoResetWithLock scroll_reset(
157 &scroll_offset_dip_, gfx::Vector2dF(), scroll_offset_dip_lock_); 157 &scroll_offset_dip_, gfx::Vector2dF(), scroll_offset_dip_lock_);
158 158
159 SkCanvas* rec_canvas = picture->beginRecording(width, height, 0); 159 SkPictureRecorder recorder;
160 SkCanvas* rec_canvas = recorder.beginRecording(width, height, NULL, 0);
160 if (has_compositor_) 161 if (has_compositor_)
161 CompositeSW(rec_canvas); 162 CompositeSW(rec_canvas);
162 picture->endRecording(); 163 return skia::AdoptRef(recorder.endRecording());
163 return picture;
164 } 164 }
165 165
166 void BrowserViewRenderer::EnableOnNewPicture(bool enabled) { 166 void BrowserViewRenderer::EnableOnNewPicture(bool enabled) {
167 on_new_picture_enable_ = enabled; 167 on_new_picture_enable_ = enabled;
168 } 168 }
169 169
170 void BrowserViewRenderer::ClearView() { 170 void BrowserViewRenderer::ClearView() {
171 TRACE_EVENT_INSTANT0("android_webview", 171 TRACE_EVENT_INSTANT0("android_webview",
172 "BrowserViewRenderer::ClearView", 172 "BrowserViewRenderer::ClearView",
173 TRACE_EVENT_SCOPE_THREAD); 173 TRACE_EVENT_SCOPE_THREAD);
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 base::StringAppendF(&str, 598 base::StringAppendF(&str,
599 "surface width height: [%d %d] ", 599 "surface width height: [%d %d] ",
600 draw_info->width, 600 draw_info->width,
601 draw_info->height); 601 draw_info->height);
602 base::StringAppendF(&str, "is_layer: %d ", draw_info->is_layer); 602 base::StringAppendF(&str, "is_layer: %d ", draw_info->is_layer);
603 } 603 }
604 return str; 604 return str;
605 } 605 }
606 606
607 } // namespace android_webview 607 } // namespace android_webview
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698