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/public/browser/draw_sw.h" | 9 #include "android_webview/public/browser/draw_sw.h" |
10 #include "base/android/scoped_java_ref.h" | 10 #include "base/android/scoped_java_ref.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 const gfx::Vector2d& scroll_correction, | 80 const gfx::Vector2d& scroll_correction, |
81 const gfx::Size size); | 81 const gfx::Size size); |
82 ~AuxiliaryCanvasHolder() override; | 82 ~AuxiliaryCanvasHolder() override; |
83 | 83 |
84 SkCanvas* GetCanvas() override; | 84 SkCanvas* GetCanvas() override; |
85 | 85 |
86 private: | 86 private: |
87 ScopedJavaLocalRef<jobject> jcanvas_; | 87 ScopedJavaLocalRef<jobject> jcanvas_; |
88 ScopedJavaLocalRef<jobject> jbitmap_; | 88 ScopedJavaLocalRef<jobject> jbitmap_; |
89 gfx::Vector2d scroll_; | 89 gfx::Vector2d scroll_; |
90 scoped_ptr<SkBitmap> bitmap_; | 90 std::unique_ptr<SkBitmap> bitmap_; |
91 skia::RefPtr<SkCanvas> canvas_; | 91 skia::RefPtr<SkCanvas> canvas_; |
92 DISALLOW_COPY_AND_ASSIGN(AuxiliaryCanvasHolder); | 92 DISALLOW_COPY_AND_ASSIGN(AuxiliaryCanvasHolder); |
93 }; | 93 }; |
94 | 94 |
95 AuxiliaryCanvasHolder::AuxiliaryCanvasHolder( | 95 AuxiliaryCanvasHolder::AuxiliaryCanvasHolder( |
96 JNIEnv* env, | 96 JNIEnv* env, |
97 jobject java_canvas, | 97 jobject java_canvas, |
98 const gfx::Vector2d& scroll_correction, | 98 const gfx::Vector2d& scroll_correction, |
99 const gfx::Size size) | 99 const gfx::Size size) |
100 : jcanvas_(env, java_canvas), scroll_(scroll_correction) { | 100 : jcanvas_(env, java_canvas), scroll_(scroll_correction) { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 return canvas_.get(); | 142 return canvas_.get(); |
143 } | 143 } |
144 | 144 |
145 } // namespace | 145 } // namespace |
146 | 146 |
147 void RasterHelperSetAwDrawSWFunctionTable(AwDrawSWFunctionTable* table) { | 147 void RasterHelperSetAwDrawSWFunctionTable(AwDrawSWFunctionTable* table) { |
148 g_sw_draw_functions = table; | 148 g_sw_draw_functions = table; |
149 } | 149 } |
150 | 150 |
151 // static | 151 // static |
152 scoped_ptr<SoftwareCanvasHolder> SoftwareCanvasHolder::Create( | 152 std::unique_ptr<SoftwareCanvasHolder> SoftwareCanvasHolder::Create( |
153 jobject java_canvas, | 153 jobject java_canvas, |
154 const gfx::Vector2d& scroll_correction, | 154 const gfx::Vector2d& scroll_correction, |
155 const gfx::Size& auxiliary_bitmap_size, | 155 const gfx::Size& auxiliary_bitmap_size, |
156 bool force_auxiliary_bitmap) { | 156 bool force_auxiliary_bitmap) { |
157 JNIEnv* env = base::android::AttachCurrentThread(); | 157 JNIEnv* env = base::android::AttachCurrentThread(); |
158 scoped_ptr<SoftwareCanvasHolder> holder; | 158 std::unique_ptr<SoftwareCanvasHolder> holder; |
159 if (!force_auxiliary_bitmap) { | 159 if (!force_auxiliary_bitmap) { |
160 holder.reset(new JavaCanvasHolder(env, java_canvas, scroll_correction)); | 160 holder.reset(new JavaCanvasHolder(env, java_canvas, scroll_correction)); |
161 } | 161 } |
162 if (!holder.get() || !holder->GetCanvas()) { | 162 if (!holder.get() || !holder->GetCanvas()) { |
163 holder.reset(); | 163 holder.reset(); |
164 holder.reset(new AuxiliaryCanvasHolder(env, java_canvas, scroll_correction, | 164 holder.reset(new AuxiliaryCanvasHolder(env, java_canvas, scroll_correction, |
165 auxiliary_bitmap_size)); | 165 auxiliary_bitmap_size)); |
166 } | 166 } |
167 if (!holder->GetCanvas()) { | 167 if (!holder->GetCanvas()) { |
168 holder.reset(); | 168 holder.reset(); |
169 } | 169 } |
170 return holder; | 170 return holder; |
171 } | 171 } |
172 | 172 |
173 bool RegisterJavaBrowserViewRendererHelper(JNIEnv* env) { | 173 bool RegisterJavaBrowserViewRendererHelper(JNIEnv* env) { |
174 return RegisterNativesImpl(env); | 174 return RegisterNativesImpl(env); |
175 } | 175 } |
176 | 176 |
177 } // namespace android_webview | 177 } // namespace android_webview |
OLD | NEW |