| 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 "ui/gl/async_pixel_transfer_delegate_android.h" | 5 #include "ui/gl/async_pixel_transfer_delegate_android.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| 11 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/process_util.h" | 14 #include "base/process_util.h" |
| 15 #include "base/shared_memory.h" | 15 #include "base/shared_memory.h" |
| 16 #include "base/threading/thread.h" | 16 #include "base/threading/thread.h" |
| 17 #include "build/build_config.h" | 17 #include "build/build_config.h" |
| 18 #include "ui/gl/async_pixel_transfer_delegate.h" | 18 #include "ui/gl/async_pixel_transfer_delegate.h" |
| 19 #include "ui/gl/async_pixel_transfer_delegate_stub.h" | 19 #include "ui/gl/async_pixel_transfer_delegate_stub.h" |
| 20 #include "ui/gl/egl_util.h" | 20 #include "ui/gl/egl_util.h" |
| 21 #include "ui/gl/gl_bindings.h" | 21 #include "ui/gl/gl_bindings.h" |
| 22 #include "ui/gl/gl_context.h" | 22 #include "ui/gl/gl_context.h" |
| 23 #include "ui/gl/gl_surface_egl.h" | 23 #include "ui/gl/gl_surface_egl.h" |
| 24 | 24 |
| 25 // TODO(epenner): Move thread priorities to base. (crbug.com/170549) |
| 26 #include <sys/resource.h> |
| 27 |
| 25 using base::SharedMemory; | 28 using base::SharedMemory; |
| 26 using base::SharedMemoryHandle; | 29 using base::SharedMemoryHandle; |
| 27 | 30 |
| 28 namespace gfx { | 31 namespace gfx { |
| 29 | 32 |
| 30 namespace { | 33 namespace { |
| 31 | 34 |
| 32 const char kAsyncTransferThreadName[] = "AsyncTransferThread"; | 35 const char kAsyncTransferThreadName[] = "AsyncTransferThread"; |
| 33 | 36 |
| 34 bool CheckErrors(const char* file, int line) { | 37 bool CheckErrors(const char* file, int line) { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 virtual void Init() OVERRIDE { | 91 virtual void Init() OVERRIDE { |
| 89 GLShareGroup* share_group = NULL; | 92 GLShareGroup* share_group = NULL; |
| 90 bool software = false; | 93 bool software = false; |
| 91 surface_ = new gfx::PbufferGLSurfaceEGL(software, gfx::Size(1,1)); | 94 surface_ = new gfx::PbufferGLSurfaceEGL(software, gfx::Size(1,1)); |
| 92 surface_->Initialize(); | 95 surface_->Initialize(); |
| 93 context_ = gfx::GLContext::CreateGLContext(share_group, | 96 context_ = gfx::GLContext::CreateGLContext(share_group, |
| 94 surface_, | 97 surface_, |
| 95 gfx::PreferDiscreteGpu); | 98 gfx::PreferDiscreteGpu); |
| 96 bool is_current = context_->MakeCurrent(surface_); | 99 bool is_current = context_->MakeCurrent(surface_); |
| 97 DCHECK(is_current); | 100 DCHECK(is_current); |
| 101 |
| 102 // TODO(epenner): Move thread priorities to base. (crbug.com/170549) |
| 103 int nice_value = 10; // Idle priority. |
| 104 setpriority(PRIO_PROCESS, base::PlatformThread::CurrentId(), nice_value); |
| 98 } | 105 } |
| 99 | 106 |
| 100 virtual void CleanUp() OVERRIDE { | 107 virtual void CleanUp() OVERRIDE { |
| 101 surface_ = NULL; | 108 surface_ = NULL; |
| 102 context_->ReleaseCurrent(surface_); | 109 context_->ReleaseCurrent(surface_); |
| 103 context_ = NULL; | 110 context_ = NULL; |
| 104 } | 111 } |
| 105 | 112 |
| 106 private: | 113 private: |
| 107 scoped_refptr<gfx::GLContext> context_; | 114 scoped_refptr<gfx::GLContext> context_; |
| (...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 614 tex_params.type, | 621 tex_params.type, |
| 615 data); | 622 data); |
| 616 } | 623 } |
| 617 WaitForGl(); | 624 WaitForGl(); |
| 618 | 625 |
| 619 DCHECK(CHECK_GL()); | 626 DCHECK(CHECK_GL()); |
| 620 state->last_transfer_time_ = base::TimeTicks::HighResNow() - begin_time; | 627 state->last_transfer_time_ = base::TimeTicks::HighResNow() - begin_time; |
| 621 } | 628 } |
| 622 | 629 |
| 623 } // namespace gfx | 630 } // namespace gfx |
| OLD | NEW |