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

Side by Side Diff: webkit/tools/pepper_test_plugin/plugin_object.cc

Issue 453015: Update the Pepper APIs to the latest spec for the 2D demo plugin.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/reference_builds/
Patch Set: '' Created 11 years 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
« no previous file with comments | « webkit/tools/pepper_test_plugin/plugin_object.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 SkPoint grad_points[2]; 217 SkPoint grad_points[2];
218 grad_points[0].set(SkIntToScalar(0), SkIntToScalar(0)); 218 grad_points[0].set(SkIntToScalar(0), SkIntToScalar(0));
219 grad_points[1].set(SkIntToScalar(0), SkIntToScalar(height)); 219 grad_points[1].set(SkIntToScalar(0), SkIntToScalar(height));
220 paint.setShader(SkGradientShader::CreateLinear( 220 paint.setShader(SkGradientShader::CreateLinear(
221 grad_points, grad_colors, NULL, 2, SkShader::kRepeat_TileMode)) 221 grad_points, grad_colors, NULL, 2, SkShader::kRepeat_TileMode))
222 ->safeUnref(); 222 ->safeUnref();
223 223
224 canvas.drawPath(path, paint); 224 canvas.drawPath(path, paint);
225 } 225 }
226 226
227 NPPepperExtensions* pepper = NULL; 227 void FlushCallback(NPP instance, NPDeviceContext* context,
228 NPError err, void* user_data) {
229 }
228 230
229 void FlushCallback(NPRenderContext* context, void* user_data) { 231 NPExtensions* extensions = NULL;
230 }
231 232
232 } // namespace 233 } // namespace
233 234
234 235
235 // PluginObject ---------------------------------------------------------------- 236 // PluginObject ----------------------------------------------------------------
236 237
237 PluginObject::PluginObject(NPP npp) 238 PluginObject::PluginObject(NPP npp)
238 : npp_(npp), 239 : npp_(npp),
239 test_object_(browser->createobject(npp, GetTestClass())) { 240 test_object_(browser->createobject(npp, GetTestClass())),
240 if (!pepper) { 241 device2d_(NULL) {
242 if (!extensions) {
241 browser->getvalue(npp_, NPNVPepperExtensions, 243 browser->getvalue(npp_, NPNVPepperExtensions,
242 reinterpret_cast<void*>(&pepper)); 244 reinterpret_cast<void*>(&extensions));
243 CHECK(pepper); 245 CHECK(extensions);
244 } 246 }
247 device2d_ = extensions->acquireDevice(npp, NPPepper2DDevice);
248 CHECK(device2d_);
245 } 249 }
246 250
247 PluginObject::~PluginObject() { 251 PluginObject::~PluginObject() {
252 // FIXME(brettw) destroy the context.
248 browser->releaseobject(test_object_); 253 browser->releaseobject(test_object_);
249 } 254 }
250 255
251 // static 256 // static
252 NPClass* PluginObject::GetPluginClass() { 257 NPClass* PluginObject::GetPluginClass() {
253 return &plugin_class; 258 return &plugin_class;
254 } 259 }
255 260
256 void PluginObject::SetWindow(const NPWindow& window) { 261 void PluginObject::SetWindow(const NPWindow& window) {
257 // File test
258 /* TODO(brettw): remove this when the file stuff is complete. This code is for
259 testing the OpenFileInSandbox function which is not complete.
260 {
261 void* handle = (void*)112358;
262 NPError err = pepper->openFile(npp_,
263 "q:\\prj\\src2\\src\\webkit\\tools\\pepper_test_plugin\\README",
264 &handle);
265 CHECK(err == NPERR_NO_ERROR);
266
267 char buf[256];
268 sprintf(buf, "Got the handle %d", (int)handle);
269 ::MessageBoxA(NULL, buf, "pepper", 0);
270 }*/
271
272 size_.set_width(window.width); 262 size_.set_width(window.width);
273 size_.set_height(window.height); 263 size_.set_height(window.height);
274 264
275 NPRenderContext context; 265 NPDeviceContext2DConfig config;
276 pepper->initializeRender(npp_, NPRenderGraphicsRGBA, &context); 266 NPDeviceContext2D context;
267 device2d_->initializeContext(npp_, &config, &context);
277 268
278 SkBitmap bitmap; 269 SkBitmap bitmap;
279 bitmap.setConfig(SkBitmap::kARGB_8888_Config, window.width, window.height); 270 bitmap.setConfig(SkBitmap::kARGB_8888_Config, window.width, window.height);
280 bitmap.setPixels(context.u.graphicsRgba.region); 271 bitmap.setPixels(context.u.graphicsRgba.region);
281 272
282 SkCanvas canvas(bitmap); 273 SkCanvas canvas(bitmap);
283 DrawSampleBitmap(canvas, window.width, window.height); 274 DrawSampleBitmap(canvas, window.width, window.height);
284 275
285 // TODO(brettw) figure out why this cast is necessary, the functions seem to 276 // TODO(brettw) figure out why this cast is necessary, the functions seem to
286 // match. Could be a calling convention mismatch? 277 // match. Could be a calling convention mismatch?
287 NPFlushRenderContextCallbackPtr callback = 278 NPDeviceFlushContextCallbackPtr callback =
288 reinterpret_cast<NPFlushRenderContextCallbackPtr>(&FlushCallback); 279 reinterpret_cast<NPDeviceFlushContextCallbackPtr>(&FlushCallback);
289 pepper->flushRender(npp_, &context, callback, NULL); 280 device2d_->flushContext(npp_, &context, callback, NULL);
290 } 281 }
OLDNEW
« no previous file with comments | « webkit/tools/pepper_test_plugin/plugin_object.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698