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

Unified Diff: src/core/SkRemote.cpp

Issue 1418483006: SkRemote: some images, many TODOs (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: drop drawSprite Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkRemote.cpp
diff --git a/src/core/SkRemote.cpp b/src/core/SkRemote.cpp
index bc89e6ff2a6f983c2526fc6c4ef063326e3d2052..c4d230f8a113eead2db17ff38739ca026f3dec99 100644
--- a/src/core/SkRemote.cpp
+++ b/src/core/SkRemote.cpp
@@ -9,6 +9,7 @@
#include "SkCanvas.h"
#include "SkColorFilter.h"
#include "SkDrawLooper.h"
+#include "SkImage.h"
#include "SkImageFilter.h"
#include "SkMaskFilter.h"
#include "SkPath.h"
@@ -160,6 +161,12 @@ namespace SkRemote {
void willSave() override { fEncoder-> save(); }
void didRestore() override { fEncoder->restore(); }
+ SaveLayerStrategy willSaveLayer(const SkRect* bounds,
+ const SkPaint* paint,
+ SaveFlags flags) override {
+ // TODO
+ return kNoLayer_SaveLayerStrategy;
+ }
void didConcat(const SkMatrix&) override { this->didSetMatrix(this->getTotalMatrix()); }
void didSetMatrix(const SkMatrix& matrix) override {
@@ -210,6 +217,131 @@ namespace SkRemote {
this->onDrawPath(path, paint);
}
+ void onDrawPoints(PointMode mode,
+ size_t count,
+ const SkPoint pts[],
+ const SkPaint& paint) override {
+ // TODO
+ }
+
+ void onDrawDrawable(SkDrawable* drawable, const SkMatrix* matrix) override {
+ // TODO
+ }
+
+ void onDrawPicture(const SkPicture* pic,
+ const SkMatrix* matrix,
+ const SkPaint* paint) override {
+ // TODO
hal.canary 2015/11/03 15:09:56 Isn't this->INHERITED::onDrawPicture(pic, m
mtklein 2015/11/03 15:24:30 Done.
+ }
+
+ void onDrawVertices(VertexMode vmode,
+ int vertexCount,
+ const SkPoint vertices[],
+ const SkPoint texs[],
+ const SkColor colors[],
+ SkXfermode* xmode,
+ const uint16_t indices[],
+ int indexCount,
+ const SkPaint& paint) override {
+ // TODO
+ }
+
+ void onDrawPatch(const SkPoint cubics[12],
+ const SkColor colors[4],
+ const SkPoint texCoords[4],
+ SkXfermode* xmode,
+ const SkPaint& paint) override {
+ // TODO
+ }
+
+ void onDrawAtlas(const SkImage* atlas,
+ const SkRSXform xform[],
+ const SkRect tex[],
+ const SkColor colors[],
+ int count,
+ SkXfermode::Mode mode,
+ const SkRect* cull,
+ const SkPaint* paint) override {
+ // TODO
+ }
+
+ void onDrawBitmap(const SkBitmap& bitmap,
+ SkScalar left,
+ SkScalar top,
+ const SkPaint* paint) override {
+ auto src = SkRect::MakeWH(bitmap.width(), bitmap.height()),
+ dst = src.makeOffset(left, top);
+ this->onDrawBitmapRect(bitmap, &src, dst, paint, kStrict_SrcRectConstraint);
+ }
+
+ void onDrawBitmapRect(const SkBitmap& bitmap,
+ const SkRect* src,
+ const SkRect& dst,
+ const SkPaint* paint,
+ SrcRectConstraint constraint) override {
+ SkAutoTUnref<SkImage> image(SkImage::NewFromBitmap(bitmap));
+ this->onDrawImageRect(image, src, dst, paint, constraint);
+ }
+
+ void onDrawImage(const SkImage* image,
+ SkScalar left,
+ SkScalar top,
+ const SkPaint* paint) override {
+ if (!image) {
+ return;
+ }
+ auto src = SkRect::MakeWH(image->width(), image->height()),
+ dst = src.makeOffset(left, top);
+ this->onDrawImageRect(image, &src, dst, paint, kStrict_SrcRectConstraint);
+ }
+
+ void onDrawImageRect(const SkImage* image,
+ const SkRect* src,
+ const SkRect& dst,
+ const SkPaint* paint,
+ SrcRectConstraint constraint) override {
+ // TODO: this is all a (likely buggy) hack to get images drawing quickly.
+ if (!image) {
+ return;
+ }
+
+ auto bounds = SkRect::MakeWH(image->width(), image->height());
+ if (!src) {
+ src = &bounds;
+ }
+ auto matrix = SkMatrix::MakeRectToRect(*src, dst, SkMatrix::kFill_ScaleToFit);
+
+ SkAutoTUnref<SkImage> subset;
+ if (src) {
+ if (!bounds.intersect(*src)) {
+ return;
+ }
+ subset.reset(image->newSubset(bounds.roundOut()));
+ image = subset;
+ }
+
+ auto paintWithShader = paint ? *paint : SkPaint();
+ SkAutoTUnref<SkShader> shader(
+ image->newShader(SkShader::kClamp_TileMode, SkShader::kClamp_TileMode, &matrix));
+ paintWithShader.setShader(shader);
+
+ this->onDrawRect(dst, paintWithShader);
+ }
+
+ void onDrawBitmapNine(const SkBitmap& bitmap,
+ const SkIRect& center,
+ const SkRect& dst,
+ const SkPaint* paint) override {
+ // TODO
hal.canary 2015/11/03 15:04:01 SkAutoTUnref<SkImage> image(SkImage::NewFromBitmap
mtklein 2015/11/03 15:24:31 Done.
+ }
+
+ void onDrawImageNine(const SkImage* image,
+ const SkIRect& center,
+ const SkRect& dst,
+ const SkPaint* paint) override {
+ // TODO
hal.canary 2015/11/03 15:04:01 SkNinePatchIter iter(image->width(), image->height
mtklein 2015/11/03 15:24:31 Done.
+ }
+
void onDrawText(const void* text, size_t byteLength,
SkScalar x, SkScalar y, const SkPaint& paint) override {
// Text-as-paths is a temporary hack.
@@ -239,22 +371,31 @@ namespace SkRemote {
}
void onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle edgeStyle) override {
+ this->INHERITED::onClipRect(rect, op, edgeStyle);
hal.canary 2015/11/03 15:04:01 // Please add comment explaining why we need this.
mtklein 2015/11/03 15:24:31 // Done.
SkPath path;
path.addRect(rect);
this->onClipPath(path, op, edgeStyle);
}
void onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyle edgeStyle) override {
+ this->INHERITED::onClipRRect(rrect, op, edgeStyle);
SkPath path;
path.addRRect(rrect);
this->onClipPath(path, op, edgeStyle);
}
void onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle edgeStyle) override {
+ this->INHERITED::onClipPath(path, op, edgeStyle);
fEncoder->clipPath(this->id(path), op, edgeStyle == kSoft_ClipEdgeStyle);
}
+ void onClipRegion(const SkRegion& region, SkRegion::Op op) override {
+ this->INHERITED::onClipRegion(region, op);
+ // TODO
+ }
+
Encoder* fEncoder;
+ typedef SkCanvas INHERITED;
};
SkCanvas* NewCanvas(Encoder* encoder) { return new Canvas(encoder); }
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698