Bug 1020629. DrawTargetSkia::CopySurface is broken with A8 surfaces. r=gw280
authorJeff Muizelaar <jmuizelaar@mozilla.com>
Tue, 10 Jun 2014 23:42:32 -0400
changeset 208998 749f66e5319a0def0093ff5fc0f36ed0c5c9ee4b
parent 208997 000b317ce64f5352b55f56ced1907382f3bc6844
child 208999 b256757ec87ecfb9a0986a385d7c13cfa7d3c762
push id3857
push userraliiev@mozilla.com
push dateTue, 02 Sep 2014 16:39:23 +0000
treeherdermozilla-beta@5638b907b505 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgw280
bugs1020629
milestone33.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1020629. DrawTargetSkia::CopySurface is broken with A8 surfaces. r=gw280 If we clear the surface before doing drawBitmap we end up with the right results. This also adds some writePixels code that we could try out later.
content/base/test/csp/chrome.ini
content/base/test/csp/file_CSP.sjs
content/base/test/csp/file_CSP_evalscript_main.html
content/base/test/csp/file_CSP_evalscript_main.html^headers^
content/base/test/csp/file_CSP_evalscript_main.js
content/base/test/csp/file_CSP_evalscript_main_getCRMFRequest.html
content/base/test/csp/file_CSP_evalscript_main_getCRMFRequest.html^headers^
content/base/test/csp/file_CSP_evalscript_main_getCRMFRequest.js
content/base/test/csp/file_CSP_evalscript_no_CSP_at_all.html
content/base/test/csp/file_CSP_evalscript_no_CSP_at_all.html^headers^
content/base/test/csp/file_CSP_evalscript_no_CSP_at_all.js
content/base/test/csp/file_CSP_frameancestors.sjs
content/base/test/csp/file_CSP_frameancestors_main.html
content/base/test/csp/file_CSP_frameancestors_main.js
content/base/test/csp/file_CSP_inlinescript_main.html
content/base/test/csp/file_CSP_inlinescript_main.html^headers^
content/base/test/csp/file_CSP_inlinestyle_main.html
content/base/test/csp/file_CSP_inlinestyle_main.html^headers^
content/base/test/csp/file_CSP_main.html
content/base/test/csp/file_CSP_main.html^headers^
content/base/test/csp/file_CSP_main.js
content/base/test/csp/file_csp_bug768029.html
content/base/test/csp/file_csp_bug768029.sjs
content/base/test/csp/file_csp_bug773891.html
content/base/test/csp/file_csp_bug773891.sjs
content/base/test/csp/file_csp_redirects_main.html
content/base/test/csp/file_csp_redirects_page.sjs
content/base/test/csp/file_csp_redirects_resource.sjs
content/base/test/csp/file_csp_report.sjs
content/base/test/csp/file_multi_policy_injection_bypass.html
content/base/test/csp/file_multi_policy_injection_bypass.html^headers^
content/base/test/csp/file_multi_policy_injection_bypass_2.html
content/base/test/csp/file_multi_policy_injection_bypass_2.html^headers^
content/base/test/csp/file_redirect_content.sjs
content/base/test/csp/file_redirect_report.sjs
content/base/test/csp/file_subframe_run_js_if_allowed.html
content/base/test/csp/file_subframe_run_js_if_allowed.html^headers^
content/base/test/csp/mochitest.ini
content/base/test/csp/moz.build
content/base/test/csp/test_301_redirect.html
content/base/test/csp/test_302_redirect.html
content/base/test/csp/test_303_redirect.html
content/base/test/csp/test_307_redirect.html
content/base/test/csp/test_CSP.html
content/base/test/csp/test_CSP_evalscript.html
content/base/test/csp/test_CSP_evalscript_getCRMFRequest.html
content/base/test/csp/test_CSP_frameancestors.html
content/base/test/csp/test_CSP_inlinescript.html
content/base/test/csp/test_CSP_inlinestyle.html
content/base/test/csp/test_csp_bug768029.html
content/base/test/csp/test_csp_bug773891.html
content/base/test/csp/test_csp_redirects.html
content/base/test/csp/test_multi_policy_injection_bypass.html
content/base/test/csp/test_subframe_run_js_if_allowed.html
gfx/2d/DrawTargetSkia.cpp
js/src/parjs-benchmarks/README.txt
--- a/gfx/2d/DrawTargetSkia.cpp
+++ b/gfx/2d/DrawTargetSkia.cpp
@@ -657,32 +657,55 @@ DrawTargetSkia::CopySurface(SourceSurfac
   if (aSurface->GetType() != SurfaceType::SKIA) {
     return;
   }
 
   MarkChanged();
 
   TempBitmap bitmap = GetBitmapForSurface(aSurface);
 
+  // This is a fast path that is disabled for now to mimimize risk
+  if (false && !bitmap.mBitmap.getTexture() && mCanvas->getDevice()->config() == bitmap.mBitmap.config()) {
+	SkBitmap bm(bitmap.mBitmap);
+	bm.lockPixels();
+	if (bm.getPixels()) {
+	  SkImageInfo info = bm.info();
+	  info.fWidth = aSourceRect.width;
+	  info.fHeight = aSourceRect.height;
+	  uint8_t* pixels = static_cast<uint8_t*>(bm.getPixels());
+	  // adjust pixels for the source offset
+	  pixels += aSourceRect.x + aSourceRect.y*bm.rowBytes();
+	  mCanvas->writePixels(info, pixels, bm.rowBytes(), aDestination.x, aDestination.y);
+	  return;
+	}
+  }
+
   mCanvas->save();
   mCanvas->resetMatrix();
   SkRect dest = IntRectToSkRect(IntRect(aDestination.x, aDestination.y, aSourceRect.width, aSourceRect.height)); 
   SkIRect source = IntRectToSkIRect(aSourceRect);
   mCanvas->clipRect(dest, SkRegion::kReplace_Op);
   SkPaint paint;
 
   if (mCanvas->getDevice()->config() == SkBitmap::kRGB_565_Config) {
     // Set the xfermode to SOURCE_OVER to workaround
     // http://code.google.com/p/skia/issues/detail?id=628
     // RGB565 is opaque so they're equivalent anyway
     paint.setXfermodeMode(SkXfermode::kSrcOver_Mode);
   } else {
     paint.setXfermodeMode(SkXfermode::kSrc_Mode);
   }
-
+  // drawBitmapRect with A8 bitmaps ends up doing a mask operation
+  // so we need to clear before
+  if (bitmap.mBitmap.config() == SkBitmap::kA8_Config) {
+    SkPaint clearPaint;
+    clearPaint.setColor(SkColorSetARGB(0, 0, 0, 0));
+    clearPaint.setXfermodeMode(SkXfermode::kSrc_Mode);
+    mCanvas->drawPaint(clearPaint);
+  }
   mCanvas->drawBitmapRect(bitmap.mBitmap, &source, dest, &paint);
   mCanvas->restore();
 }
 
 bool
 DrawTargetSkia::Init(const IntSize &aSize, SurfaceFormat aFormat)
 {
   SkAutoTUnref<SkBaseDevice> device(new SkBitmapDevice(GfxFormatToSkiaConfig(aFormat),