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

Unified Diff: gm/surface.cpp

Issue 583773004: Revert of introduce Props to surface (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gm/image.cpp ('k') | gm/xfermodes3.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/surface.cpp
diff --git a/gm/surface.cpp b/gm/surface.cpp
deleted file mode 100644
index dbcced2cbfabf4d4282fd64c85d270279cbaf383..0000000000000000000000000000000000000000
--- a/gm/surface.cpp
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright 2014 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "gm.h"
-#include "SkGradientShader.h"
-#include "SkSurface.h"
-#include "SkSurfaceProps.h"
-
-#define W 200
-#define H 100
-
-static SkShader* make_shader() {
- int a = 0x99;
- int b = 0xBB;
- SkPoint pts[] = { { 0, 0 }, { W, H } };
- SkColor colors[] = { SkColorSetRGB(a, a, a), SkColorSetRGB(b, b, b) };
- return SkGradientShader::CreateLinear(pts, colors, NULL, 2, SkShader::kClamp_TileMode);
-}
-
-static SkSurface* make_surface(GrContext* ctx, const SkImageInfo& info, SkPixelGeometry geo,
- int disallowAA, int disallowDither) {
- uint32_t flags = 0;
- if (disallowAA) {
- flags |= SkSurfaceProps::kDisallowAntiAlias_Flag;
- }
- if (disallowDither) {
- flags |= SkSurfaceProps::kDisallowDither_Flag;
- }
-
- SkSurfaceProps props(flags, geo);
- if (ctx) {
- return SkSurface::NewRenderTarget(ctx, info, 0, &props);
- } else {
- return SkSurface::NewRaster(info, &props);
- }
-}
-
-static void test_draw(SkCanvas* canvas, const char label[]) {
- SkPaint paint;
-
- paint.setAntiAlias(true);
- paint.setLCDRenderText(true);
- paint.setDither(true);
-
- paint.setShader(make_shader())->unref();
- canvas->drawRect(SkRect::MakeWH(W, H), paint);
- paint.setShader(NULL);
-
- paint.setColor(SK_ColorWHITE);
- paint.setTextSize(32);
- paint.setTextAlign(SkPaint::kCenter_Align);
- canvas->drawText(label, strlen(label), W / 2, H * 3 / 4, paint);
-}
-
-class SurfacePropsGM : public skiagm::GM {
-public:
- SurfacePropsGM() {}
-
-protected:
- SkString onShortName() SK_OVERRIDE {
- return SkString("surfaceprops");
- }
-
- virtual SkISize onISize() SK_OVERRIDE {
- return SkISize::Make(W * 4, H * 5);
- }
-
- virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
- GrContext* ctx = canvas->getGrContext();
-
- // must be opaque to have a hope of testing LCD text
- const SkImageInfo info = SkImageInfo::MakeN32(W, H, kOpaque_SkAlphaType);
-
- const struct {
- SkPixelGeometry fGeo;
- const char* fLabel;
- } rec[] = {
- { kUnknown_SkPixelGeometry, "Unknown" },
- { kRGB_H_SkPixelGeometry, "RGB_H" },
- { kBGR_H_SkPixelGeometry, "BGR_H" },
- { kRGB_V_SkPixelGeometry, "RGB_V" },
- { kBGR_V_SkPixelGeometry, "BGR_V" },
- };
-
- SkScalar x = 0;
- for (int disallowAA = 0; disallowAA <= 1; ++disallowAA) {
- for (int disallowDither = 0; disallowDither <= 1; ++disallowDither) {
- SkScalar y = 0;
- for (size_t i = 0; i < SK_ARRAY_COUNT(rec); ++i) {
- SkAutoTUnref<SkSurface> surface(make_surface(ctx, info, rec[i].fGeo,
- disallowAA, disallowDither));
- test_draw(surface->getCanvas(), rec[i].fLabel);
- surface->draw(canvas, x, y, NULL);
- y += H;
- }
- x += W;
- }
- }
- }
-
-private:
- typedef GM INHERITED;
-};
-
-DEF_GM( return new SurfacePropsGM )
« no previous file with comments | « gm/image.cpp ('k') | gm/xfermodes3.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698