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 "remoting/client/plugin/pepper_video_renderer_2d.h" | 5 #include "remoting/client/plugin/pepper_video_renderer_2d.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 | 144 |
145 // Create a 2D rendering context with the new dimensions. | 145 // Create a 2D rendering context with the new dimensions. |
146 graphics2d_ = pp::Graphics2D( | 146 graphics2d_ = pp::Graphics2D( |
147 instance_, pp::Size(source_size_.width(), source_size_.height()), true); | 147 instance_, pp::Size(source_size_.width(), source_size_.height()), true); |
148 graphics2d_.SetScale(static_cast<float>(view_size_.width()) / | 148 graphics2d_.SetScale(static_cast<float>(view_size_.width()) / |
149 source_size_.width()); | 149 source_size_.width()); |
150 bool result = instance_->BindGraphics(graphics2d_); | 150 bool result = instance_->BindGraphics(graphics2d_); |
151 DCHECK(result) << "Couldn't bind the device context."; | 151 DCHECK(result) << "Couldn't bind the device context."; |
152 } | 152 } |
153 | 153 |
154 | |
155 if (size_changed || !source_dpi_.equals(frame->dpi())) { | |
156 source_dpi_ = frame->dpi(); | |
157 | |
158 // Notify JavaScript of the change in source size. | |
159 event_handler_->OnVideoSize(source_size_, source_dpi_); | |
160 } | |
161 | |
162 // If Debug dirty region is enabled then emit it. | 154 // If Debug dirty region is enabled then emit it. |
163 if (debug_dirty_region_) | 155 if (debug_dirty_region_) |
164 event_handler_->OnVideoFrameDirtyRegion(frame->updated_region()); | 156 event_handler_->OnVideoFrameDirtyRegion(frame->updated_region()); |
165 | 157 |
166 const pp::ImageData& image_data = | 158 const pp::ImageData& image_data = |
167 static_cast<PepperDesktopFrame*>(frame.get())->buffer(); | 159 static_cast<PepperDesktopFrame*>(frame.get())->buffer(); |
168 for (webrtc::DesktopRegion::Iterator i(frame->updated_region()); !i.IsAtEnd(); | 160 for (webrtc::DesktopRegion::Iterator i(frame->updated_region()); !i.IsAtEnd(); |
169 i.Advance()) { | 161 i.Advance()) { |
170 graphics2d_.PaintImageData(image_data, pp::Point(0, 0), | 162 graphics2d_.PaintImageData(image_data, pp::Point(0, 0), |
171 pp::Rect(i.rect().left(), i.rect().top(), | 163 pp::Rect(i.rect().left(), i.rect().top(), |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 flush_pending_ = false; | 206 flush_pending_ = false; |
215 | 207 |
216 // Call all callbacks for the frames we've just flushed. | 208 // Call all callbacks for the frames we've just flushed. |
217 flushing_frames_done_callbacks_.clear(); | 209 flushing_frames_done_callbacks_.clear(); |
218 | 210 |
219 // Flush again if necessary. | 211 // Flush again if necessary. |
220 Flush(); | 212 Flush(); |
221 } | 213 } |
222 | 214 |
223 } // namespace remoting | 215 } // namespace remoting |
OLD | NEW |