| Index: native_client_sdk/src/libraries/ppapi_simple/ps_context_2d.c
|
| diff --git a/native_client_sdk/src/libraries/ppapi_simple/ps_context_2d.cc b/native_client_sdk/src/libraries/ppapi_simple/ps_context_2d.c
|
| similarity index 76%
|
| rename from native_client_sdk/src/libraries/ppapi_simple/ps_context_2d.cc
|
| rename to native_client_sdk/src/libraries/ppapi_simple/ps_context_2d.c
|
| index d422cf74693f6adf8e422311599609d9c04f6b3c..dc4e04277ba55773c9eaf117ebc7321c14425459 100644
|
| --- a/native_client_sdk/src/libraries/ppapi_simple/ps_context_2d.cc
|
| +++ b/native_client_sdk/src/libraries/ppapi_simple/ps_context_2d.c
|
| @@ -1,6 +1,6 @@
|
| -// Copyright 2013 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.
|
| +/* Copyright (c) 2012 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. */
|
|
|
| #include <stdlib.h>
|
| #include <string.h>
|
| @@ -13,7 +13,6 @@
|
| #include "ppapi/c/ppb_image_data.h"
|
| #include "ppapi/c/ppb_instance.h"
|
| #include "ppapi/c/ppb_view.h"
|
| -#include "ppapi/cpp/image_data.h"
|
|
|
| #include "ppapi_simple/ps.h"
|
| #include "ppapi_simple/ps_context_2d.h"
|
| @@ -22,7 +21,7 @@
|
| #include "ppapi_simple/ps_interface.h"
|
|
|
| PSContext2D_t* PSContext2DAllocate(PP_ImageDataFormat format) {
|
| - PSContext2D_t* ctx = (PSContext2D_t*) malloc(sizeof(PSContext2D_t));
|
| + PSContext2D_t* ctx = (PSContext2D_t*)malloc(sizeof(PSContext2D_t));
|
| memset(ctx, 0, sizeof(PSContext2D_t));
|
|
|
| ctx->format = format;
|
| @@ -48,7 +47,7 @@ PP_ImageDataFormat PSContext2DGetNativeImageDataFormat() {
|
| // Update the 2D context if the message is appropriate, returning non-zero
|
| // if the event was consumed.
|
| int PSContext2DHandleEvent(PSContext2D_t* ctx, PSEvent* event) {
|
| - switch(event->type) {
|
| + switch (event->type) {
|
| case PSE_INSTANCE_DIDCHANGEVIEW: {
|
| struct PP_Rect rect;
|
|
|
| @@ -59,15 +58,13 @@ int PSContext2DHandleEvent(PSContext2D_t* ctx, PSEvent* event) {
|
| ctx->height = rect.size.height;
|
|
|
| // Create an opaque graphic context of the specified size.
|
| - ctx->graphic_2d =
|
| - PSInterfaceGraphics2D()->Create(PSGetInstanceId(), &rect.size,
|
| - PP_TRUE);
|
| + ctx->graphic_2d = PSInterfaceGraphics2D()->Create(PSGetInstanceId(),
|
| + &rect.size, PP_TRUE);
|
|
|
| // Bind the context to so that draws will be visible.
|
| if (ctx->graphic_2d) {
|
| - ctx->bound =
|
| - PSInterfaceInstance()->BindGraphics(PSGetInstanceId(),
|
| - ctx->graphic_2d);
|
| + ctx->bound = PSInterfaceInstance()->BindGraphics(PSGetInstanceId(),
|
| + ctx->graphic_2d);
|
| }
|
|
|
| // Typically this resource would not be allocated yet, but just in case
|
| @@ -79,35 +76,36 @@ int PSContext2DHandleEvent(PSContext2D_t* ctx, PSEvent* event) {
|
|
|
| return 1;
|
| }
|
| - default: break;
|
| + default:
|
| + break;
|
| }
|
|
|
| return 0;
|
| }
|
|
|
| -
|
| // Allocates (if needed) a new image context which will be swapped in when
|
| // drawing is complete. PSContextGetBuffer and PSContext2DSwapBuffer
|
| // implemented the suggested image/graphic_2d use specified in the
|
| // ppb_graphics_2d header.
|
| int PSContext2DGetBuffer(PSContext2D_t* ctx) {
|
| - if (!ctx->bound) return 0;
|
| + if (!ctx->bound)
|
| + return 0;
|
|
|
| // Check if we are already holding an image
|
| - if (ctx->image) return 1;
|
| + if (ctx->image)
|
| + return 1;
|
|
|
| - PP_Size size;
|
| + struct PP_Size size;
|
| size.width = ctx->width;
|
| size.height = ctx->height;
|
|
|
| // Allocate a new image resource with the specified size and format, but
|
| // do not ZERO out the buffer first since we will fill it.
|
| - PP_Resource image =
|
| - PSInterfaceImageData()->Create(PSGetInstanceId(), ctx->format, &size,
|
| - PP_FALSE);
|
| + PP_Resource image = PSInterfaceImageData()->Create(
|
| + PSGetInstanceId(), ctx->format, &size, PP_FALSE);
|
|
|
| if (0 == image) {
|
| - PSInstance::GetInstance()->Error("Unable to create 2D image.\n");
|
| + PSInstanceError("Unable to create 2D image.\n");
|
| return 0;
|
| }
|
|
|
| @@ -116,7 +114,7 @@ int PSContext2DGetBuffer(PSContext2D_t* ctx) {
|
| PSInterfaceImageData()->Describe(image, &desc);
|
|
|
| ctx->image = image;
|
| - ctx->data = static_cast<uint32_t*>(PSInterfaceImageData()->Map(image));
|
| + ctx->data = (uint32_t*)(PSInterfaceImageData()->Map(image));
|
| ctx->stride = desc.stride;
|
| return 1;
|
| }
|
|
|