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 <stdint.h> | 9 #include <stdint.h> |
10 #include <utility> | 10 #include <utility> |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
162 ExternalBeginFrameSource(CompositorImpl* compositor) | 162 ExternalBeginFrameSource(CompositorImpl* compositor) |
163 : compositor_(compositor) { | 163 : compositor_(compositor) { |
164 compositor_->AddObserver(this); | 164 compositor_->AddObserver(this); |
165 } | 165 } |
166 | 166 |
167 ~ExternalBeginFrameSource() override { | 167 ~ExternalBeginFrameSource() override { |
168 compositor_->RemoveObserver(this); | 168 compositor_->RemoveObserver(this); |
169 } | 169 } |
170 | 170 |
171 // cc::BeginFrameSourceBase implementation: | 171 // cc::BeginFrameSourceBase implementation: |
172 void AddObserver(cc::BeginFrameObserver* obs) override { | |
173 cc::BeginFrameSourceBase::AddObserver(obs); | |
174 DCHECK(needs_begin_frames()); | |
175 // Send a MISSED begin frame if necessary. | |
176 if (last_begin_frame_args_.IsValid()) { | |
enne (OOO)
2016/04/18 21:36:01
style nit: I'd early out here instead of nesting a
no sievers
2016/04/22 19:53:11
Done.
| |
177 cc::BeginFrameArgs last_args = obs->LastUsedBeginFrameArgs(); | |
178 if (!last_args.IsValid() || | |
179 (last_begin_frame_args_.frame_time > last_args.frame_time)) { | |
180 last_begin_frame_args_.type = cc::BeginFrameArgs::MISSED; | |
no sievers
2016/04/13 00:23:53
Btw not using MISSED here breaks the world and I'm
| |
181 // We know that the scheduler wants to draw, so the deadline | |
182 // doesn't matter much. But pass a timestamp that won't expire | |
183 // soon, so we don't get discarded in BeginRetroFrame(), see | |
184 // crbug.com/602485. | |
185 last_begin_frame_args_.deadline = base::TimeTicks::Now() + | |
186 base::TimeDelta::FromMilliseconds(16); | |
enne (OOO)
2016/04/18 21:36:01
With https://codereview.chromium.org/1887243002, i
no sievers
2016/04/22 19:53:11
I made it a TODO and reworded the comment, since I
| |
187 obs->OnBeginFrame(last_begin_frame_args_); | |
188 } | |
189 } | |
190 } | |
191 | |
172 void OnNeedsBeginFramesChanged(bool needs_begin_frames) override { | 192 void OnNeedsBeginFramesChanged(bool needs_begin_frames) override { |
193 TRACE_EVENT1("compositor", "OnNeedsBeginFramesChanged", | |
194 "needs_begin_frames", needs_begin_frames); | |
173 compositor_->OnNeedsBeginFramesChange(needs_begin_frames); | 195 compositor_->OnNeedsBeginFramesChange(needs_begin_frames); |
174 } | 196 } |
175 | 197 |
176 // CompositorImpl::VSyncObserver implementation: | 198 // CompositorImpl::VSyncObserver implementation: |
177 void OnVSync(base::TimeTicks frame_time, | 199 void OnVSync(base::TimeTicks frame_time, |
178 base::TimeDelta vsync_period) override { | 200 base::TimeDelta vsync_period) override { |
179 CallOnBeginFrame(cc::BeginFrameArgs::Create( | 201 base::TimeTicks deadline = frame_time + 2 * vsync_period / 3; |
enne (OOO)
2016/04/18 21:36:01
Where does this come from?
no sievers
2016/04/22 19:53:11
Removed. It's not needed as long as the scheduler
| |
180 BEGINFRAME_FROM_HERE, frame_time, base::TimeTicks::Now(), vsync_period, | 202 last_begin_frame_args_ = |
181 cc::BeginFrameArgs::NORMAL)); | 203 cc::BeginFrameArgs::Create(BEGINFRAME_FROM_HERE, frame_time, deadline, |
204 vsync_period, cc::BeginFrameArgs::NORMAL); | |
205 CallOnBeginFrame(last_begin_frame_args_); | |
182 } | 206 } |
183 | 207 |
184 private: | 208 private: |
185 CompositorImpl* compositor_; | 209 CompositorImpl* compositor_; |
210 cc::BeginFrameArgs last_begin_frame_args_; | |
186 }; | 211 }; |
187 | 212 |
188 static bool g_initialized = false; | 213 static bool g_initialized = false; |
189 | 214 |
190 base::LazyInstance<cc::SurfaceManager> g_surface_manager = | 215 base::LazyInstance<cc::SurfaceManager> g_surface_manager = |
191 LAZY_INSTANCE_INITIALIZER; | 216 LAZY_INSTANCE_INITIALIZER; |
192 | 217 |
193 int g_surface_id_namespace = 0; | 218 int g_surface_id_namespace = 0; |
194 | 219 |
195 class SingleThreadTaskGraphRunner : public cc::SingleThreadTaskGraphRunner { | 220 class SingleThreadTaskGraphRunner : public cc::SingleThreadTaskGraphRunner { |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
399 | 424 |
400 void CompositorImpl::SetHasTransparentBackground(bool flag) { | 425 void CompositorImpl::SetHasTransparentBackground(bool flag) { |
401 has_transparent_background_ = flag; | 426 has_transparent_background_ = flag; |
402 if (host_) | 427 if (host_) |
403 host_->set_has_transparent_background(flag); | 428 host_->set_has_transparent_background(flag); |
404 } | 429 } |
405 | 430 |
406 void CompositorImpl::SetNeedsComposite() { | 431 void CompositorImpl::SetNeedsComposite() { |
407 if (!host_->visible()) | 432 if (!host_->visible()) |
408 return; | 433 return; |
434 TRACE_EVENT0("compositor", "Compositor::SetNeedsComposite"); | |
409 host_->SetNeedsAnimate(); | 435 host_->SetNeedsAnimate(); |
410 } | 436 } |
411 | 437 |
412 static scoped_ptr<WebGraphicsContext3DCommandBufferImpl> | 438 static scoped_ptr<WebGraphicsContext3DCommandBufferImpl> |
413 CreateGpuProcessViewContext( | 439 CreateGpuProcessViewContext( |
414 const scoped_refptr<gpu::GpuChannelHost>& gpu_channel_host, | 440 const scoped_refptr<gpu::GpuChannelHost>& gpu_channel_host, |
415 const gpu::gles2::ContextCreationAttribHelper& attributes, | 441 const gpu::gles2::ContextCreationAttribHelper& attributes, |
416 int surface_id) { | 442 int surface_id) { |
417 GURL url("chrome://gpu/Compositor::createContext3D"); | 443 GURL url("chrome://gpu/Compositor::createContext3D"); |
418 static const size_t kBytesPerPixel = 4; | 444 static const size_t kBytesPerPixel = 4; |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
578 void CompositorImpl::AddObserver(VSyncObserver* observer) { | 604 void CompositorImpl::AddObserver(VSyncObserver* observer) { |
579 observer_list_.AddObserver(observer); | 605 observer_list_.AddObserver(observer); |
580 } | 606 } |
581 | 607 |
582 void CompositorImpl::RemoveObserver(VSyncObserver* observer) { | 608 void CompositorImpl::RemoveObserver(VSyncObserver* observer) { |
583 observer_list_.RemoveObserver(observer); | 609 observer_list_.RemoveObserver(observer); |
584 } | 610 } |
585 | 611 |
586 cc::UIResourceId CompositorImpl::CreateUIResource( | 612 cc::UIResourceId CompositorImpl::CreateUIResource( |
587 cc::UIResourceClient* client) { | 613 cc::UIResourceClient* client) { |
614 TRACE_EVENT0("compositor", "CompositorImpl::CreateUIResource"); | |
588 return host_->CreateUIResource(client); | 615 return host_->CreateUIResource(client); |
589 } | 616 } |
590 | 617 |
591 void CompositorImpl::DeleteUIResource(cc::UIResourceId resource_id) { | 618 void CompositorImpl::DeleteUIResource(cc::UIResourceId resource_id) { |
619 TRACE_EVENT0("compositor", "CompositorImpl::DeleteUIResource"); | |
592 host_->DeleteUIResource(resource_id); | 620 host_->DeleteUIResource(resource_id); |
593 } | 621 } |
594 | 622 |
595 bool CompositorImpl::SupportsETC1NonPowerOfTwo() const { | 623 bool CompositorImpl::SupportsETC1NonPowerOfTwo() const { |
596 return gpu_capabilities_.texture_format_etc1_npot; | 624 return gpu_capabilities_.texture_format_etc1_npot; |
597 } | 625 } |
598 | 626 |
599 void CompositorImpl::DidPostSwapBuffers() { | 627 void CompositorImpl::DidPostSwapBuffers() { |
600 TRACE_EVENT0("compositor", "CompositorImpl::DidPostSwapBuffers"); | 628 TRACE_EVENT0("compositor", "CompositorImpl::DidPostSwapBuffers"); |
601 pending_swapbuffers_++; | 629 pending_swapbuffers_++; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
642 needs_begin_frames_ = needs_begin_frames; | 670 needs_begin_frames_ = needs_begin_frames; |
643 if (needs_begin_frames_) | 671 if (needs_begin_frames_) |
644 root_window_->RequestVSyncUpdate(); | 672 root_window_->RequestVSyncUpdate(); |
645 } | 673 } |
646 | 674 |
647 void CompositorImpl::SetNeedsAnimate() { | 675 void CompositorImpl::SetNeedsAnimate() { |
648 needs_animate_ = true; | 676 needs_animate_ = true; |
649 if (!host_->visible()) | 677 if (!host_->visible()) |
650 return; | 678 return; |
651 | 679 |
680 TRACE_EVENT0("compositor", "Compositor::SetNeedsAnimate"); | |
652 host_->SetNeedsAnimate(); | 681 host_->SetNeedsAnimate(); |
653 } | 682 } |
654 | 683 |
655 } // namespace content | 684 } // namespace content |
OLD | NEW |