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

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

Issue 7669055: Remove webkit::ppapi::Resource. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Nulls auditeed Created 9 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
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/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
11 #include "base/task.h" 11 #include "base/task.h"
12 #include "skia/ext/platform_canvas.h" 12 #include "skia/ext/platform_canvas.h"
13 #include "ppapi/c/pp_errors.h" 13 #include "ppapi/c/pp_errors.h"
14 #include "ppapi/c/pp_rect.h" 14 #include "ppapi/c/pp_rect.h"
15 #include "ppapi/c/pp_resource.h" 15 #include "ppapi/c/pp_resource.h"
16 #include "ppapi/c/ppb_graphics_2d.h" 16 #include "ppapi/c/ppb_graphics_2d.h"
17 #include "ppapi/thunk/enter.h" 17 #include "ppapi/thunk/enter.h"
18 #include "ppapi/thunk/thunk.h" 18 #include "ppapi/thunk/thunk.h"
19 #include "third_party/skia/include/core/SkBitmap.h" 19 #include "third_party/skia/include/core/SkBitmap.h"
20 #include "ui/gfx/blit.h" 20 #include "ui/gfx/blit.h"
21 #include "ui/gfx/point.h" 21 #include "ui/gfx/point.h"
22 #include "ui/gfx/rect.h" 22 #include "ui/gfx/rect.h"
23 #include "webkit/plugins/ppapi/common.h" 23 #include "webkit/plugins/ppapi/common.h"
24 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" 24 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
25 #include "webkit/plugins/ppapi/ppb_image_data_impl.h" 25 #include "webkit/plugins/ppapi/ppb_image_data_impl.h"
26 #include "webkit/plugins/ppapi/resource_helper.h"
26 27
27 #if defined(OS_MACOSX) 28 #if defined(OS_MACOSX)
28 #include "base/mac/mac_util.h" 29 #include "base/mac/mac_util.h"
29 #include "base/mac/scoped_cftyperef.h" 30 #include "base/mac/scoped_cftyperef.h"
30 #endif 31 #endif
31 32
32 using ppapi::thunk::EnterResourceNoLock; 33 using ppapi::thunk::EnterResourceNoLock;
33 using ppapi::thunk::PPB_ImageData_API; 34 using ppapi::thunk::PPB_ImageData_API;
34 35
35 namespace webkit { 36 namespace webkit {
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 gfx::Rect paint_src_rect; 144 gfx::Rect paint_src_rect;
144 145
145 // Valid when type == SCROLL. 146 // Valid when type == SCROLL.
146 gfx::Rect scroll_clip_rect; 147 gfx::Rect scroll_clip_rect;
147 int scroll_dx, scroll_dy; 148 int scroll_dx, scroll_dy;
148 149
149 // Valid when type == REPLACE. 150 // Valid when type == REPLACE.
150 scoped_refptr<PPB_ImageData_Impl> replace_image; 151 scoped_refptr<PPB_ImageData_Impl> replace_image;
151 }; 152 };
152 153
153 PPB_Graphics2D_Impl::PPB_Graphics2D_Impl(PluginInstance* instance) 154 PPB_Graphics2D_Impl::PPB_Graphics2D_Impl(PP_Instance instance)
154 : Resource(instance), 155 : Resource(instance),
155 bound_instance_(NULL), 156 bound_instance_(NULL),
156 offscreen_flush_pending_(false), 157 offscreen_flush_pending_(false),
157 is_always_opaque_(false) { 158 is_always_opaque_(false) {
158 } 159 }
159 160
160 PPB_Graphics2D_Impl::~PPB_Graphics2D_Impl() { 161 PPB_Graphics2D_Impl::~PPB_Graphics2D_Impl() {
161 } 162 }
162 163
163 // static 164 // static
164 PP_Resource PPB_Graphics2D_Impl::Create(PluginInstance* instance, 165 PP_Resource PPB_Graphics2D_Impl::Create(PP_Instance instance,
165 const PP_Size& size, 166 const PP_Size& size,
166 PP_Bool is_always_opaque) { 167 PP_Bool is_always_opaque) {
167 scoped_refptr<PPB_Graphics2D_Impl> graphics_2d( 168 scoped_refptr<PPB_Graphics2D_Impl> graphics_2d(
168 new PPB_Graphics2D_Impl(instance)); 169 new PPB_Graphics2D_Impl(instance));
169 if (!graphics_2d->Init(size.width, size.height, 170 if (!graphics_2d->Init(size.width, size.height,
170 PPBoolToBool(is_always_opaque))) { 171 PPBoolToBool(is_always_opaque))) {
171 return 0; 172 return 0;
172 } 173 }
173 return graphics_2d->GetReference(); 174 return graphics_2d->GetReference();
174 } 175 }
175 176
176 bool PPB_Graphics2D_Impl::Init(int width, int height, bool is_always_opaque) { 177 bool PPB_Graphics2D_Impl::Init(int width, int height, bool is_always_opaque) {
177 // The underlying PPB_ImageData_Impl will validate the dimensions. 178 // The underlying PPB_ImageData_Impl will validate the dimensions.
178 image_data_ = new PPB_ImageData_Impl(instance()); 179 image_data_ = new PPB_ImageData_Impl(pp_instance());
179 if (!image_data_->Init(PPB_ImageData_Impl::GetNativeImageDataFormat(), 180 if (!image_data_->Init(PPB_ImageData_Impl::GetNativeImageDataFormat(),
180 width, height, true) || 181 width, height, true) ||
181 !image_data_->Map()) { 182 !image_data_->Map()) {
182 image_data_ = NULL; 183 image_data_ = NULL;
183 return false; 184 return false;
184 } 185 }
185 is_always_opaque_ = is_always_opaque; 186 is_always_opaque_ = is_always_opaque;
186 return true; 187 return true;
187 } 188 }
188 189
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 CGContextRestoreGState(canvas); 482 CGContextRestoreGState(canvas);
482 #else 483 #else
483 SkRect sk_plugin_rect = SkRect::MakeXYWH( 484 SkRect sk_plugin_rect = SkRect::MakeXYWH(
484 SkIntToScalar(plugin_rect.origin().x()), 485 SkIntToScalar(plugin_rect.origin().x()),
485 SkIntToScalar(plugin_rect.origin().y()), 486 SkIntToScalar(plugin_rect.origin().y()),
486 SkIntToScalar(plugin_rect.width()), 487 SkIntToScalar(plugin_rect.width()),
487 SkIntToScalar(plugin_rect.height())); 488 SkIntToScalar(plugin_rect.height()));
488 canvas->save(); 489 canvas->save();
489 canvas->clipRect(sk_plugin_rect); 490 canvas->clipRect(sk_plugin_rect);
490 491
491 if (instance()->IsFullPagePlugin()) { 492 PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this);
493 if (!plugin_instance)
494 return;
495 if (plugin_instance->IsFullPagePlugin()) {
492 // When we're resizing a window with a full-frame plugin, the plugin may 496 // When we're resizing a window with a full-frame plugin, the plugin may
493 // not yet have bound a new device, which will leave parts of the 497 // not yet have bound a new device, which will leave parts of the
494 // background exposed if the window is getting larger. We want this to 498 // background exposed if the window is getting larger. We want this to
495 // show white (typically less jarring) rather than black or uninitialized. 499 // show white (typically less jarring) rather than black or uninitialized.
496 // We don't do this for non-full-frame plugins since we specifically want 500 // We don't do this for non-full-frame plugins since we specifically want
497 // the page background to show through. 501 // the page background to show through.
498 canvas->save(); 502 canvas->save();
499 SkRect image_data_rect = SkRect::MakeXYWH( 503 SkRect image_data_rect = SkRect::MakeXYWH(
500 SkIntToScalar(plugin_rect.origin().x()), 504 SkIntToScalar(plugin_rect.origin().x()),
501 SkIntToScalar(plugin_rect.origin().y()), 505 SkIntToScalar(plugin_rect.origin().y()),
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 } 640 }
637 641
638 bool PPB_Graphics2D_Impl::HasPendingFlush() const { 642 bool PPB_Graphics2D_Impl::HasPendingFlush() const {
639 return !unpainted_flush_callback_.is_null() || 643 return !unpainted_flush_callback_.is_null() ||
640 !painted_flush_callback_.is_null() || 644 !painted_flush_callback_.is_null() ||
641 offscreen_flush_pending_; 645 offscreen_flush_pending_;
642 } 646 }
643 647
644 } // namespace ppapi 648 } // namespace ppapi
645 } // namespace webkit 649 } // namespace webkit
OLDNEW
« no previous file with comments | « webkit/plugins/ppapi/ppb_graphics_2d_impl.h ('k') | webkit/plugins/ppapi/ppb_graphics_3d_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698