| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_view.h" | 5 #include "remoting/client/plugin/pepper_view.h" |
| 6 | 6 |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "ppapi/cpp/graphics_2d.h" | 8 #include "ppapi/cpp/graphics_2d.h" |
| 9 #include "ppapi/cpp/image_data.h" | 9 #include "ppapi/cpp/image_data.h" |
| 10 #include "ppapi/cpp/point.h" | 10 #include "ppapi/cpp/point.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 if (!instance_->CurrentlyOnPluginThread()) { | 41 if (!instance_->CurrentlyOnPluginThread()) { |
| 42 RunTaskOnPluginThread(NewTracedMethod(this, &PepperView::Paint)); | 42 RunTaskOnPluginThread(NewTracedMethod(this, &PepperView::Paint)); |
| 43 return; | 43 return; |
| 44 } | 44 } |
| 45 | 45 |
| 46 TraceContext::tracer()->PrintString("Start Paint."); | 46 TraceContext::tracer()->PrintString("Start Paint."); |
| 47 // TODO(ajwong): We're assuming the native format is BGRA_PREMUL below. This | 47 // TODO(ajwong): We're assuming the native format is BGRA_PREMUL below. This |
| 48 // is wrong. | 48 // is wrong. |
| 49 if (is_static_fill_) { | 49 if (is_static_fill_) { |
| 50 LOG(ERROR) << "Static filling " << static_fill_color_; | 50 LOG(ERROR) << "Static filling " << static_fill_color_; |
| 51 pp::ImageData image(pp::ImageData::GetNativeImageDataFormat(), | 51 pp::ImageData image(instance_, pp::ImageData::GetNativeImageDataFormat(), |
| 52 pp::Size(viewport_width_, viewport_height_), | 52 pp::Size(viewport_width_, viewport_height_), |
| 53 false); | 53 false); |
| 54 if (image.is_null()) { | 54 if (image.is_null()) { |
| 55 LOG(ERROR) << "Unable to allocate image of size: " | 55 LOG(ERROR) << "Unable to allocate image of size: " |
| 56 << viewport_width_ << "x" << viewport_height_; | 56 << viewport_width_ << "x" << viewport_height_; |
| 57 return; | 57 return; |
| 58 } | 58 } |
| 59 | 59 |
| 60 for (int y = 0; y < image.size().height(); y++) { | 60 for (int y = 0; y < image.size().height(); y++) { |
| 61 for (int x = 0; x < image.size().width(); x++) { | 61 for (int x = 0; x < image.size().width(); x++) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 75 } | 75 } |
| 76 TraceContext::tracer()->PrintString("End Paint."); | 76 TraceContext::tracer()->PrintString("End Paint."); |
| 77 } | 77 } |
| 78 | 78 |
| 79 void PepperView::PaintFrame(media::VideoFrame* frame, UpdatedRects* rects) { | 79 void PepperView::PaintFrame(media::VideoFrame* frame, UpdatedRects* rects) { |
| 80 DCHECK(instance_->CurrentlyOnPluginThread()); | 80 DCHECK(instance_->CurrentlyOnPluginThread()); |
| 81 | 81 |
| 82 TraceContext::tracer()->PrintString("Start Paint Frame."); | 82 TraceContext::tracer()->PrintString("Start Paint Frame."); |
| 83 // TODO(ajwong): We're assuming the native format is BGRA_PREMUL below. This | 83 // TODO(ajwong): We're assuming the native format is BGRA_PREMUL below. This |
| 84 // is wrong. | 84 // is wrong. |
| 85 pp::ImageData image(pp::ImageData::GetNativeImageDataFormat(), | 85 pp::ImageData image(instance_, pp::ImageData::GetNativeImageDataFormat(), |
| 86 pp::Size(viewport_width_, viewport_height_), | 86 pp::Size(viewport_width_, viewport_height_), |
| 87 false); | 87 false); |
| 88 if (image.is_null()) { | 88 if (image.is_null()) { |
| 89 LOG(ERROR) << "Unable to allocate image of size: " | 89 LOG(ERROR) << "Unable to allocate image of size: " |
| 90 << frame->width() << "x" << frame->height(); | 90 << frame->width() << "x" << frame->height(); |
| 91 return; | 91 return; |
| 92 } | 92 } |
| 93 | 93 |
| 94 uint32_t* frame_data = | 94 uint32_t* frame_data = |
| 95 reinterpret_cast<uint32_t*>(frame->data(media::VideoFrame::kRGBPlane)); | 95 reinterpret_cast<uint32_t*>(frame->data(media::VideoFrame::kRGBPlane)); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 } | 174 } |
| 175 | 175 |
| 176 // TODO(ajwong): Should we ignore x & y updates? What do those even mean? | 176 // TODO(ajwong): Should we ignore x & y updates? What do those even mean? |
| 177 | 177 |
| 178 // TODO(ajwong): What does viewport x, y mean to a plugin anyways? | 178 // TODO(ajwong): What does viewport x, y mean to a plugin anyways? |
| 179 viewport_x_ = x; | 179 viewport_x_ = x; |
| 180 viewport_y_ = y; | 180 viewport_y_ = y; |
| 181 viewport_width_ = width; | 181 viewport_width_ = width; |
| 182 viewport_height_ = height; | 182 viewport_height_ = height; |
| 183 | 183 |
| 184 graphics2d_ = pp::Graphics2D(pp::Size(viewport_width_, viewport_height_), | 184 graphics2d_ = pp::Graphics2D(instance_, |
| 185 pp::Size(viewport_width_, viewport_height_), |
| 185 false); | 186 false); |
| 186 if (!instance_->BindGraphics(graphics2d_)) { | 187 if (!instance_->BindGraphics(graphics2d_)) { |
| 187 LOG(ERROR) << "Couldn't bind the device context."; | 188 LOG(ERROR) << "Couldn't bind the device context."; |
| 188 return; | 189 return; |
| 189 } | 190 } |
| 190 } | 191 } |
| 191 | 192 |
| 192 void PepperView::AllocateFrame(media::VideoFrame::Format format, | 193 void PepperView::AllocateFrame(media::VideoFrame::Format format, |
| 193 size_t width, | 194 size_t width, |
| 194 size_t height, | 195 size_t height, |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 } | 236 } |
| 236 | 237 |
| 237 void PepperView::OnPaintDone() { | 238 void PepperView::OnPaintDone() { |
| 238 // TODO(ajwong):Probably should set some variable to allow repaints to | 239 // TODO(ajwong):Probably should set some variable to allow repaints to |
| 239 // actually paint. | 240 // actually paint. |
| 240 TraceContext::tracer()->PrintString("Paint flushed"); | 241 TraceContext::tracer()->PrintString("Paint flushed"); |
| 241 return; | 242 return; |
| 242 } | 243 } |
| 243 | 244 |
| 244 } // namespace remoting | 245 } // namespace remoting |
| OLD | NEW |