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

Side by Side Diff: native_client_sdk/src/libraries/ppapi_simple/ps_context_2d.cc

Issue 23072027: Merge 217400 "Change ppapi_simple to support pixel format select..." (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1599/src/
Patch Set: Created 7 years, 4 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
« no previous file with comments | « native_client_sdk/src/libraries/ppapi_simple/ps_context_2d.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 // Copyright 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.auto 3 // found in the LICENSE file.
4 4
5 #include <stdlib.h> 5 #include <stdlib.h>
6 #include <string.h> 6 #include <string.h>
7 7
8 #include "ppapi/c/pp_rect.h" 8 #include "ppapi/c/pp_rect.h"
9 #include "ppapi/c/pp_resource.h" 9 #include "ppapi/c/pp_resource.h"
10 #include "ppapi/c/pp_size.h" 10 #include "ppapi/c/pp_size.h"
11 #include "ppapi/c/ppb_core.h" 11 #include "ppapi/c/ppb_core.h"
12 #include "ppapi/c/ppb_graphics_2d.h" 12 #include "ppapi/c/ppb_graphics_2d.h"
13 #include "ppapi/c/ppb_image_data.h" 13 #include "ppapi/c/ppb_image_data.h"
14 #include "ppapi/c/ppb_instance.h" 14 #include "ppapi/c/ppb_instance.h"
15 #include "ppapi/c/ppb_view.h" 15 #include "ppapi/c/ppb_view.h"
16 #include "ppapi/cpp/image_data.h" 16 #include "ppapi/cpp/image_data.h"
17 17
18 #include "ppapi_simple/ps.h" 18 #include "ppapi_simple/ps.h"
19 #include "ppapi_simple/ps_context_2d.h" 19 #include "ppapi_simple/ps_context_2d.h"
20 #include "ppapi_simple/ps_event.h" 20 #include "ppapi_simple/ps_event.h"
21 #include "ppapi_simple/ps_instance.h" 21 #include "ppapi_simple/ps_instance.h"
22 #include "ppapi_simple/ps_interface.h" 22 #include "ppapi_simple/ps_interface.h"
23 23
24 PSContext2D_t* PSContext2DAllocate() { 24 PSContext2D_t* PSContext2DAllocate(PP_ImageDataFormat format) {
25 PSContext2D_t* ctx = (PSContext2D_t*) malloc(sizeof(PSContext2D_t)); 25 PSContext2D_t* ctx = (PSContext2D_t*) malloc(sizeof(PSContext2D_t));
26 memset(ctx, 0, sizeof(PSContext2D_t)); 26 memset(ctx, 0, sizeof(PSContext2D_t));
27 27
28 ctx->format = PSInterfaceImageData()->GetNativeImageDataFormat(); 28 ctx->format = format;
29 return ctx; 29 return ctx;
30 } 30 }
31 31
32 void PSContext2DFree(PSContext2D_t* ctx) { 32 void PSContext2DFree(PSContext2D_t* ctx) {
33 if (ctx->graphic_2d) { 33 if (ctx->graphic_2d) {
34 PSInterfaceCore()->ReleaseResource(ctx->graphic_2d); 34 PSInterfaceCore()->ReleaseResource(ctx->graphic_2d);
35 ctx->graphic_2d = 0; 35 ctx->graphic_2d = 0;
36 } 36 }
37 if (ctx->image) { 37 if (ctx->image) {
38 PSInterfaceCore()->ReleaseResource(ctx->image); 38 PSInterfaceCore()->ReleaseResource(ctx->image);
39 ctx->image = 0; 39 ctx->image = 0;
40 } 40 }
41 free(ctx); 41 free(ctx);
42 } 42 }
43 43
44 PP_ImageDataFormat PSContext2DGetNativeImageDataFormat() {
45 return PSInterfaceImageData()->GetNativeImageDataFormat();
46 }
47
44 // Update the 2D context if the message is appropriate, returning non-zero 48 // Update the 2D context if the message is appropriate, returning non-zero
45 // if the event was consumed. 49 // if the event was consumed.
46 int PSContext2DHandleEvent(PSContext2D_t* ctx, PSEvent* event) { 50 int PSContext2DHandleEvent(PSContext2D_t* ctx, PSEvent* event) {
47 switch(event->type) { 51 switch(event->type) {
48 case PSE_INSTANCE_DIDCHANGEVIEW: { 52 case PSE_INSTANCE_DIDCHANGEVIEW: {
49 struct PP_Rect rect; 53 struct PP_Rect rect;
50 54
51 PSInterfaceView()->GetRect(event->as_resource, &rect); 55 PSInterfaceView()->GetRect(event->as_resource, &rect);
52 PSInterfaceCore()->ReleaseResource(ctx->graphic_2d); 56 PSInterfaceCore()->ReleaseResource(ctx->graphic_2d);
53 ctx->bound = 0; 57 ctx->bound = 0;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 PSInterfaceCore()->ReleaseResource(ctx->image); 129 PSInterfaceCore()->ReleaseResource(ctx->image);
126 130
127 ctx->image = 0; 131 ctx->image = 0;
128 ctx->stride = 0; 132 ctx->stride = 0;
129 ctx->data = NULL; 133 ctx->data = NULL;
130 return 1; 134 return 1;
131 } 135 }
132 return 0; 136 return 0;
133 } 137 }
134 138
OLDNEW
« no previous file with comments | « native_client_sdk/src/libraries/ppapi_simple/ps_context_2d.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698