Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "content/browser/renderer_host/compositor_impl_android.h" | |
| 6 | |
| 7 #include "base/bind.h" | |
| 8 #include "base/logging.h" | |
| 9 #include "content/browser/android/graphics_context.h" | |
| 10 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" | |
| 11 #include "content/common/gpu/client/gpu_channel_host.h" | |
| 12 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" | |
| 13 #include "content/common/gpu/gpu_process_launch_causes.h" | |
| 14 #include "third_party/WebKit/Source/Platform/chromium/public/WebCompositor.h" | |
| 15 | |
| 16 namespace content { | |
| 17 | |
| 18 // static | |
| 19 Compositor* Compositor::Create() { | |
| 20 return new CompositorImpl(); | |
| 21 } | |
| 22 | |
| 23 CompositorImpl::CompositorImpl() | |
| 24 : root_layer_(WebKit::WebLayer::create()) { | |
| 25 } | |
| 26 | |
| 27 CompositorImpl::~CompositorImpl() { | |
| 28 } | |
| 29 | |
| 30 void CompositorImpl::OnSurfaceUpdated( | |
| 31 const SurfacePresentedCallback& callback) { | |
| 32 host_.composite(); | |
| 33 uint32 sync_point = context_->InsertSyncPoint(); | |
| 34 callback.Run(sync_point); | |
| 35 } | |
| 36 | |
| 37 void CompositorImpl::SetRootLayer(WebKit::WebLayer* root_layer) { | |
| 38 root_layer_->removeAllChildren(); | |
| 39 root_layer_->addChild(root_layer); | |
| 40 } | |
| 41 | |
| 42 void CompositorImpl::SetWindowSurface(ANativeWindow* window) { | |
| 43 if (window) { | |
| 44 context_.reset(GraphicsContext::CreateForUI(window)); | |
| 45 WebKit::WebCompositor::initialize(NULL); | |
|
klobag.chromium
2012/08/28 00:12:07
If SurfaceView is shown and hidden and shown again
no sievers
2012/08/29 02:30:50
Done. Added a static Compositor::Initialize() func
| |
| 46 WebKit::WebLayerTreeView::Settings settings; | |
| 47 settings.refreshRate = 60.0; | |
| 48 host_.initialize(this, *root_layer_, settings); | |
| 49 host_.setVisible(true); | |
| 50 host_.setSurfaceReady(); | |
| 51 } else { | |
| 52 context_.reset(NULL); | |
|
klobag.chromium
2012/08/28 00:12:07
Should you reset size_ as you use it to compare in
no sievers
2012/08/29 02:30:50
Done.
| |
| 53 } | |
| 54 } | |
| 55 | |
| 56 void CompositorImpl::SetWindowBounds(const gfx::Size& size) { | |
| 57 if (size_ == size) | |
| 58 return; | |
| 59 | |
| 60 size_ = size; | |
| 61 host_.setViewportSize(size); | |
| 62 root_layer_->setBounds(size); | |
| 63 } | |
| 64 | |
| 65 void CompositorImpl::updateAnimations(double frameBeginTime) { | |
| 66 } | |
| 67 | |
| 68 void CompositorImpl::layout() { | |
| 69 } | |
| 70 | |
| 71 void CompositorImpl::applyScrollAndScale(const WebKit::WebSize& scrollDelta, | |
| 72 float scaleFactor) { | |
| 73 } | |
| 74 | |
| 75 WebKit::WebGraphicsContext3D* CompositorImpl::createContext3D() { | |
| 76 WebKit::WebGraphicsContext3D::Attributes attrs; | |
|
klobag.chromium
2012/08/28 00:12:07
Should you check context_ for null first as it may
no sievers
2012/08/29 02:30:50
Done.
| |
| 77 attrs.shareResources = true; | |
| 78 GpuChannelHostFactory* factory = BrowserGpuChannelHostFactory::instance(); | |
| 79 GURL url("chrome://gpu/Compositor::createContext3D"); | |
| 80 base::WeakPtr<WebGraphicsContext3DSwapBuffersClient> swap_client; | |
| 81 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context( | |
| 82 new WebGraphicsContext3DCommandBufferImpl( | |
| 83 context_->GetSurfaceID(), | |
| 84 url, | |
| 85 factory, | |
| 86 swap_client)); | |
| 87 if (!context->Initialize( | |
| 88 attrs, | |
| 89 false, | |
| 90 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)) { | |
| 91 return NULL; | |
| 92 } | |
| 93 | |
| 94 return context.release(); | |
| 95 } | |
| 96 | |
| 97 void CompositorImpl::didRebindGraphicsContext(bool success) { | |
| 98 } | |
| 99 | |
| 100 void CompositorImpl::didCommit() { | |
| 101 } | |
| 102 | |
| 103 void CompositorImpl::didCommitAndDrawFrame() { | |
| 104 } | |
| 105 | |
| 106 void CompositorImpl::didCompleteSwapBuffers() { | |
| 107 } | |
| 108 | |
| 109 void CompositorImpl::scheduleComposite() { | |
| 110 } | |
| 111 | |
| 112 } // namespace content | |
| OLD | NEW |