Bug 1309272, part 3 - Allow DrawTargetSkia to work without an SkSurface. r=mchang
authorLee Salzman <lsalzman@mozilla.com>
Wed, 26 Oct 2016 13:41:07 -0400
changeset 320101 ee15183d057288ccd8b6b22b13b85c540229f736
parent 320100 c974afea821bdd83ebedd3adeefe0bbe87cb1fb5
child 320109 8f8f02af9d17a6c04462cedaab803b89acd681d7
push id20749
push userryanvm@gmail.com
push dateSat, 29 Oct 2016 13:21:21 +0000
treeherderfx-team@1b170b39ed6b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmchang
bugs1309272
milestone52.0a1
Bug 1309272, part 3 - Allow DrawTargetSkia to work without an SkSurface. r=mchang MozReview-Commit-ID: JczfiM0eIct
gfx/2d/DrawTargetSkia.cpp
--- a/gfx/2d/DrawTargetSkia.cpp
+++ b/gfx/2d/DrawTargetSkia.cpp
@@ -268,17 +268,17 @@ DrawTargetSkia::~DrawTargetSkia()
   }
 #endif
 }
 
 already_AddRefed<SourceSurface>
 DrawTargetSkia::Snapshot()
 {
   RefPtr<SourceSurfaceSkia> snapshot = mSnapshot;
-  if (!snapshot) {
+  if (mSurface && !snapshot) {
     snapshot = new SourceSurfaceSkia();
     sk_sp<SkImage> image;
     // If the surface is raster, making a snapshot may trigger a pixel copy.
     // Instead, try to directly make a raster image referencing the surface pixels.
     SkPixmap pixmap;
     if (mSurface->peekPixels(&pixmap)) {
       image = SkImage::MakeFromRaster(pixmap, nullptr, nullptr);
     } else {
@@ -1858,17 +1858,17 @@ DrawTargetSkia::SetTransform(const Matri
   mCanvas->setMatrix(mat);
   mTransform = aTransform;
 }
 
 void*
 DrawTargetSkia::GetNativeSurface(NativeSurfaceType aType)
 {
 #ifdef USE_SKIA_GPU
-  if (aType == NativeSurfaceType::OPENGL_TEXTURE) {
+  if (aType == NativeSurfaceType::OPENGL_TEXTURE && mSurface) {
     GrBackendObject handle = mSurface->getTextureHandle(SkSurface::kFlushRead_BackendHandleAccess);
     if (handle) {
       return (void*)(uintptr_t)reinterpret_cast<GrGLTextureInfo *>(handle)->fID;
     }
   }
 #endif
   return nullptr;
 }
@@ -2109,17 +2109,19 @@ DrawTargetSkia::CreateFilter(FilterType 
 void
 DrawTargetSkia::MarkChanged()
 {
   if (mSnapshot) {
     mSnapshot->DrawTargetWillChange();
     mSnapshot = nullptr;
 
     // Handle copying of any image snapshots bound to the surface.
-    mSurface->notifyContentWillChange(SkSurface::kRetain_ContentChangeMode);
+    if (mSurface) {
+      mSurface->notifyContentWillChange(SkSurface::kRetain_ContentChangeMode);
+    }
   }
 }
 
 void
 DrawTargetSkia::SnapshotDestroyed()
 {
   mSnapshot = nullptr;
 }