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

Side by Side Diff: ppapi/proxy/graphics_2d_resource.cc

Issue 1881603002: Added SetLayerTransform to PPAPI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added Graphics2D 1.2 to histograms Created 4 years, 8 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
« no previous file with comments | « ppapi/proxy/graphics_2d_resource.h ('k') | ppapi/proxy/ppapi_messages.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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. 3 // found in the LICENSE file.
4 4
5 #include "ppapi/proxy/graphics_2d_resource.h" 5 #include "ppapi/proxy/graphics_2d_resource.h"
6 6
7 #include "ppapi/c/pp_bool.h" 7 #include "ppapi/c/pp_bool.h"
8 #include "ppapi/c/pp_point.h" 8 #include "ppapi/c/pp_point.h"
9 #include "ppapi/c/pp_rect.h" 9 #include "ppapi/c/pp_rect.h"
10 #include "ppapi/c/pp_resource.h" 10 #include "ppapi/c/pp_resource.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 return PP_FALSE; 106 return PP_FALSE;
107 Post(RENDERER, PpapiHostMsg_Graphics2D_SetScale(scale)); 107 Post(RENDERER, PpapiHostMsg_Graphics2D_SetScale(scale));
108 scale_ = scale; 108 scale_ = scale;
109 return PP_TRUE; 109 return PP_TRUE;
110 } 110 }
111 111
112 float Graphics2DResource::GetScale() { 112 float Graphics2DResource::GetScale() {
113 return scale_; 113 return scale_;
114 } 114 }
115 115
116 PP_Bool Graphics2DResource::SetLayerTransform(float scale,
117 const PP_Point* origin,
118 const PP_Point* translate) {
119 if (scale <= 0.0f)
120 return PP_FALSE;
121 // Adding the origin to the transform.
122 PP_FloatPoint translate_with_origin;
123 translate_with_origin.x = (1 - scale) * origin->x - translate->x;
124 translate_with_origin.y = (1 - scale) * origin->y - translate->y;
125 Post(RENDERER,
126 PpapiHostMsg_Graphics2D_SetLayerTransform(scale, translate_with_origin));
127 return PP_TRUE;
128 }
129
116 int32_t Graphics2DResource::Flush(scoped_refptr<TrackedCallback> callback) { 130 int32_t Graphics2DResource::Flush(scoped_refptr<TrackedCallback> callback) {
117 // If host is not even created, return failure immediately. This can happen 131 // If host is not even created, return failure immediately. This can happen
118 // when failed to initialize (in constructor). 132 // when failed to initialize (in constructor).
119 if (!sent_create_to_renderer()) 133 if (!sent_create_to_renderer())
120 return PP_ERROR_FAILED; 134 return PP_ERROR_FAILED;
121 135
122 if (TrackedCallback::IsPending(current_flush_callback_)) 136 if (TrackedCallback::IsPending(current_flush_callback_))
123 return PP_ERROR_INPROGRESS; // Can't have >1 flush pending. 137 return PP_ERROR_INPROGRESS; // Can't have >1 flush pending.
124 current_flush_callback_ = callback; 138 current_flush_callback_ = callback;
125 139
(...skipping 14 matching lines...) Expand all
140 return result == PP_OK; 154 return result == PP_OK;
141 } 155 }
142 156
143 void Graphics2DResource::OnPluginMsgFlushACK( 157 void Graphics2DResource::OnPluginMsgFlushACK(
144 const ResourceMessageReplyParams& params) { 158 const ResourceMessageReplyParams& params) {
145 current_flush_callback_->Run(params.result()); 159 current_flush_callback_->Run(params.result());
146 } 160 }
147 161
148 } // namespace proxy 162 } // namespace proxy
149 } // namespace ppapi 163 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/graphics_2d_resource.h ('k') | ppapi/proxy/ppapi_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698