Home | History | Annotate | Download | only in ppapi_simple
      1 /* Copyright 2013 The Chromium Authors. All rights reserved.
      2  * Use of this source code is governed by a BSD-style license that can be
      3  * found in the LICENSE file. */
      4 
      5 #ifndef PPAPI_SIMPLE_PS_CONTEXT_2D_H_
      6 #define PPAPI_SIMPLE_PS_CONTEXT_2D_H_
      7 
      8 #include "ppapi/c/pp_resource.h"
      9 #include "ppapi/c/ppb_graphics_2d.h"
     10 #include "ppapi/c/ppb_image_data.h"
     11 
     12 #include "ppapi_simple/ps_event.h"
     13 
     14 #include "sdk_util/macros.h"
     15 
     16 EXTERN_C_BEGIN
     17 
     18 typedef struct {
     19   int bound;
     20   int32_t width;
     21   int32_t height;
     22   uint32_t stride;
     23   uint32_t* data;
     24   PP_ImageDataFormat format;
     25   PP_Resource graphic_2d;
     26   PP_Resource image;
     27 } PSContext2D_t;
     28 
     29 
     30 /*
     31  * PSContext2DAllocate
     32  *
     33  * Allocate or free a 2D context object which the library can use to perform
     34  * various PPAPI operations on the developer's behalf, such as processing view
     35  * change events, swapping buffers, etc...
     36  */
     37 PSContext2D_t* PSContext2DAllocate(PP_ImageDataFormat format);
     38 void PSContext2DFree(PSContext2D_t* ctx);
     39 
     40 /*
     41  * PSContext2DGetNativeFormat
     42  *
     43  * Query the native system image format.
     44  */
     45 PP_ImageDataFormat PSContext2DGetNativeImageDataFormat();
     46 
     47 /*
     48  * PSContext2DHandleEvent
     49  *
     50  * Updates the context such as allocating, freeing, or sizing graphics and
     51  * image resources in response to events.
     52  */
     53 int PSContext2DHandleEvent(PSContext2D_t* ctx, PSEvent* event);
     54 
     55 /*
     56  * PSContext2DGetBuffer
     57  *
     58  * Points the data member of the context to the raw pixels of the image for
     59  * writing to the screen.  The image will become visible after a swap.
     60  */
     61 int PSContext2DGetBuffer(PSContext2D_t* ctx);
     62 
     63 /*
     64  * PSContext2DSwapBuffer
     65  *
     66  * Swaps out the currently visible graphics with the data stored in the image
     67  * buffer making it visible.  The old image resource will no longer be
     68  * available after this call.
     69  */
     70 int PSContext2DSwapBuffer(PSContext2D_t* ctx);
     71 
     72 EXTERN_C_END
     73 
     74 #endif  /* PPAPI_SIMPLE_PS_CONTEXT_2D_H_ */
     75