| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/gfx/compositor/compositor.h" | 5 #include "ui/gfx/compositor/compositor.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <d3dx10.h> | 8 #include <d3dx10.h> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 ScopedComPtr<ID3D10Texture2D> texture_; | 79 ScopedComPtr<ID3D10Texture2D> texture_; |
| 80 ScopedComPtr<ID3D10ShaderResourceView> shader_view_; | 80 ScopedComPtr<ID3D10ShaderResourceView> shader_view_; |
| 81 ScopedComPtr<ID3D10Buffer> vertex_buffer_; | 81 ScopedComPtr<ID3D10Buffer> vertex_buffer_; |
| 82 | 82 |
| 83 DISALLOW_COPY_AND_ASSIGN(ViewTexture); | 83 DISALLOW_COPY_AND_ASSIGN(ViewTexture); |
| 84 }; | 84 }; |
| 85 | 85 |
| 86 // D3D 10 Compositor implementation. | 86 // D3D 10 Compositor implementation. |
| 87 class CompositorWin : public Compositor { | 87 class CompositorWin : public Compositor { |
| 88 public: | 88 public: |
| 89 CompositorWin(gfx::AcceleratedWidget widget, | 89 CompositorWin(CompositorOwner* owner, |
| 90 const gfx::Size& size); | 90 const gfx::Size& size); |
| 91 | 91 |
| 92 void Init(); | 92 void Init(); |
| 93 | 93 |
| 94 // Invoked to update the perspective needed by this texture. |transform| is | 94 // Invoked to update the perspective needed by this texture. |transform| is |
| 95 // the transform for the texture, and |size| the size of the texture. | 95 // the transform for the texture, and |size| the size of the texture. |
| 96 void UpdatePerspective(const ui::Transform& transform, | 96 void UpdatePerspective(const ui::Transform& transform, |
| 97 const gfx::Size& view_size); | 97 const gfx::Size& view_size); |
| 98 | 98 |
| 99 // Returns the index buffer used for drawing a texture. | 99 // Returns the index buffer used for drawing a texture. |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 buffer_desc.ByteWidth = sizeof(Vertex) * ARRAYSIZE_UNSAFE(vertices); | 314 buffer_desc.ByteWidth = sizeof(Vertex) * ARRAYSIZE_UNSAFE(vertices); |
| 315 buffer_desc.BindFlags = D3D10_BIND_VERTEX_BUFFER; | 315 buffer_desc.BindFlags = D3D10_BIND_VERTEX_BUFFER; |
| 316 buffer_desc.CPUAccessFlags = 0; | 316 buffer_desc.CPUAccessFlags = 0; |
| 317 buffer_desc.MiscFlags = 0; | 317 buffer_desc.MiscFlags = 0; |
| 318 D3D10_SUBRESOURCE_DATA init_data; | 318 D3D10_SUBRESOURCE_DATA init_data; |
| 319 init_data.pSysMem = vertices; | 319 init_data.pSysMem = vertices; |
| 320 RETURN_IF_FAILED(device_->CreateBuffer(&buffer_desc, &init_data, | 320 RETURN_IF_FAILED(device_->CreateBuffer(&buffer_desc, &init_data, |
| 321 vertex_buffer_.Receive())); | 321 vertex_buffer_.Receive())); |
| 322 } | 322 } |
| 323 | 323 |
| 324 CompositorWin::CompositorWin(gfx::AcceleratedWidget widget, | 324 CompositorWin::CompositorWin(CompositorOwner* owner, |
| 325 const gfx::Size& size) | 325 const gfx::Size& size) |
| 326 : Compositor(size), | 326 : Compositor(owner, size), |
| 327 host_(widget), | 327 host_(owner->GetAcceleratedWidget()), |
| 328 technique_(NULL) { | 328 technique_(NULL) { |
| 329 } | 329 } |
| 330 | 330 |
| 331 void CompositorWin::Init() { | 331 void CompositorWin::Init() { |
| 332 CreateDevice(); | 332 CreateDevice(); |
| 333 LoadEffects(); | 333 LoadEffects(); |
| 334 OnWidgetSizeChanged(); | 334 OnWidgetSizeChanged(); |
| 335 InitVertexLayout(); | 335 InitVertexLayout(); |
| 336 CreateVertexBuffer(); | 336 CreateVertexBuffer(); |
| 337 CreateIndexBuffer(); | 337 CreateIndexBuffer(); |
| (...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 789 if (error_code != S_OK) { | 789 if (error_code != S_OK) { |
| 790 Errored(error_code); | 790 Errored(error_code); |
| 791 return NULL; | 791 return NULL; |
| 792 } | 792 } |
| 793 return vertex_buffer; | 793 return vertex_buffer; |
| 794 } | 794 } |
| 795 | 795 |
| 796 } // namespace | 796 } // namespace |
| 797 | 797 |
| 798 // static | 798 // static |
| 799 Compositor* Compositor::Create(gfx::AcceleratedWidget widget, | 799 Compositor* Compositor::Create(CompositorOwner* owner, |
| 800 const gfx::Size& size) { | 800 const gfx::Size& size) { |
| 801 CompositorWin* compositor = new CompositorWin(widget, size); | 801 CompositorWin* compositor = new CompositorWin(owner, size); |
| 802 compositor->Init(); | 802 compositor->Init(); |
| 803 return compositor; | 803 return compositor; |
| 804 } | 804 } |
| 805 | 805 |
| 806 } // namespace ui | 806 } // namespace ui |
| OLD | NEW |