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_.adjust_deadline_for_parent = 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_.adjust_deadline_for_parent to false |
| 62 class OutputSurfaceWithoutParent : public cc::OutputSurface { |
| 63 public: |
| 64 OutputSurfaceWithoutParent(scoped_ptr<WebKit::WebGraphicsContext3D> context3d) |
| 65 : cc::OutputSurface(context3d.Pass()) { |
| 66 capabilities_.adjust_deadline_for_parent = false; |
| 67 } |
| 68 }; |
| 69 |
59 static bool g_initialized = false; | 70 static bool g_initialized = false; |
60 static base::Thread* g_impl_thread = NULL; | 71 static base::Thread* 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 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 url, | 369 url, |
359 factory, | 370 factory, |
360 weak_factory_.GetWeakPtr())); | 371 weak_factory_.GetWeakPtr())); |
361 if (!context->InitializeWithDefaultBufferSizes( | 372 if (!context->InitializeWithDefaultBufferSizes( |
362 attrs, | 373 attrs, |
363 false, | 374 false, |
364 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE))
{ | 375 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE))
{ |
365 LOG(ERROR) << "Failed to create 3D context for compositor."; | 376 LOG(ERROR) << "Failed to create 3D context for compositor."; |
366 return scoped_ptr<cc::OutputSurface>(); | 377 return scoped_ptr<cc::OutputSurface>(); |
367 } | 378 } |
368 return make_scoped_ptr(new cc::OutputSurface( | 379 return scoped_ptr<cc::OutputSurface>( |
369 context.PassAs<WebKit::WebGraphicsContext3D>())); | 380 new OutputSurfaceWithoutParent( |
| 381 context.PassAs<WebKit::WebGraphicsContext3D>())); |
370 } | 382 } |
371 } | 383 } |
372 | 384 |
373 void CompositorImpl::DidCompleteSwapBuffers() { | 385 void CompositorImpl::DidCompleteSwapBuffers() { |
374 client_->OnSwapBuffersCompleted(); | 386 client_->OnSwapBuffersCompleted(); |
375 } | 387 } |
376 | 388 |
377 void CompositorImpl::ScheduleComposite() { | 389 void CompositorImpl::ScheduleComposite() { |
378 client_->ScheduleComposite(); | 390 client_->ScheduleComposite(); |
379 } | 391 } |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 case ANDROID_BITMAP_FORMAT_RGBA_8888: | 468 case ANDROID_BITMAP_FORMAT_RGBA_8888: |
457 return GL_UNSIGNED_BYTE; | 469 return GL_UNSIGNED_BYTE; |
458 break; | 470 break; |
459 case ANDROID_BITMAP_FORMAT_RGB_565: | 471 case ANDROID_BITMAP_FORMAT_RGB_565: |
460 default: | 472 default: |
461 return GL_UNSIGNED_SHORT_5_6_5; | 473 return GL_UNSIGNED_SHORT_5_6_5; |
462 } | 474 } |
463 } | 475 } |
464 | 476 |
465 } // namespace content | 477 } // namespace content |
OLD | NEW |