OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/renderer_host/compositor_impl_android.h" | 5 #include "content/browser/renderer_host/compositor_impl_android.h" |
6 | 6 |
7 #include <android/bitmap.h> | 7 #include <android/bitmap.h> |
8 #include <android/native_window_jni.h> | 8 #include <android/native_window_jni.h> |
9 #include <map> | 9 #include <map> |
10 | 10 |
(...skipping 28 matching lines...) Expand all Loading... |
39 namespace gfx { | 39 namespace gfx { |
40 class JavaBitmap; | 40 class JavaBitmap; |
41 } | 41 } |
42 | 42 |
43 namespace { | 43 namespace { |
44 | 44 |
45 // Used for drawing directly to the screen. Bypasses resizing and swaps. | 45 // Used for drawing directly to the screen. Bypasses resizing and swaps. |
46 class DirectOutputSurface : public cc::OutputSurface { | 46 class DirectOutputSurface : public cc::OutputSurface { |
47 public: | 47 public: |
48 DirectOutputSurface(scoped_ptr<WebKit::WebGraphicsContext3D> context3d) | 48 DirectOutputSurface(scoped_ptr<WebKit::WebGraphicsContext3D> context3d) |
49 : cc::OutputSurface(context3d.Pass()) {} | 49 : cc::OutputSurface(context3d.Pass()) { |
| 50 capabilities_.has_parent_compositor = false; |
| 51 } |
50 | 52 |
51 virtual void Reshape(gfx::Size size, float scale_factor) OVERRIDE { | 53 virtual void Reshape(gfx::Size size, float scale_factor) OVERRIDE { |
52 surface_size_ = size; | 54 surface_size_ = size; |
53 } | 55 } |
54 virtual void SwapBuffers(cc::CompositorFrame*) OVERRIDE { | 56 virtual void SwapBuffers(cc::CompositorFrame*) OVERRIDE { |
55 context3d()->shallowFlushCHROMIUM(); | 57 context3d()->shallowFlushCHROMIUM(); |
56 } | 58 } |
57 }; | 59 }; |
58 | 60 |
| 61 // Used to override capabilities_.has_parent_compositor to false |
| 62 class OutputSurfaceWithoutParent : public cc::OutputSurface { |
| 63 public: |
| 64 OutputSurfaceWithoutParent(scoped_ptr<WebKit::WebGraphicsContext3D> context3d) |
| 65 : cc::OutputSurface(context3d.Pass()) { |
| 66 capabilities_.has_parent_compositor = false; |
| 67 } |
| 68 }; |
| 69 |
59 static bool g_initialized = false; | 70 static bool g_initialized = false; |
60 static webkit_glue::WebThreadImpl* g_impl_thread = NULL; | 71 static webkit_glue::WebThreadImpl* g_impl_thread = NULL; |
61 static bool g_use_direct_gl = false; | 72 static bool g_use_direct_gl = false; |
62 | 73 |
63 } // anonymous namespace | 74 } // anonymous namespace |
64 | 75 |
65 namespace content { | 76 namespace content { |
66 | 77 |
67 typedef std::map<int, base::android::ScopedJavaGlobalRef<jobject> > | 78 typedef std::map<int, base::android::ScopedJavaGlobalRef<jobject> > |
68 SurfaceMap; | 79 SurfaceMap; |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 url, | 368 url, |
358 factory, | 369 factory, |
359 weak_factory_.GetWeakPtr())); | 370 weak_factory_.GetWeakPtr())); |
360 if (!context->InitializeWithDefaultBufferSizes( | 371 if (!context->InitializeWithDefaultBufferSizes( |
361 attrs, | 372 attrs, |
362 false, | 373 false, |
363 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE))
{ | 374 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE))
{ |
364 LOG(ERROR) << "Failed to create 3D context for compositor."; | 375 LOG(ERROR) << "Failed to create 3D context for compositor."; |
365 return scoped_ptr<cc::OutputSurface>(); | 376 return scoped_ptr<cc::OutputSurface>(); |
366 } | 377 } |
367 return make_scoped_ptr(new cc::OutputSurface( | 378 return scoped_ptr<cc::OutputSurface>( |
368 context.PassAs<WebKit::WebGraphicsContext3D>())); | 379 new OutputSurfaceWithoutParent( |
| 380 context.PassAs<WebKit::WebGraphicsContext3D>())); |
369 } | 381 } |
370 } | 382 } |
371 | 383 |
372 void CompositorImpl::DidCompleteSwapBuffers() { | 384 void CompositorImpl::DidCompleteSwapBuffers() { |
373 client_->OnSwapBuffersCompleted(); | 385 client_->OnSwapBuffersCompleted(); |
374 } | 386 } |
375 | 387 |
376 void CompositorImpl::ScheduleComposite() { | 388 void CompositorImpl::ScheduleComposite() { |
377 client_->ScheduleComposite(); | 389 client_->ScheduleComposite(); |
378 } | 390 } |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 case ANDROID_BITMAP_FORMAT_RGBA_8888: | 467 case ANDROID_BITMAP_FORMAT_RGBA_8888: |
456 return GL_UNSIGNED_BYTE; | 468 return GL_UNSIGNED_BYTE; |
457 break; | 469 break; |
458 case ANDROID_BITMAP_FORMAT_RGB_565: | 470 case ANDROID_BITMAP_FORMAT_RGB_565: |
459 default: | 471 default: |
460 return GL_UNSIGNED_SHORT_5_6_5; | 472 return GL_UNSIGNED_SHORT_5_6_5; |
461 } | 473 } |
462 } | 474 } |
463 | 475 |
464 } // namespace content | 476 } // namespace content |
OLD | NEW |