| 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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. |
| 100 ID3D10Buffer* GetTextureIndexBuffer(); | 100 ID3D10Buffer* GetTextureIndexBuffer(); |
| 101 | 101 |
| 102 // Compositor: | 102 // Compositor: |
| 103 virtual Texture* CreateTexture() OVERRIDE; | 103 virtual Texture* CreateTexture() OVERRIDE; |
| 104 virtual void NotifyStart() OVERRIDE; | |
| 105 virtual void NotifyEnd() OVERRIDE; | |
| 106 virtual void Blur(const gfx::Rect& bounds) OVERRIDE; | 104 virtual void Blur(const gfx::Rect& bounds) OVERRIDE; |
| 107 virtual void SchedulePaint() OVERRIDE; | 105 virtual void SchedulePaint() OVERRIDE; |
| 108 | 106 |
| 109 protected: | 107 protected: |
| 108 virtual void OnNotifyStart() OVERRIDE; |
| 109 virtual void OnNotifyEnd() OVERRIDE; |
| 110 virtual void OnWidgetSizeChanged() OVERRIDE; | 110 virtual void OnWidgetSizeChanged() OVERRIDE; |
| 111 | 111 |
| 112 private: | 112 private: |
| 113 enum Direction { | 113 enum Direction { |
| 114 HORIZONTAL, | 114 HORIZONTAL, |
| 115 VERTICAL | 115 VERTICAL |
| 116 }; | 116 }; |
| 117 | 117 |
| 118 ~CompositorWin(); | 118 ~CompositorWin(); |
| 119 | 119 |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 } | 381 } |
| 382 | 382 |
| 383 ID3D10Buffer* CompositorWin::GetTextureIndexBuffer() { | 383 ID3D10Buffer* CompositorWin::GetTextureIndexBuffer() { |
| 384 return index_buffer_.get(); | 384 return index_buffer_.get(); |
| 385 } | 385 } |
| 386 | 386 |
| 387 Texture* CompositorWin::CreateTexture() { | 387 Texture* CompositorWin::CreateTexture() { |
| 388 return new ViewTexture(this, device_.get(), fx_.get()); | 388 return new ViewTexture(this, device_.get(), fx_.get()); |
| 389 } | 389 } |
| 390 | 390 |
| 391 void CompositorWin::NotifyStart() { | 391 void CompositorWin::OnNotifyStart() { |
| 392 ID3D10RenderTargetView* target_view = main_render_target_view_.get(); | 392 ID3D10RenderTargetView* target_view = main_render_target_view_.get(); |
| 393 device_->OMSetRenderTargets(1, &target_view, depth_stencil_view_.get()); | 393 device_->OMSetRenderTargets(1, &target_view, depth_stencil_view_.get()); |
| 394 | 394 |
| 395 // Clear the background and stencil view. | 395 // Clear the background and stencil view. |
| 396 device_->ClearRenderTargetView(target_view, | 396 device_->ClearRenderTargetView(target_view, |
| 397 D3DXCOLOR(0.0f, 0.0f, 0.0f, 0.0f)); | 397 D3DXCOLOR(0.0f, 0.0f, 0.0f, 0.0f)); |
| 398 device_->ClearDepthStencilView( | 398 device_->ClearDepthStencilView( |
| 399 depth_stencil_view_.get(), D3D10_CLEAR_DEPTH|D3D10_CLEAR_STENCIL, | 399 depth_stencil_view_.get(), D3D10_CLEAR_DEPTH|D3D10_CLEAR_STENCIL, |
| 400 1.0f, 0); | 400 1.0f, 0); |
| 401 | 401 |
| 402 // TODO: these steps may not be necessary each time through. | 402 // TODO: these steps may not be necessary each time through. |
| 403 device_->OMSetDepthStencilState(0, 0); | 403 device_->OMSetDepthStencilState(0, 0); |
| 404 float blend_factors[] = {0.0f, 0.0f, 0.0f, 0.0f}; | 404 float blend_factors[] = {0.0f, 0.0f, 0.0f, 0.0f}; |
| 405 device_->OMSetBlendState(0, blend_factors, 0xffffffff); | 405 device_->OMSetBlendState(0, blend_factors, 0xffffffff); |
| 406 device_->IASetInputLayout(vertex_layout_.get()); | 406 device_->IASetInputLayout(vertex_layout_.get()); |
| 407 device_->IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST); | 407 device_->IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST); |
| 408 } | 408 } |
| 409 | 409 |
| 410 void CompositorWin::NotifyEnd() { | 410 void CompositorWin::OnNotifyEnd() { |
| 411 // Copy from main_render_target_view_| (where all are rendering was done) back | 411 // Copy from main_render_target_view_| (where all are rendering was done) back |
| 412 // to |dest_render_target_view_|. | 412 // to |dest_render_target_view_|. |
| 413 ID3D10RenderTargetView* target_view = dest_render_target_view_.get(); | 413 ID3D10RenderTargetView* target_view = dest_render_target_view_.get(); |
| 414 device_->OMSetRenderTargets(1, &target_view, NULL); | 414 device_->OMSetRenderTargets(1, &target_view, NULL); |
| 415 device_->ClearRenderTargetView(target_view, | 415 device_->ClearRenderTargetView(target_view, |
| 416 D3DXCOLOR(0.0f, 0.0f, 0.0f, 0.0f)); | 416 D3DXCOLOR(0.0f, 0.0f, 0.0f, 0.0f)); |
| 417 RETURN_IF_FAILED( | 417 RETURN_IF_FAILED( |
| 418 fx_->GetVariableByName("textureMap")->AsShaderResource()-> | 418 fx_->GetVariableByName("textureMap")->AsShaderResource()-> |
| 419 SetResource(main_texture_shader_view_.get())); | 419 SetResource(main_texture_shader_view_.get())); |
| 420 D3DXMATRIX identify_matrix; | 420 D3DXMATRIX identify_matrix; |
| (...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 799 | 799 |
| 800 // static | 800 // static |
| 801 Compositor* Compositor::Create(gfx::AcceleratedWidget widget, | 801 Compositor* Compositor::Create(gfx::AcceleratedWidget widget, |
| 802 const gfx::Size& size) { | 802 const gfx::Size& size) { |
| 803 CompositorWin* compositor = new CompositorWin(widget, size); | 803 CompositorWin* compositor = new CompositorWin(widget, size); |
| 804 compositor->Init(); | 804 compositor->Init(); |
| 805 return compositor; | 805 return compositor; |
| 806 } | 806 } |
| 807 | 807 |
| 808 } // namespace ui | 808 } // namespace ui |
| OLD | NEW |