• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2019 Google LLC.
2 // Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
3 #include "tools/fiddle/examples.h"
4 // HASH=45bca8747b8f49b5be34b520897ef048
5 REG_FIDDLE(Image_MakeCrossContextFromPixmap, 256, 64, false, 4) {
draw(SkCanvas * canvas)6 void draw(SkCanvas* canvas) {
7     auto dContext = GrAsDirectContext(canvas->recordingContext());
8     if (!dContext) {
9         return;
10     }
11 
12     SkPixmap pixmap;
13     if (source.peekPixels(&pixmap)) {
14         sk_sp<SkImage> image = SkImage::MakeCrossContextFromPixmap(dContext, pixmap, false);
15         canvas->drawImage(image, 0, 0);
16     }
17 }
18 }  // END FIDDLE
19