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

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

Issue 16796002: Delete the browser-compositor webview render mode (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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
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/browser/in_process_view_renderer.h" 5 #include "android_webview/browser/in_process_view_renderer.h"
6 6
7 #include <android/bitmap.h> 7 #include <android/bitmap.h>
8 8
9 #include "android_webview/public/browser/draw_gl.h" 9 #include "android_webview/public/browser/draw_gl.h"
10 #include "android_webview/public/browser/draw_sw.h" 10 #include "android_webview/public/browser/draw_sw.h"
11 #include "base/android/jni_android.h" 11 #include "base/android/jni_android.h"
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/debug/trace_event.h" 13 #include "base/debug/trace_event.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "content/public/browser/android/content_view_core.h" 15 #include "content/public/browser/android/content_view_core.h"
16 #include "content/public/browser/android/synchronous_compositor.h" 16 #include "content/public/browser/android/synchronous_compositor.h"
17 #include "content/public/browser/render_view_host.h" 17 #include "content/public/browser/render_view_host.h"
18 #include "content/public/browser/web_contents.h" 18 #include "content/public/browser/web_contents.h"
19 #include "skia/ext/refptr.h"
19 #include "third_party/skia/include/core/SkBitmap.h" 20 #include "third_party/skia/include/core/SkBitmap.h"
20 #include "third_party/skia/include/core/SkCanvas.h" 21 #include "third_party/skia/include/core/SkCanvas.h"
21 #include "third_party/skia/include/core/SkDevice.h" 22 #include "third_party/skia/include/core/SkDevice.h"
22 #include "third_party/skia/include/core/SkGraphics.h" 23 #include "third_party/skia/include/core/SkGraphics.h"
23 #include "third_party/skia/include/core/SkPicture.h" 24 #include "third_party/skia/include/core/SkPicture.h"
24 #include "ui/gfx/size_conversions.h" 25 #include "ui/gfx/size_conversions.h"
25 #include "ui/gfx/transform.h" 26 #include "ui/gfx/transform.h"
26 #include "ui/gfx/vector2d_f.h" 27 #include "ui/gfx/vector2d_f.h"
27 #include "ui/gl/gl_bindings.h" 28 #include "ui/gl/gl_bindings.h"
28 29
29 // TODO(leandrogracia): Borrowed from gl2ext.h. Cannot be included due to 30 // TODO(leandrogracia): Borrowed from gl2ext.h. Cannot be included due to
30 // conflicts with gl_bindings.h and the EGL library methods 31 // conflicts with gl_bindings.h and the EGL library methods
31 // (eglGetCurrentContext). 32 // (eglGetCurrentContext).
32 #ifndef GL_TEXTURE_EXTERNAL_OES 33 #ifndef GL_TEXTURE_EXTERNAL_OES
33 #define GL_TEXTURE_EXTERNAL_OES 0x8D65 34 #define GL_TEXTURE_EXTERNAL_OES 0x8D65
34 #endif 35 #endif
35 36
36 #ifndef GL_TEXTURE_BINDING_EXTERNAL_OES 37 #ifndef GL_TEXTURE_BINDING_EXTERNAL_OES
37 #define GL_TEXTURE_BINDING_EXTERNAL_OES 0x8D67 38 #define GL_TEXTURE_BINDING_EXTERNAL_OES 0x8D67
38 #endif 39 #endif
39 40
40 using base::android::AttachCurrentThread; 41 using base::android::AttachCurrentThread;
41 using base::android::JavaRef; 42 using base::android::JavaRef;
42 using base::android::ScopedJavaLocalRef; 43 using base::android::ScopedJavaLocalRef;
43 using content::Compositor;
44 using content::ContentViewCore; 44 using content::ContentViewCore;
45 45
46 namespace android_webview { 46 namespace android_webview {
47 47
48 namespace { 48 namespace {
49 49
50 class GLStateRestore { 50 class GLStateRestore {
51 public: 51 public:
52 GLStateRestore() { 52 GLStateRestore() {
53 #if !defined(NDEBUG) 53 #if !defined(NDEBUG)
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 bool RenderPictureToCanvas(SkPicture* picture, SkCanvas* canvas) { 255 bool RenderPictureToCanvas(SkPicture* picture, SkCanvas* canvas) {
256 canvas->drawPicture(*picture); 256 canvas->drawPicture(*picture);
257 return true; 257 return true;
258 } 258 }
259 259
260 // TODO(boliu): Remove this when hardware mode is ready. 260 // TODO(boliu): Remove this when hardware mode is ready.
261 bool HardwareEnabled() { 261 bool HardwareEnabled() {
262 return CommandLine::ForCurrentProcess()->HasSwitch("testing-webview-gl-mode"); 262 return CommandLine::ForCurrentProcess()->HasSwitch("testing-webview-gl-mode");
263 } 263 }
264 264
265 // Provides software rendering functions from the Android glue layer.
266 // Allows preventing extra copies of data when rendering.
267 AwDrawSWFunctionTable* g_sw_draw_functions = NULL;
268
269 // Tells if the Skia library versions in Android and Chromium are compatible.
270 // If they are then it's possible to pass Skia objects like SkPictures to the
271 // Android glue layer via the SW rendering functions.
272 // If they are not, then additional copies and rasterizations are required
273 // as a fallback mechanism, which will have an important performance impact.
274 bool g_is_skia_version_compatible = false;
275
265 } // namespace 276 } // namespace
266 277
278 // static
279 void BrowserViewRenderer::SetAwDrawSWFunctionTable(
280 AwDrawSWFunctionTable* table) {
281 g_sw_draw_functions = table;
282 g_is_skia_version_compatible =
283 g_sw_draw_functions->is_skia_version_compatible(&SkGraphics::GetVersion);
284 LOG_IF(WARNING, !g_is_skia_version_compatible)
285 << "Skia versions are not compatible, rendering performance will suffer.";
286 }
287
288 // static
289 AwDrawSWFunctionTable* BrowserViewRenderer::GetAwDrawSWFunctionTable() {
290 return g_sw_draw_functions;
291 }
292
293 // static
294 bool BrowserViewRenderer::IsSkiaVersionCompatible() {
295 DCHECK(g_sw_draw_functions);
296 return g_is_skia_version_compatible;
297 }
298
267 InProcessViewRenderer::InProcessViewRenderer( 299 InProcessViewRenderer::InProcessViewRenderer(
268 BrowserViewRenderer::Client* client, 300 BrowserViewRenderer::Client* client,
269 JavaHelper* java_helper) 301 JavaHelper* java_helper)
270 : client_(client), 302 : client_(client),
271 java_helper_(java_helper), 303 java_helper_(java_helper),
272 web_contents_(NULL), 304 web_contents_(NULL),
273 compositor_(NULL), 305 compositor_(NULL),
274 view_visible_(false), 306 view_visible_(false),
275 continuous_invalidate_(false), 307 continuous_invalidate_(false),
276 continuous_invalidate_task_pending_(false), 308 continuous_invalidate_task_pending_(false),
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 // TODO(joth): BrowserViewRendererImpl had a bunch of logic for dpi and page 630 // TODO(joth): BrowserViewRendererImpl had a bunch of logic for dpi and page
599 // scale here. Determine what if any needs bringing over to this class. 631 // scale here. Determine what if any needs bringing over to this class.
600 return CompositeSW(canvas); 632 return CompositeSW(canvas);
601 } 633 }
602 634
603 bool InProcessViewRenderer::CompositeSW(SkCanvas* canvas) { 635 bool InProcessViewRenderer::CompositeSW(SkCanvas* canvas) {
604 return compositor_ && compositor_->DemandDrawSw(canvas); 636 return compositor_ && compositor_->DemandDrawSw(canvas);
605 } 637 }
606 638
607 } // namespace android_webview 639 } // namespace android_webview
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698