Chromium Code Reviews| 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/render_widget_host_view_android.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_android.h" |
| 6 | 6 |
| 7 #include <android/bitmap.h> | 7 #include <android/bitmap.h> |
| 8 | 8 |
| 9 #include "base/android/build_info.h" | 9 #include "base/android/build_info.h" |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 111 // WebGraphicsContextLostCallback implementation. | 111 // WebGraphicsContextLostCallback implementation. |
| 112 virtual void onContextLost() override; | 112 virtual void onContextLost() override; |
| 113 | 113 |
| 114 GLHelper* GetGLHelper() { return gl_helper_.get(); } | 114 GLHelper* GetGLHelper() { return gl_helper_.get(); } |
| 115 bool IsLost() { return !context_.get() || context_->isContextLost(); } | 115 bool IsLost() { return !context_.get() || context_->isContextLost(); } |
| 116 | 116 |
| 117 private: | 117 private: |
| 118 GLHelperHolder(); | 118 GLHelperHolder(); |
| 119 static scoped_ptr<WebGraphicsContext3DCommandBufferImpl> CreateContext3D(); | 119 static scoped_ptr<WebGraphicsContext3DCommandBufferImpl> CreateContext3D(); |
| 120 | 120 |
| 121 // Whether gpu_toplevel category is enabled. | |
| 122 const unsigned char* gpu_trace_top_level_category_; | |
| 123 | |
| 121 scoped_ptr<GLHelper> gl_helper_; | 124 scoped_ptr<GLHelper> gl_helper_; |
| 122 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context_; | 125 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context_; |
| 123 | 126 |
| 124 DISALLOW_COPY_AND_ASSIGN(GLHelperHolder); | 127 DISALLOW_COPY_AND_ASSIGN(GLHelperHolder); |
| 125 }; | 128 }; |
| 126 | 129 |
| 127 GLHelperHolder* GLHelperHolder::Create() { | 130 GLHelperHolder* GLHelperHolder::Create() { |
| 128 GLHelperHolder* holder = new GLHelperHolder; | 131 GLHelperHolder* holder = new GLHelperHolder; |
| 129 holder->Initialize(); | 132 holder->Initialize(); |
| 130 | 133 |
| 131 return holder; | 134 return holder; |
| 132 } | 135 } |
| 133 | 136 |
| 134 GLHelperHolder::GLHelperHolder() { | 137 GLHelperHolder::GLHelperHolder() |
| 138 : gpu_trace_top_level_category_(TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED( | |
| 139 TRACE_DISABLED_BY_DEFAULT("gpu_toplevel"))) { | |
| 135 } | 140 } |
| 136 | 141 |
| 137 GLHelperHolder::~GLHelperHolder() { | 142 GLHelperHolder::~GLHelperHolder() { |
| 143 if (context_ && *gpu_trace_top_level_category_) { | |
|
vmiura
2014/12/09 00:18:10
Check if the category is enabled inside the macros
| |
| 144 TRACE_GPU_EVENT_END0(context_); | |
| 145 } | |
| 138 } | 146 } |
| 139 | 147 |
| 140 void GLHelperHolder::Initialize() { | 148 void GLHelperHolder::Initialize() { |
| 141 context_ = CreateContext3D(); | 149 context_ = CreateContext3D(); |
| 142 if (context_) { | 150 if (context_) { |
| 143 context_->setContextLostCallback(this); | 151 context_->setContextLostCallback(this); |
| 144 gl_helper_.reset(new GLHelper(context_->GetImplementation(), | 152 gl_helper_.reset(new GLHelper(context_->GetImplementation(), |
| 145 context_->GetContextSupport())); | 153 context_->GetContextSupport())); |
| 146 } | 154 } |
| 147 } | 155 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 184 3 * full_screen_texture_size_in_bytes, kDefaultMaxTransferBufferSize); | 192 3 * full_screen_texture_size_in_bytes, kDefaultMaxTransferBufferSize); |
| 185 limits.mapped_memory_reclaim_limit = | 193 limits.mapped_memory_reclaim_limit = |
| 186 WebGraphicsContext3DCommandBufferImpl::kNoLimit; | 194 WebGraphicsContext3DCommandBufferImpl::kNoLimit; |
| 187 bool lose_context_when_out_of_memory = false; | 195 bool lose_context_when_out_of_memory = false; |
| 188 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context( | 196 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context( |
| 189 new WebGraphicsContext3DCommandBufferImpl( | 197 new WebGraphicsContext3DCommandBufferImpl( |
| 190 0, // offscreen | 198 0, // offscreen |
| 191 url, gpu_channel_host.get(), attrs, lose_context_when_out_of_memory, | 199 url, gpu_channel_host.get(), attrs, lose_context_when_out_of_memory, |
| 192 limits, nullptr)); | 200 limits, nullptr)); |
| 193 if (context->InitializeOnCurrentThread()) { | 201 if (context->InitializeOnCurrentThread()) { |
| 194 context->pushGroupMarkerEXT( | 202 if (*gpu_trace_top_level_category_) { |
|
vmiura
2014/12/09 00:18:10
Same, check if the category is enabled inside the
| |
| 195 base::StringPrintf("CmdBufferImageTransportFactory-%p", | 203 TRACE_GPU_EVENT_BEGIN0( |
| 196 context.get()).c_str()); | 204 context, |
| 205 TRACE_DISABLED_BY_DEFAULT("gpu_toplevel"), | |
| 206 base::StringPrintf("CmdBufferImageTransportFactory-%p", | |
| 207 context.get()).c_str()); | |
| 208 } | |
| 197 } else { | 209 } else { |
| 198 context.reset(); | 210 context.reset(); |
| 199 } | 211 } |
| 200 | 212 |
| 201 return context.Pass(); | 213 return context.Pass(); |
| 202 } | 214 } |
| 203 | 215 |
| 204 // This can only be used for readback postprocessing. It may return null if the | 216 // This can only be used for readback postprocessing. It may return null if the |
| 205 // channel was lost and not reestablished yet. | 217 // channel was lost and not reestablished yet. |
| 206 GLHelper* GetPostReadbackGLHelper() { | 218 GLHelper* GetPostReadbackGLHelper() { |
| (...skipping 1684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1891 results->orientationAngle = display.RotationAsDegree(); | 1903 results->orientationAngle = display.RotationAsDegree(); |
| 1892 results->orientationType = | 1904 results->orientationType = |
| 1893 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display); | 1905 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display); |
| 1894 gfx::DeviceDisplayInfo info; | 1906 gfx::DeviceDisplayInfo info; |
| 1895 results->depth = info.GetBitsPerPixel(); | 1907 results->depth = info.GetBitsPerPixel(); |
| 1896 results->depthPerComponent = info.GetBitsPerComponent(); | 1908 results->depthPerComponent = info.GetBitsPerComponent(); |
| 1897 results->isMonochrome = (results->depthPerComponent == 0); | 1909 results->isMonochrome = (results->depthPerComponent == 0); |
| 1898 } | 1910 } |
| 1899 | 1911 |
| 1900 } // namespace content | 1912 } // namespace content |
| OLD | NEW |