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

Side by Side Diff: webkit/plugins/ppapi/ppb_graphics_2d_impl.cc

Issue 8801027: Always run Flush completion callbacks in Graphics2D. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Really fix compile Created 9 years 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 | « webkit/plugins/ppapi/ppb_graphics_2d_impl.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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "webkit/plugins/ppapi/ppb_graphics_2d_impl.h" 5 #include "webkit/plugins/ppapi/ppb_graphics_2d_impl.h"
6 6
7 #include <iterator> 7 #include <iterator>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 154
155 PPB_Graphics2D_Impl::PPB_Graphics2D_Impl(PP_Instance instance) 155 PPB_Graphics2D_Impl::PPB_Graphics2D_Impl(PP_Instance instance)
156 : Resource(instance), 156 : Resource(instance),
157 bound_instance_(NULL), 157 bound_instance_(NULL),
158 offscreen_flush_pending_(false), 158 offscreen_flush_pending_(false),
159 is_always_opaque_(false), 159 is_always_opaque_(false),
160 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { 160 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
161 } 161 }
162 162
163 PPB_Graphics2D_Impl::~PPB_Graphics2D_Impl() { 163 PPB_Graphics2D_Impl::~PPB_Graphics2D_Impl() {
164 // LastPluginRefWasDeleted should have aborted all pending callbacks.
165 DCHECK(painted_flush_callback_.is_null());
166 DCHECK(unpainted_flush_callback_.is_null());
164 } 167 }
165 168
166 // static 169 // static
167 PP_Resource PPB_Graphics2D_Impl::Create(PP_Instance instance, 170 PP_Resource PPB_Graphics2D_Impl::Create(PP_Instance instance,
168 const PP_Size& size, 171 const PP_Size& size,
169 PP_Bool is_always_opaque) { 172 PP_Bool is_always_opaque) {
170 scoped_refptr<PPB_Graphics2D_Impl> graphics_2d( 173 scoped_refptr<PPB_Graphics2D_Impl> graphics_2d(
171 new PPB_Graphics2D_Impl(instance)); 174 new PPB_Graphics2D_Impl(instance));
172 if (!graphics_2d->Init(size.width, size.height, 175 if (!graphics_2d->Init(size.width, size.height,
173 PPBoolToBool(is_always_opaque))) { 176 PPBoolToBool(is_always_opaque))) {
(...skipping 13 matching lines...) Expand all
187 } 190 }
188 is_always_opaque_ = is_always_opaque; 191 is_always_opaque_ = is_always_opaque;
189 return true; 192 return true;
190 } 193 }
191 194
192 ::ppapi::thunk::PPB_Graphics2D_API* 195 ::ppapi::thunk::PPB_Graphics2D_API*
193 PPB_Graphics2D_Impl::AsPPB_Graphics2D_API() { 196 PPB_Graphics2D_Impl::AsPPB_Graphics2D_API() {
194 return this; 197 return this;
195 } 198 }
196 199
197 PPB_Graphics2D_Impl* PPB_Graphics2D_Impl::AsPPB_Graphics2D_Impl() { 200 void PPB_Graphics2D_Impl::LastPluginRefWasDeleted() {
198 return this; 201 Resource::LastPluginRefWasDeleted();
202
203 // Abort any pending callbacks.
204 if (!unpainted_flush_callback_.is_null())
205 unpainted_flush_callback_.Execute(PP_ERROR_ABORTED);
206 if (!painted_flush_callback_.is_null())
207 painted_flush_callback_.Execute(PP_ERROR_ABORTED);
199 } 208 }
200 209
201 PP_Bool PPB_Graphics2D_Impl::Describe(PP_Size* size, 210 PP_Bool PPB_Graphics2D_Impl::Describe(PP_Size* size,
202 PP_Bool* is_always_opaque) { 211 PP_Bool* is_always_opaque) {
203 size->width = image_data_->width(); 212 size->width = image_data_->width();
204 size->height = image_data_->height(); 213 size->height = image_data_->height();
205 *is_always_opaque = PP_FromBool(is_always_opaque_); 214 *is_always_opaque = PP_FromBool(is_always_opaque_);
206 return PP_TRUE; 215 return PP_TRUE;
207 } 216 }
208 217
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 // |unpainted_flush_callback_| in the header for more. 542 // |unpainted_flush_callback_| in the header for more.
534 if (!unpainted_flush_callback_.is_null()) { 543 if (!unpainted_flush_callback_.is_null()) {
535 DCHECK(painted_flush_callback_.is_null()); 544 DCHECK(painted_flush_callback_.is_null());
536 std::swap(painted_flush_callback_, unpainted_flush_callback_); 545 std::swap(painted_flush_callback_, unpainted_flush_callback_);
537 } 546 }
538 } 547 }
539 548
540 void PPB_Graphics2D_Impl::ViewFlushedPaint() { 549 void PPB_Graphics2D_Impl::ViewFlushedPaint() {
541 // Notify any "painted" callback. See |unpainted_flush_callback_| in the 550 // Notify any "painted" callback. See |unpainted_flush_callback_| in the
542 // header for more. 551 // header for more.
543 if (!painted_flush_callback_.is_null()) { 552 if (!painted_flush_callback_.is_null())
544 // We must clear this variable before issuing the callback. It will be 553 painted_flush_callback_.Execute(PP_OK);
545 // common for the plugin to issue another invalidate in response to a flush
546 // callback, and we don't want to think that a callback is already pending.
547 FlushCallbackData callback;
548 std::swap(callback, painted_flush_callback_);
549 callback.Execute(PP_OK);
550 }
551 } 554 }
552 555
553 void PPB_Graphics2D_Impl::ExecutePaintImageData(PPB_ImageData_Impl* image, 556 void PPB_Graphics2D_Impl::ExecutePaintImageData(PPB_ImageData_Impl* image,
554 int x, int y, 557 int x, int y,
555 const gfx::Rect& src_rect, 558 const gfx::Rect& src_rect,
556 gfx::Rect* invalidated_rect) { 559 gfx::Rect* invalidated_rect) {
557 // Ensure the source image is mapped to read from it. 560 // Ensure the source image is mapped to read from it.
558 ImageDataAutoMapper auto_mapper(image); 561 ImageDataAutoMapper auto_mapper(image);
559 if (!auto_mapper.is_valid()) 562 if (!auto_mapper.is_valid())
560 return; 563 return;
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 } 643 }
641 644
642 bool PPB_Graphics2D_Impl::HasPendingFlush() const { 645 bool PPB_Graphics2D_Impl::HasPendingFlush() const {
643 return !unpainted_flush_callback_.is_null() || 646 return !unpainted_flush_callback_.is_null() ||
644 !painted_flush_callback_.is_null() || 647 !painted_flush_callback_.is_null() ||
645 offscreen_flush_pending_; 648 offscreen_flush_pending_;
646 } 649 }
647 650
648 } // namespace ppapi 651 } // namespace ppapi
649 } // namespace webkit 652 } // namespace webkit
OLDNEW
« no previous file with comments | « webkit/plugins/ppapi/ppb_graphics_2d_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698