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/proxy/graphics_2d_resource.h" | 5 #include "ppapi/proxy/graphics_2d_resource.h" |
6 | 6 |
7 #include "ppapi/c/pp_bool.h" | 7 #include "ppapi/c/pp_bool.h" |
8 #include "ppapi/c/pp_point.h" | 8 #include "ppapi/c/pp_point.h" |
9 #include "ppapi/c/pp_rect.h" | 9 #include "ppapi/c/pp_rect.h" |
10 #include "ppapi/c/pp_resource.h" | 10 #include "ppapi/c/pp_resource.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 Log(PP_LOGLEVEL_ERROR, | 92 Log(PP_LOGLEVEL_ERROR, |
93 "Graphics2DResource.PaintImageData: Bad image resource."); | 93 "Graphics2DResource.PaintImageData: Bad image resource."); |
94 return; | 94 return; |
95 } | 95 } |
96 enter_image.object()->SetIsCandidateForReuse(); | 96 enter_image.object()->SetIsCandidateForReuse(); |
97 | 97 |
98 Post(RENDERER, PpapiHostMsg_Graphics2D_ReplaceContents( | 98 Post(RENDERER, PpapiHostMsg_Graphics2D_ReplaceContents( |
99 image_object->host_resource())); | 99 image_object->host_resource())); |
100 } | 100 } |
101 | 101 |
102 bool Graphics2DResource::SetScale(float scale) { | 102 PP_Bool Graphics2DResource::SetScale(float scale) { |
103 if (scale <= 0.0f) | 103 if (scale <= 0.0f) |
104 return false; | 104 return PP_FALSE; |
105 Post(RENDERER, PpapiHostMsg_Graphics2D_Dev_SetScale(scale)); | 105 Post(RENDERER, PpapiHostMsg_Graphics2D_Dev_SetScale(scale)); |
106 scale_ = scale; | 106 scale_ = scale; |
107 return true; | 107 return PP_TRUE; |
108 } | 108 } |
109 | 109 |
110 float Graphics2DResource::GetScale() { | 110 float Graphics2DResource::GetScale() { |
111 return scale_; | 111 return scale_; |
112 } | 112 } |
113 | 113 |
114 int32_t Graphics2DResource::Flush(scoped_refptr<TrackedCallback> callback, | 114 int32_t Graphics2DResource::Flush(scoped_refptr<TrackedCallback> callback) { |
115 PP_Resource* old_image_data) { | |
116 // If host is not even created, return failure immediately. This can happen | 115 // If host is not even created, return failure immediately. This can happen |
117 // when failed to initialize (in constructor). | 116 // when failed to initialize (in constructor). |
118 if (!sent_create_to_renderer()) | 117 if (!sent_create_to_renderer()) |
119 return PP_ERROR_FAILED; | 118 return PP_ERROR_FAILED; |
120 | 119 |
121 // We don't support this feature, it's for in-renderer only. | |
122 if (old_image_data) | |
123 *old_image_data = 0; | |
124 | |
125 if (TrackedCallback::IsPending(current_flush_callback_)) | 120 if (TrackedCallback::IsPending(current_flush_callback_)) |
126 return PP_ERROR_INPROGRESS; // Can't have >1 flush pending. | 121 return PP_ERROR_INPROGRESS; // Can't have >1 flush pending. |
127 current_flush_callback_ = callback; | 122 current_flush_callback_ = callback; |
128 | 123 |
129 Call<PpapiPluginMsg_Graphics2D_FlushAck>( | 124 Call<PpapiPluginMsg_Graphics2D_FlushAck>( |
130 RENDERER, | 125 RENDERER, |
131 PpapiHostMsg_Graphics2D_Flush(), | 126 PpapiHostMsg_Graphics2D_Flush(), |
132 base::Bind(&Graphics2DResource::OnPluginMsgFlushACK, this)); | 127 base::Bind(&Graphics2DResource::OnPluginMsgFlushACK, this)); |
133 return PP_OK_COMPLETIONPENDING; | 128 return PP_OK_COMPLETIONPENDING; |
134 } | 129 } |
135 | 130 |
136 bool Graphics2DResource::ReadImageData(PP_Resource image, | 131 bool Graphics2DResource::ReadImageData(PP_Resource image, |
137 const PP_Point* top_left) { | 132 const PP_Point* top_left) { |
138 if (!top_left) | 133 if (!top_left) |
139 return false; | 134 return false; |
140 int32_t result = SyncCall<PpapiPluginMsg_Graphics2D_ReadImageDataAck>( | 135 int32_t result = SyncCall<PpapiPluginMsg_Graphics2D_ReadImageDataAck>( |
141 RENDERER, | 136 RENDERER, |
142 PpapiHostMsg_Graphics2D_ReadImageData(image, *top_left)); | 137 PpapiHostMsg_Graphics2D_ReadImageData(image, *top_left)); |
143 return result == PP_OK; | 138 return result == PP_OK; |
144 } | 139 } |
145 | 140 |
146 void Graphics2DResource::OnPluginMsgFlushACK( | 141 void Graphics2DResource::OnPluginMsgFlushACK( |
147 const ResourceMessageReplyParams& params) { | 142 const ResourceMessageReplyParams& params) { |
148 current_flush_callback_->Run(params.result()); | 143 current_flush_callback_->Run(params.result()); |
149 } | 144 } |
150 | 145 |
151 } // namespace proxy | 146 } // namespace proxy |
152 } // namespace ppapi | 147 } // namespace ppapi |
OLD | NEW |