| 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 "ppapi/cpp/graphics_2d.h" | 5 #include "ppapi/cpp/graphics_2d.h" |
| 6 | 6 |
| 7 #include "ppapi/c/pp_errors.h" | 7 #include "ppapi/c/pp_errors.h" |
| 8 #include "ppapi/c/ppb_graphics_2d.h" | 8 #include "ppapi/c/ppb_graphics_2d.h" |
| 9 #include "ppapi/cpp/completion_callback.h" | 9 #include "ppapi/cpp/completion_callback.h" |
| 10 #include "ppapi/cpp/image_data.h" | 10 #include "ppapi/cpp/image_data.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 Resource::operator=(other); | 55 Resource::operator=(other); |
| 56 size_ = other.size_; | 56 size_ = other.size_; |
| 57 return *this; | 57 return *this; |
| 58 } | 58 } |
| 59 | 59 |
| 60 void Graphics2D::PaintImageData(const ImageData& image, | 60 void Graphics2D::PaintImageData(const ImageData& image, |
| 61 const Point& top_left) { | 61 const Point& top_left) { |
| 62 if (!has_interface<PPB_Graphics2D_1_0>()) | 62 if (!has_interface<PPB_Graphics2D_1_0>()) |
| 63 return; | 63 return; |
| 64 get_interface<PPB_Graphics2D_1_0>()->PaintImageData(pp_resource(), | 64 get_interface<PPB_Graphics2D_1_0>()->PaintImageData(pp_resource(), |
| 65 image.pp_resource(), | 65 image.pp_resource(), |
| 66 &top_left.pp_point(), | 66 &top_left.pp_point(), |
| 67 NULL); | 67 NULL); |
| 68 } | 68 } |
| 69 | 69 |
| 70 void Graphics2D::PaintImageData(const ImageData& image, | 70 void Graphics2D::PaintImageData(const ImageData& image, |
| 71 const Point& top_left, | 71 const Point& top_left, |
| 72 const Rect& src_rect) { | 72 const Rect& src_rect) { |
| 73 if (!has_interface<PPB_Graphics2D_1_0>()) | 73 if (!has_interface<PPB_Graphics2D_1_0>()) |
| 74 return; | 74 return; |
| 75 get_interface<PPB_Graphics2D_1_0>()->PaintImageData(pp_resource(), | 75 get_interface<PPB_Graphics2D_1_0>()->PaintImageData(pp_resource(), |
| 76 image.pp_resource(), | 76 image.pp_resource(), |
| 77 &top_left.pp_point(), | 77 &top_left.pp_point(), |
| 78 &src_rect.pp_rect()); | 78 &src_rect.pp_rect()); |
| 79 } | 79 } |
| 80 | 80 |
| 81 void Graphics2D::Scroll(const Rect& clip, const Point& amount) { | 81 void Graphics2D::Scroll(const Rect& clip, const Point& amount) { |
| 82 if (!has_interface<PPB_Graphics2D_1_0>()) | 82 if (!has_interface<PPB_Graphics2D_1_0>()) |
| 83 return; | 83 return; |
| 84 get_interface<PPB_Graphics2D_1_0>()->Scroll(pp_resource(), | 84 get_interface<PPB_Graphics2D_1_0>()->Scroll(pp_resource(), |
| 85 &clip.pp_rect(), | 85 &clip.pp_rect(), |
| 86 &amount.pp_point()); | 86 &amount.pp_point()); |
| 87 } | 87 } |
| 88 | 88 |
| 89 void Graphics2D::ReplaceContents(ImageData* image) { | 89 void Graphics2D::ReplaceContents(ImageData* image) { |
| 90 if (!has_interface<PPB_Graphics2D_1_0>()) | 90 if (!has_interface<PPB_Graphics2D_1_0>()) |
| 91 return; | 91 return; |
| 92 get_interface<PPB_Graphics2D_1_0>()->ReplaceContents(pp_resource(), | 92 get_interface<PPB_Graphics2D_1_0>()->ReplaceContents(pp_resource(), |
| 93 image->pp_resource()); | 93 image->pp_resource()); |
| 94 | 94 |
| 95 // On success, reset the image data. This is to help prevent people | 95 // On success, reset the image data. This is to help prevent people |
| 96 // from continuing to use the resource which will result in artifacts. | 96 // from continuing to use the resource which will result in artifacts. |
| 97 *image = ImageData(); | 97 *image = ImageData(); |
| 98 } | 98 } |
| 99 | 99 |
| 100 int32_t Graphics2D::Flush(const CompletionCallback& cc) { | 100 int32_t Graphics2D::Flush(const CompletionCallback& cc) { |
| 101 if (!has_interface<PPB_Graphics2D_1_0>()) | 101 if (!has_interface<PPB_Graphics2D_1_0>()) |
| 102 return cc.MayForce(PP_ERROR_NOINTERFACE); | 102 return cc.MayForce(PP_ERROR_NOINTERFACE); |
| 103 return get_interface<PPB_Graphics2D_1_0>()->Flush(pp_resource(), | 103 return get_interface<PPB_Graphics2D_1_0>()->Flush( |
| 104 cc.pp_completion_callback()); | 104 pp_resource(), cc.pp_completion_callback()); |
| 105 } | 105 } |
| 106 | 106 |
| 107 } // namespace pp | 107 } // namespace pp |
| OLD | NEW |