| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "cc/output/output_surface.h" | 5 #include "cc/output/output_surface.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 virtual void onContextLost() { client_->DidLoseOutputSurface(); } | 39 virtual void onContextLost() { client_->DidLoseOutputSurface(); } |
| 40 | 40 |
| 41 private: | 41 private: |
| 42 OutputSurfaceClient* client_; | 42 OutputSurfaceClient* client_; |
| 43 }; | 43 }; |
| 44 | 44 |
| 45 OutputSurface::OutputSurface( | 45 OutputSurface::OutputSurface( |
| 46 scoped_ptr<WebKit::WebGraphicsContext3D> context3d) | 46 scoped_ptr<WebKit::WebGraphicsContext3D> context3d) |
| 47 : client_(NULL), | 47 : client_(NULL), |
| 48 context3d_(context3d.Pass()), | 48 context3d_(context3d.Pass()), |
| 49 has_gl_discard_backbuffer_(false) { | 49 has_gl_discard_backbuffer_(false), |
| 50 device_scale_factor_(-1) { |
| 50 } | 51 } |
| 51 | 52 |
| 52 OutputSurface::OutputSurface( | 53 OutputSurface::OutputSurface( |
| 53 scoped_ptr<cc::SoftwareOutputDevice> software_device) | 54 scoped_ptr<cc::SoftwareOutputDevice> software_device) |
| 54 : client_(NULL), | 55 : client_(NULL), |
| 55 software_device_(software_device.Pass()), | 56 software_device_(software_device.Pass()), |
| 56 has_gl_discard_backbuffer_(false) { | 57 has_gl_discard_backbuffer_(false), |
| 58 device_scale_factor_(-1) { |
| 57 } | 59 } |
| 58 | 60 |
| 59 OutputSurface::OutputSurface( | 61 OutputSurface::OutputSurface( |
| 60 scoped_ptr<WebKit::WebGraphicsContext3D> context3d, | 62 scoped_ptr<WebKit::WebGraphicsContext3D> context3d, |
| 61 scoped_ptr<cc::SoftwareOutputDevice> software_device) | 63 scoped_ptr<cc::SoftwareOutputDevice> software_device) |
| 62 : client_(NULL), | 64 : client_(NULL), |
| 63 context3d_(context3d.Pass()), | 65 context3d_(context3d.Pass()), |
| 64 software_device_(software_device.Pass()), | 66 software_device_(software_device.Pass()), |
| 65 has_gl_discard_backbuffer_(false) { | 67 has_gl_discard_backbuffer_(false), |
| 68 device_scale_factor_(-1) { |
| 66 } | 69 } |
| 67 | 70 |
| 68 OutputSurface::~OutputSurface() { | 71 OutputSurface::~OutputSurface() { |
| 69 } | 72 } |
| 70 | 73 |
| 71 bool OutputSurface::ForcedDrawToSoftwareDevice() const { | 74 bool OutputSurface::ForcedDrawToSoftwareDevice() const { |
| 72 return false; | 75 return false; |
| 73 } | 76 } |
| 74 | 77 |
| 75 bool OutputSurface::BindToClient( | 78 bool OutputSurface::BindToClient( |
| (...skipping 29 matching lines...) Expand all Loading... |
| 105 context3d_->ensureBackbufferCHROMIUM(); | 108 context3d_->ensureBackbufferCHROMIUM(); |
| 106 } | 109 } |
| 107 | 110 |
| 108 void OutputSurface::DiscardBackbuffer() { | 111 void OutputSurface::DiscardBackbuffer() { |
| 109 DCHECK(context3d_); | 112 DCHECK(context3d_); |
| 110 if (has_gl_discard_backbuffer_) | 113 if (has_gl_discard_backbuffer_) |
| 111 context3d_->discardBackbufferCHROMIUM(); | 114 context3d_->discardBackbufferCHROMIUM(); |
| 112 } | 115 } |
| 113 | 116 |
| 114 void OutputSurface::Reshape(gfx::Size size, float scale_factor) { | 117 void OutputSurface::Reshape(gfx::Size size, float scale_factor) { |
| 115 DCHECK(context3d_); | 118 if (size == surface_size_ && scale_factor == device_scale_factor_) |
| 116 context3d_->reshapeWithScaleFactor(size.width(), size.height(), scale_factor); | 119 return; |
| 120 |
| 121 surface_size_ = size; |
| 122 device_scale_factor_ = scale_factor; |
| 123 if (context3d_) { |
| 124 context3d_->reshapeWithScaleFactor( |
| 125 size.width(), size.height(), scale_factor); |
| 126 } |
| 127 } |
| 128 |
| 129 gfx::Size OutputSurface::SurfaceSize() const { |
| 130 return surface_size_; |
| 117 } | 131 } |
| 118 | 132 |
| 119 void OutputSurface::BindFramebuffer() { | 133 void OutputSurface::BindFramebuffer() { |
| 120 DCHECK(context3d_); | 134 DCHECK(context3d_); |
| 121 context3d_->bindFramebuffer(GL_FRAMEBUFFER, 0); | 135 context3d_->bindFramebuffer(GL_FRAMEBUFFER, 0); |
| 122 } | 136 } |
| 123 | 137 |
| 124 void OutputSurface::SwapBuffers(const ui::LatencyInfo& latency_info) { | 138 void OutputSurface::SwapBuffers(const ui::LatencyInfo& latency_info) { |
| 125 DCHECK(context3d_); | 139 DCHECK(context3d_); |
| 126 // Note that currently this has the same effect as SwapBuffers; we should | 140 // Note that currently this has the same effect as SwapBuffers; we should |
| 127 // consider exposing a different entry point on WebGraphicsContext3D. | 141 // consider exposing a different entry point on WebGraphicsContext3D. |
| 128 context3d_->prepareTexture(); | 142 context3d_->prepareTexture(); |
| 129 } | 143 } |
| 130 | 144 |
| 131 void OutputSurface::PostSubBuffer(gfx::Rect rect, | 145 void OutputSurface::PostSubBuffer(gfx::Rect rect, |
| 132 const ui::LatencyInfo& latency_info) { | 146 const ui::LatencyInfo& latency_info) { |
| 133 DCHECK(context3d_); | 147 DCHECK(context3d_); |
| 134 context3d_->postSubBufferCHROMIUM( | 148 context3d_->postSubBufferCHROMIUM( |
| 135 rect.x(), rect.y(), rect.width(), rect.height()); | 149 rect.x(), rect.y(), rect.width(), rect.height()); |
| 136 } | 150 } |
| 137 | 151 |
| 138 } // namespace cc | 152 } // namespace cc |
| OLD | NEW |