diff options
author | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-27 22:26:50 +0000 |
---|---|---|
committer | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-27 22:26:50 +0000 |
commit | 7a3af28e5355ac738d35d89c4d17c1d918e8d99d (patch) | |
tree | a8622f76f6d928a11445927ca64be4f8a523b21d /ppapi/examples/2d | |
parent | 5698b3b6d0d4535a68c1ac8fe45fc0a55c2ac3ad (diff) | |
download | chromium_src-7a3af28e5355ac738d35d89c4d17c1d918e8d99d.zip chromium_src-7a3af28e5355ac738d35d89c4d17c1d918e8d99d.tar.gz chromium_src-7a3af28e5355ac738d35d89c4d17c1d918e8d99d.tar.bz2 |
Enable building ppapi/examples on Windows.
Fix some comments, and replace variables named "device" with "graphics".
R=brettw@chromium.org
BUG=54005,62585
Review URL: http://codereview.chromium.org/7272007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@90660 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/examples/2d')
-rw-r--r-- | ppapi/examples/2d/graphics_2d_example.c | 34 | ||||
-rw-r--r-- | ppapi/examples/2d/scroll.cc | 9 |
2 files changed, 22 insertions, 21 deletions
diff --git a/ppapi/examples/2d/graphics_2d_example.c b/ppapi/examples/2d/graphics_2d_example.c index d17f99a..aac4225 100644 --- a/ppapi/examples/2d/graphics_2d_example.c +++ b/ppapi/examples/2d/graphics_2d_example.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2010 The Chromium Authors. All rights reserved. +/* Copyright (c) 2011 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ @@ -38,20 +38,20 @@ struct InstanceInfo { /** Linked list of all live instances. */ struct InstanceInfo* all_instances = NULL; -/** Returns a refed resource corresponding to the created device context. */ -PP_Resource MakeAndBindDeviceContext(PP_Instance instance, - const struct PP_Size* size) { - PP_Resource device_context; +/** Returns a refed resource corresponding to the created graphics 2d. */ +PP_Resource MakeAndBindGraphics2D(PP_Instance instance, + const struct PP_Size* size) { + PP_Resource graphics; - device_context = g_graphics_2d_interface->Create(instance, size, PP_FALSE); - if (!device_context) + graphics = g_graphics_2d_interface->Create(instance, size, PP_FALSE); + if (!graphics) return 0; - if (!g_instance_interface->BindGraphics(instance, device_context)) { - g_core_interface->ReleaseResource(device_context); + if (!g_instance_interface->BindGraphics(instance, graphics)) { + g_core_interface->ReleaseResource(graphics); return 0; } - return device_context; + return graphics; } void FlushCompletionCallback(void* user_data, int32_t result) { @@ -59,7 +59,7 @@ void FlushCompletionCallback(void* user_data, int32_t result) { } void Repaint(struct InstanceInfo* instance, const struct PP_Size* size) { - PP_Resource image, device_context; + PP_Resource image, graphics; struct PP_ImageDataDesc image_desc; uint32_t* image_data; int num_words, i; @@ -81,18 +81,18 @@ void Repaint(struct InstanceInfo* instance, const struct PP_Size* size) { for (i = 0; i < num_words; i++) image_data[i] = 0xFF0000FF; - /* Create the device context and paint the image to it. */ - device_context = MakeAndBindDeviceContext(instance->pp_instance, size); - if (!device_context) { + /* Create the graphics 2d and paint the image to it. */ + graphics = MakeAndBindGraphics2D(instance->pp_instance, size); + if (!graphics) { g_core_interface->ReleaseResource(image); return; } - g_graphics_2d_interface->ReplaceContents(device_context, image); - g_graphics_2d_interface->Flush(device_context, + g_graphics_2d_interface->ReplaceContents(graphics, image); + g_graphics_2d_interface->Flush(graphics, PP_MakeCompletionCallback(&FlushCompletionCallback, NULL)); - g_core_interface->ReleaseResource(device_context); + g_core_interface->ReleaseResource(graphics); g_core_interface->ReleaseResource(image); } diff --git a/ppapi/examples/2d/scroll.cc b/ppapi/examples/2d/scroll.cc index e158eac..f8c365a 100644 --- a/ppapi/examples/2d/scroll.cc +++ b/ppapi/examples/2d/scroll.cc @@ -61,7 +61,7 @@ class MyInstance : public pp::Instance, public pp::PaintManager::Client { private: // PaintManager::Client implementation. - virtual bool OnPaint(pp::Graphics2D& device, + virtual bool OnPaint(pp::Graphics2D& graphics, const std::vector<pp::Rect>& paint_rects, const pp::Rect& paint_bounds) { if (!kicked_off_) { @@ -81,15 +81,16 @@ class MyInstance : public pp::Instance, public pp::PaintManager::Client { int x_offset = x_origin % kSquareSpacing; int y_offset = y_origin % kSquareSpacing; - for (int ys = 0; ys < device.size().height() / kSquareSpacing + 2; ys++) { - for (int xs = 0; xs < device.size().width() / kSquareSpacing + 2; xs++) { + for (int ys = 0; ys < graphics.size().height() / kSquareSpacing + 2; ys++) { + for (int xs = 0; xs < graphics.size().width() / kSquareSpacing + 2; + xs++) { int x = xs * kSquareSpacing + x_offset - paint_bounds.x(); int y = ys * kSquareSpacing + y_offset - paint_bounds.y(); FillRect(&updated_image, pp::Rect(x, y, kSquareSize, kSquareSize), 0xFF000000); } } - device.PaintImageData(updated_image, paint_bounds.point()); + graphics.PaintImageData(updated_image, paint_bounds.point()); return true; } |