Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(531)

Side by Side Diff: ppapi/proxy/ppb_font_proxy.cc

Issue 7206016: Convert most remaining resources to use the API/thunk system. The significant (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/proxy/ppb_font_proxy.h" 5 #include "ppapi/proxy/ppb_font_proxy.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "ppapi/c/dev/ppb_font_dev.h" 8 #include "ppapi/c/dev/ppb_font_dev.h"
9 #include "ppapi/proxy/plugin_dispatcher.h" 9 #include "ppapi/proxy/plugin_dispatcher.h"
10 #include "ppapi/proxy/ppapi_messages.h" 10 #include "ppapi/proxy/ppapi_messages.h"
11 #include "ppapi/proxy/ppb_image_data_proxy.h" 11 #include "ppapi/proxy/ppb_image_data_proxy.h"
12 #include "ppapi/proxy/serialized_var.h" 12 #include "ppapi/proxy/serialized_var.h"
13 #include "ppapi/shared_impl/ppapi_preferences.h" 13 #include "ppapi/shared_impl/ppapi_preferences.h"
14 #include "ppapi/shared_impl/resource_object_base.h" 14 #include "ppapi/shared_impl/resource_object_base.h"
15 #include "ppapi/thunk/enter.h" 15 #include "ppapi/thunk/enter.h"
16 #include "ppapi/thunk/ppb_image_data_api.h" 16 #include "ppapi/thunk/ppb_image_data_api.h"
17 #include "ppapi/thunk/thunk.h" 17 #include "ppapi/thunk/thunk.h"
18 18
19 using ppapi::thunk::EnterResourceNoLock;
19 using ppapi::thunk::PPB_ImageData_API; 20 using ppapi::thunk::PPB_ImageData_API;
20 using ppapi::WebKitForwarding; 21 using ppapi::WebKitForwarding;
21 22
22 namespace pp { 23 namespace pp {
23 namespace proxy { 24 namespace proxy {
24 25
25 namespace { 26 namespace {
26 27
27 bool PPTextRunToTextRun(const PP_TextRun_Dev* run, 28 bool PPTextRunToTextRun(const PP_TextRun_Dev* run,
28 WebKitForwarding::Font::TextRun* output) { 29 WebKitForwarding::Font::TextRun* output) {
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 return result; 142 return result;
142 } 143 }
143 144
144 PP_Bool Font::DrawTextAt(PP_Resource pp_image_data, 145 PP_Bool Font::DrawTextAt(PP_Resource pp_image_data,
145 const PP_TextRun_Dev* text, 146 const PP_TextRun_Dev* text,
146 const PP_Point* position, 147 const PP_Point* position,
147 uint32_t color, 148 uint32_t color,
148 const PP_Rect* clip, 149 const PP_Rect* clip,
149 PP_Bool image_data_is_opaque) { 150 PP_Bool image_data_is_opaque) {
150 // Convert to an ImageData object. 151 // Convert to an ImageData object.
151 ppapi::ResourceObjectBase* image_base = 152 EnterResourceNoLock<PPB_ImageData_API> enter(pp_image_data, true);
152 ppapi::TrackerBase::Get()->GetResourceAPI(pp_image_data); 153 if (enter.failed())
153 if (!image_base)
154 return PP_FALSE; 154 return PP_FALSE;
155 PPB_ImageData_API* image_api = image_base->GetAs<PPB_ImageData_API>(); 155 ImageData* image_data = static_cast<ImageData*>(enter.object());
156 if (!image_api)
157 return PP_FALSE;
158 ImageData* image_data = static_cast<ImageData*>(image_api);
159 156
160 skia::PlatformCanvas* canvas = image_data->mapped_canvas(); 157 skia::PlatformCanvas* canvas = image_data->mapped_canvas();
161 bool needs_unmapping = false; 158 bool needs_unmapping = false;
162 if (!canvas) { 159 if (!canvas) {
163 needs_unmapping = true; 160 needs_unmapping = true;
164 image_data->Map(); 161 image_data->Map();
165 canvas = image_data->mapped_canvas(); 162 canvas = image_data->mapped_canvas();
166 if (!canvas) 163 if (!canvas)
167 return PP_FALSE; // Failure mapping. 164 return PP_FALSE; // Failure mapping.
168 } 165 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 return result; 217 return result;
221 } 218 }
222 219
223 void Font::RunOnWebKitThread(const base::Closure& task) { 220 void Font::RunOnWebKitThread(const base::Closure& task) {
224 GetDispatcher()->PostToWebKitThread(FROM_HERE, task); 221 GetDispatcher()->PostToWebKitThread(FROM_HERE, task);
225 webkit_event_.Wait(); 222 webkit_event_.Wait();
226 } 223 }
227 224
228 } // namespace proxy 225 } // namespace proxy
229 } // namespace pp 226 } // namespace pp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698