Flutter Engine
The Flutter Engine
Image_CrossContextTextureFromPixmap.cpp
Go to the documentation of this file.
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.
4REG_FIDDLE(Image_CrossContextTextureFromPixmap, 256, 64, false, 4) {
5 void draw(SkCanvas * canvas) {
6 auto dContext = GrAsDirectContext(canvas->recordingContext());
7 if (!dContext) {
8 return;
9 }
10
11 SkPixmap pixmap;
12 if (source.peekPixels(&pixmap)) {
14 canvas->drawImage(image, 0, 0);
15 }
16 }
17} // END FIDDLE
static GrDirectContext * GrAsDirectContext(GrContext_Base *base)
REG_FIDDLE(Image_CrossContextTextureFromPixmap, 256, 64, false, 4)
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition: aaclip.cpp:27
bool peekPixels(SkPixmap *pixmap) const
Definition: SkBitmap.cpp:635
virtual GrRecordingContext * recordingContext() const
Definition: SkCanvas.cpp:1637
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition: SkCanvas.h:1528
SkBitmap source
Definition: examples.cpp:28
SK_API sk_sp< SkImage > CrossContextTextureFromPixmap(GrDirectContext *context, const SkPixmap &pixmap, bool buildMips, bool limitToMaxTextureSize=false)
sk_sp< const SkImage > image
Definition: SkRecords.h:269