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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/ImageBuffer.cpp

Issue 2840093002: Allow RecordingImageBufferSurface to prevent fallback. (Closed)
Patch Set: imagebuffer-fallback: missedone Created 3 years, 7 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2008, Google Inc. All rights reserved. 2 * Copyright (c) 2008, Google Inc. All rights reserved.
3 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> 3 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org>
4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. 4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are 7 * modification, are permitted provided that the following conditions are
8 * met: 8 * met:
9 * 9 *
10 * * Redistributions of source code must retain the above copyright 10 * * Redistributions of source code must retain the above copyright
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 } 525 }
526 } 526 }
527 527
528 void ImageBuffer::DisableAcceleration() { 528 void ImageBuffer::DisableAcceleration() {
529 if (!IsAccelerated()) 529 if (!IsAccelerated())
530 return; 530 return;
531 531
532 // Create and configure a recording (unaccelerated) surface. 532 // Create and configure a recording (unaccelerated) surface.
533 std::unique_ptr<ImageBufferSurface> surface = 533 std::unique_ptr<ImageBufferSurface> surface =
534 WTF::WrapUnique(new RecordingImageBufferSurface( 534 WTF::WrapUnique(new RecordingImageBufferSurface(
535 surface_->size(), surface_->GetOpacityMode(), 535 surface_->size(), RecordingImageBufferSurface::kAllowFallback,
536 surface_->color_params())); 536 surface_->GetOpacityMode(), surface_->color_params()));
537 SetSurface(std::move(surface)); 537 SetSurface(std::move(surface));
538 } 538 }
539 539
540 void ImageBuffer::SetSurface(std::unique_ptr<ImageBufferSurface> surface) { 540 void ImageBuffer::SetSurface(std::unique_ptr<ImageBufferSurface> surface) {
541 sk_sp<SkImage> image = 541 sk_sp<SkImage> image =
542 surface_->NewImageSnapshot(kPreferNoAcceleration, kSnapshotReasonPaint); 542 surface_->NewImageSnapshot(kPreferNoAcceleration, kSnapshotReasonPaint);
543 543
544 // image can be null if alloaction failed in which case we should just 544 // image can be null if alloaction failed in which case we should just
545 // abort the surface switch to reatain the old surface which is still 545 // abort the surface switch to reatain the old surface which is still
546 // functional. 546 // functional.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 DCHECK(MIMETypeRegistry::IsSupportedImageMIMETypeForEncoding(mime_type)); 597 DCHECK(MIMETypeRegistry::IsSupportedImageMIMETypeForEncoding(mime_type));
598 598
599 Vector<unsigned char> result; 599 Vector<unsigned char> result;
600 if (!EncodeImage(mime_type, quality, &result)) 600 if (!EncodeImage(mime_type, quality, &result))
601 return "data:,"; 601 return "data:,";
602 602
603 return "data:" + mime_type + ";base64," + Base64Encode(result); 603 return "data:" + mime_type + ";base64," + Base64Encode(result);
604 } 604 }
605 605
606 } // namespace blink 606 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698