OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/java_browser_view_renderer_helper.h" | 5 #include "android_webview/native/java_browser_view_renderer_helper.h" |
6 | 6 |
7 #include <android/bitmap.h> | 7 #include <android/bitmap.h> |
8 | 8 |
| 9 #include "android_webview/common/aw_switches.h" |
9 #include "android_webview/public/browser/draw_sw.h" | 10 #include "android_webview/public/browser/draw_sw.h" |
10 #include "base/debug/trace_event.h" | 11 #include "base/debug/trace_event.h" |
11 #include "jni/JavaBrowserViewRendererHelper_jni.h" | 12 #include "jni/JavaBrowserViewRendererHelper_jni.h" |
12 #include "third_party/skia/include/core/SkBitmap.h" | 13 #include "third_party/skia/include/core/SkBitmap.h" |
13 #include "third_party/skia/include/utils/SkCanvasStateUtils.h" | 14 #include "third_party/skia/include/utils/SkCanvasStateUtils.h" |
14 | 15 |
15 using base::android::JavaRef; | 16 using base::android::JavaRef; |
16 using base::android::ScopedJavaLocalRef; | 17 using base::android::ScopedJavaLocalRef; |
17 | 18 |
18 namespace android_webview { | 19 namespace android_webview { |
19 | 20 |
20 namespace { | 21 namespace { |
21 | 22 |
22 // Provides software rendering functions from the Android glue layer. | 23 // Provides software rendering functions from the Android glue layer. |
23 // Allows preventing extra copies of data when rendering. | 24 // Allows preventing extra copies of data when rendering. |
24 AwDrawSWFunctionTable* g_sw_draw_functions = NULL; | 25 AwDrawSWFunctionTable* g_sw_draw_functions = NULL; |
25 | 26 |
26 class ScopedPixelAccess { | 27 class ScopedPixelAccess { |
27 public: | 28 public: |
28 ScopedPixelAccess(JNIEnv* env, jobject java_canvas) : pixels_(NULL) { | 29 ScopedPixelAccess(JNIEnv* env, jobject java_canvas) : pixels_(NULL) { |
29 if (g_sw_draw_functions) | 30 if (g_sw_draw_functions && !switches::ForceAuxiliaryBitmap()) |
30 pixels_ = g_sw_draw_functions->access_pixels(env, java_canvas); | 31 pixels_ = g_sw_draw_functions->access_pixels(env, java_canvas); |
31 } | 32 } |
32 | 33 |
33 ~ScopedPixelAccess() { | 34 ~ScopedPixelAccess() { |
34 if (pixels_) | 35 if (pixels_) |
35 g_sw_draw_functions->release_pixels(pixels_); | 36 g_sw_draw_functions->release_pixels(pixels_); |
36 } | 37 } |
37 | 38 |
38 AwPixelInfo* pixels() { return pixels_; } | 39 AwPixelInfo* pixels() { return pixels_; } |
39 | 40 |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 | 168 |
168 if (AndroidBitmap_unlockPixels(env, jbitmap.obj()) < 0) { | 169 if (AndroidBitmap_unlockPixels(env, jbitmap.obj()) < 0) { |
169 LOG(ERROR) << "Error unlocking java bitmap pixels."; | 170 LOG(ERROR) << "Error unlocking java bitmap pixels."; |
170 return false; | 171 return false; |
171 } | 172 } |
172 | 173 |
173 return succeeded; | 174 return succeeded; |
174 } | 175 } |
175 | 176 |
176 } // namespace android_webview | 177 } // namespace android_webview |
OLD | NEW |