• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2021 Google LLC
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #include "experimental/graphite/src/Surface_Graphite.h"
9 
10 #include "experimental/graphite/include/SkStuff.h"
11 #include "experimental/graphite/src/Device.h"
12 #include "experimental/graphite/src/Image_Graphite.h"
13 #include "experimental/graphite/src/Recorder.h"
14 
15 namespace skgpu {
16 
Surface_Graphite(sk_sp<Device> device)17 Surface_Graphite::Surface_Graphite(sk_sp<Device> device)
18         : SkSurface_Base(device->width(), device->height(), &device->surfaceProps())
19         , fDevice(std::move(device)) {
20 }
21 
~Surface_Graphite()22 Surface_Graphite::~Surface_Graphite() {}
23 
onNewCanvas()24 SkCanvas* Surface_Graphite::onNewCanvas() { return new SkCanvas(fDevice); }
25 
onNewSurface(const SkImageInfo & ii)26 sk_sp<SkSurface> Surface_Graphite::onNewSurface(const SkImageInfo& ii) {
27     return MakeGraphite(fDevice->refRecorder(), ii);
28 }
29 
onNewImageSnapshot(const SkIRect * subset)30 sk_sp<SkImage> Surface_Graphite::onNewImageSnapshot(const SkIRect* subset) {
31     SkImageInfo ii = subset ? this->imageInfo().makeDimensions(subset->size())
32                             : this->imageInfo();
33 
34     return sk_sp<Image_Graphite>(new Image_Graphite(ii));
35 }
36 
onWritePixels(const SkPixmap &,int x,int y)37 void Surface_Graphite::onWritePixels(const SkPixmap&, int x, int y) {}
onCopyOnWrite(ContentChangeMode)38 bool Surface_Graphite::onCopyOnWrite(ContentChangeMode) { return true; }
39 
40 } // namespace skgpu
41