| 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 "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" |
| 11 #include "ppapi/cpp/instance.h" | 11 #include "ppapi/cpp/instance_handle.h" |
| 12 #include "ppapi/cpp/module.h" | 12 #include "ppapi/cpp/module.h" |
| 13 #include "ppapi/cpp/module_impl.h" | 13 #include "ppapi/cpp/module_impl.h" |
| 14 #include "ppapi/cpp/point.h" | 14 #include "ppapi/cpp/point.h" |
| 15 #include "ppapi/cpp/rect.h" | 15 #include "ppapi/cpp/rect.h" |
| 16 | 16 |
| 17 namespace pp { | 17 namespace pp { |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 template <> const char* interface_name<PPB_Graphics2D>() { | 21 template <> const char* interface_name<PPB_Graphics2D>() { |
| 22 return PPB_GRAPHICS_2D_INTERFACE; | 22 return PPB_GRAPHICS_2D_INTERFACE; |
| 23 } | 23 } |
| 24 | 24 |
| 25 } // namespace | 25 } // namespace |
| 26 | 26 |
| 27 Graphics2D::Graphics2D() : Resource() { | 27 Graphics2D::Graphics2D() : Resource() { |
| 28 } | 28 } |
| 29 | 29 |
| 30 Graphics2D::Graphics2D(const Graphics2D& other) | 30 Graphics2D::Graphics2D(const Graphics2D& other) |
| 31 : Resource(other), | 31 : Resource(other), |
| 32 size_(other.size_) { | 32 size_(other.size_) { |
| 33 } | 33 } |
| 34 | 34 |
| 35 Graphics2D::Graphics2D(Instance* instance, | 35 Graphics2D::Graphics2D(const InstanceHandle& instance, |
| 36 const Size& size, | 36 const Size& size, |
| 37 bool is_always_opaque) | 37 bool is_always_opaque) |
| 38 : Resource() { | 38 : Resource() { |
| 39 if (!has_interface<PPB_Graphics2D>()) | 39 if (!has_interface<PPB_Graphics2D>()) |
| 40 return; | 40 return; |
| 41 PassRefFromConstructor(get_interface<PPB_Graphics2D>()->Create( | 41 PassRefFromConstructor(get_interface<PPB_Graphics2D>()->Create( |
| 42 instance->pp_instance(), | 42 instance.pp_instance(), |
| 43 &size.pp_size(), | 43 &size.pp_size(), |
| 44 PP_FromBool(is_always_opaque))); | 44 PP_FromBool(is_always_opaque))); |
| 45 if (!is_null()) { | 45 if (!is_null()) { |
| 46 // Only save the size if allocation succeeded. | 46 // Only save the size if allocation succeeded. |
| 47 size_ = size; | 47 size_ = size; |
| 48 } | 48 } |
| 49 } | 49 } |
| 50 | 50 |
| 51 Graphics2D::~Graphics2D() { | 51 Graphics2D::~Graphics2D() { |
| 52 } | 52 } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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>()) | 101 if (!has_interface<PPB_Graphics2D>()) |
| 102 return cc.MayForce(PP_ERROR_NOINTERFACE); | 102 return cc.MayForce(PP_ERROR_NOINTERFACE); |
| 103 return get_interface<PPB_Graphics2D>()->Flush(pp_resource(), | 103 return get_interface<PPB_Graphics2D>()->Flush(pp_resource(), |
| 104 cc.pp_completion_callback()); | 104 cc.pp_completion_callback()); |
| 105 } | 105 } |
| 106 | 106 |
| 107 } // namespace pp | 107 } // namespace pp |
| OLD | NEW |