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