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

Side by Side Diff: content/renderer/webplugin_delegate_proxy.cc

Issue 12487003: Fix painting glitch with text and NPAPI plugins. This was a regression from r167042. The problem wa… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 9 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 | « content/renderer/webplugin_delegate_proxy.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) 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 "content/renderer/webplugin_delegate_proxy.h" 5 #include "content/renderer/webplugin_delegate_proxy.h"
6 6
7 #if defined(TOOLKIT_GTK) 7 #if defined(TOOLKIT_GTK)
8 #include <gtk/gtk.h> 8 #include <gtk/gtk.h>
9 #elif defined(USE_X11) 9 #elif defined(USE_X11)
10 #include <cairo/cairo.h> 10 #include <cairo/cairo.h>
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 188
189 private: 189 private:
190 scoped_refptr<PluginChannelHost> channel_; 190 scoped_refptr<PluginChannelHost> channel_;
191 int instance_id_; 191 int instance_id_;
192 unsigned long resource_id_; 192 unsigned long resource_id_;
193 // Set to true if the response expected is a multibyte response. 193 // Set to true if the response expected is a multibyte response.
194 // For e.g. response for a HTTP byte range request. 194 // For e.g. response for a HTTP byte range request.
195 bool multibyte_response_expected_; 195 bool multibyte_response_expected_;
196 }; 196 };
197 197
198 // Returns true if the given Silverlight 'background' value corresponds to
199 // one that should make the plugin transparent. See:
200 // http://msdn.microsoft.com/en-us/library/cc838148(VS.95).aspx
201 // for possible values.
202 static bool SilverlightColorIsTransparent(const std::string& color) {
203 if (StartsWithASCII(color, "#", false)) {
204 // If it's #ARGB or #AARRGGBB check the alpha; if not it's an RGB form and
205 // it's not transparent.
206 if ((color.length() == 5 && !StartsWithASCII(color, "#F", false)) ||
207 (color.length() == 9 && !StartsWithASCII(color, "#FF", false)))
208 return true;
209 } else if (StartsWithASCII(color, "sc#", false)) {
210 // It's either sc#A,R,G,B or sc#R,G,B; if the former, check the alpha.
211 if (color.length() < 4)
212 return false;
213 std::string value_string = color.substr(3, std::string::npos);
214 std::vector<std::string> components;
215 base::SplitString(value_string, ',', &components);
216 if (components.size() == 4 && !StartsWithASCII(components[0], "1", false))
217 return true;
218 } else if (LowerCaseEqualsASCII(color, "transparent")) {
219 return true;
220 }
221 // Anything else is a named, opaque color or an RGB form with no alpha.
222 return false;
223 }
224
198 } // namespace 225 } // namespace
199 226
200 WebPluginDelegateProxy::WebPluginDelegateProxy( 227 WebPluginDelegateProxy::WebPluginDelegateProxy(
201 const std::string& mime_type, 228 const std::string& mime_type,
202 const base::WeakPtr<RenderViewImpl>& render_view) 229 const base::WeakPtr<RenderViewImpl>& render_view)
203 : render_view_(render_view), 230 : render_view_(render_view),
204 plugin_(NULL), 231 plugin_(NULL),
205 uses_shared_bitmaps_(false), 232 uses_shared_bitmaps_(false),
206 #if defined(OS_MACOSX) 233 #if defined(OS_MACOSX)
207 uses_compositor_(false), 234 uses_compositor_(false),
208 #elif defined(OS_WIN) 235 #elif defined(OS_WIN)
209 dummy_activation_window_(NULL), 236 dummy_activation_window_(NULL),
210 #endif 237 #endif
211 window_(gfx::kNullPluginWindow), 238 window_(gfx::kNullPluginWindow),
212 mime_type_(mime_type), 239 mime_type_(mime_type),
213 instance_id_(MSG_ROUTING_NONE), 240 instance_id_(MSG_ROUTING_NONE),
214 npobject_(NULL), 241 npobject_(NULL),
215 sad_plugin_(NULL), 242 sad_plugin_(NULL),
216 invalidate_pending_(false), 243 invalidate_pending_(false),
244 transparent_(false),
217 front_buffer_index_(0), 245 front_buffer_index_(0),
218 page_url_(render_view_->webview()->mainFrame()->document().url()) { 246 page_url_(render_view_->webview()->mainFrame()->document().url()) {
219 } 247 }
220 248
221 WebPluginDelegateProxy::~WebPluginDelegateProxy() { 249 WebPluginDelegateProxy::~WebPluginDelegateProxy() {
222 if (npobject_) 250 if (npobject_)
223 WebBindings::releaseObject(npobject_); 251 WebBindings::releaseObject(npobject_);
224 } 252 }
225 253
226 WebPluginDelegateProxy::SharedBitmap::SharedBitmap() {} 254 WebPluginDelegateProxy::SharedBitmap::SharedBitmap() {}
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 PluginMsg_Init_Params params; 393 PluginMsg_Init_Params params;
366 params.url = url; 394 params.url = url;
367 params.page_url = page_url_; 395 params.page_url = page_url_;
368 params.arg_names = arg_names; 396 params.arg_names = arg_names;
369 params.arg_values = arg_values; 397 params.arg_values = arg_values;
370 params.host_render_view_routing_id = render_view_->routing_id(); 398 params.host_render_view_routing_id = render_view_->routing_id();
371 params.load_manually = load_manually; 399 params.load_manually = load_manually;
372 400
373 plugin_ = plugin; 401 plugin_ = plugin;
374 402
403 bool flash = LowerCaseEqualsASCII(mime_type_, kFlashPluginSwfMimeType);
404 bool silverlight =
405 StartsWithASCII(mime_type_, "application/x-silverlight", false);
406 for (size_t i = 0; i < arg_names.size(); ++i) {
407 if ((flash && LowerCaseEqualsASCII(arg_names[i], "wmode") &&
408 LowerCaseEqualsASCII(arg_values[i], "transparent")) ||
409 (silverlight && LowerCaseEqualsASCII(arg_names[i], "background") &&
410 SilverlightColorIsTransparent(arg_values[i]))) {
411 transparent_ = true;
412 }
413 }
piman 2013/03/06 00:58:57 Do we really need all that logic? The plugin shoul
jam 2013/03/06 01:58:36 good point, switched to it. we used to default to
414
375 result = false; 415 result = false;
376 Send(new PluginMsg_Init(instance_id_, params, &result)); 416 Send(new PluginMsg_Init(instance_id_, params, &result));
377 417
378 if (!result) 418 if (!result)
379 LOG(ERROR) << "PluginMsg_Init returned false"; 419 LOG(ERROR) << "PluginMsg_Init returned false";
380 420
381 render_view_->RegisterPluginDelegate(this); 421 render_view_->RegisterPluginDelegate(this);
382 422
383 return result; 423 return result;
384 } 424 }
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
718 // a chance that it will begin repainting the back-buffer before we complete 758 // a chance that it will begin repainting the back-buffer before we complete
719 // capturing the data. Buffer flipping would increase that risk because 759 // capturing the data. Buffer flipping would increase that risk because
720 // geometry update is asynchronous, so we don't want to use buffer flipping 760 // geometry update is asynchronous, so we don't want to use buffer flipping
721 // here. 761 // here.
722 UpdateFrontBuffer(offset_rect, false); 762 UpdateFrontBuffer(offset_rect, false);
723 } 763 }
724 764
725 const SkBitmap& bitmap = 765 const SkBitmap& bitmap =
726 front_buffer_canvas()->getDevice()->accessBitmap(false); 766 front_buffer_canvas()->getDevice()->accessBitmap(false);
727 SkPaint paint; 767 SkPaint paint;
728 paint.setXfermodeMode(SkXfermode::kSrcATop_Mode); 768 paint.setXfermodeMode(
769 transparent_ ? SkXfermode::kSrcATop_Mode : SkXfermode::kSrc_Mode);
729 SkIRect src_rect = gfx::RectToSkIRect(offset_rect); 770 SkIRect src_rect = gfx::RectToSkIRect(offset_rect);
730 canvas->drawBitmapRect(bitmap, 771 canvas->drawBitmapRect(bitmap,
731 &src_rect, 772 &src_rect,
732 gfx::RectToSkRect(rect), 773 gfx::RectToSkRect(rect),
733 &paint); 774 &paint);
734 775
735 if (invalidate_pending_) { 776 if (invalidate_pending_) {
736 // Only send the PaintAck message if this paint is in response to an 777 // Only send the PaintAck message if this paint is in response to an
737 // invalidate from the plugin, since this message acts as an access token 778 // invalidate from the plugin, since this message acts as an access token
738 // to ensure only one process is using the transport dib at a time. 779 // to ensure only one process is using the transport dib at a time.
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after
1305 1346
1306 void WebPluginDelegateProxy::OnURLRedirectResponse(bool allow, 1347 void WebPluginDelegateProxy::OnURLRedirectResponse(bool allow,
1307 int resource_id) { 1348 int resource_id) {
1308 if (!plugin_) 1349 if (!plugin_)
1309 return; 1350 return;
1310 1351
1311 plugin_->URLRedirectResponse(allow, resource_id); 1352 plugin_->URLRedirectResponse(allow, resource_id);
1312 } 1353 }
1313 1354
1314 } // namespace content 1355 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/webplugin_delegate_proxy.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698